Jump to content
Sign in to follow this  

About This Club

Many are getting sick and tired of Windows. This is to help you get comfortable with Linux and Mac terminal since its linux.

Location

United States

  1. What's new in this club
  2. First it would be helpful to get a list of users that are already on your Linux box. Get a List of All Users using the /etc/passwd File Local user information is stored in the /etc/passwd file. Each line in this file represents login information for one user. less /etc/passwd Below is an example $ less /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:997:User for polkitd:/:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin nginx:x:998:996:nginx user:/var/cache/nginx:/bin/sh mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin dockerroot:x:997:993:Docker User:/var/lib/docker:/sbin/nologin netadm1n:x:1000:1000:netadm1n:/home/netadm1n:/bin/bash Each line has seven fields delimited by colons that contain the following information: User name Encrypted password (x means that the password is stored in the /etc/shadow file) User ID number (UID) User’s group ID number (GID) Full name of the user (GECOS) User home directory Login shell (defaults to /bin/bash) If you want to display only the username you can use either awk or cut commands to print only the first field containing the username: Using awk example: $ awk -F: '{ print $1}' /etc/passwd root bin daemon adm lp sync shutdown halt mail operator games ftp nobody systemd-network dbus polkitd postfix sshd tss nginx mysql apache dockerroot netadm1n Using cut example: $ cut -d: -f1 /etc/passwd root bin daemon adm lp sync shutdown halt mail operator games ftp nobody systemd-network dbus polkitd postfix sshd tss nginx mysql apache dockerroot netadm1n So you may have identified your Linux system doesn't have a user on it that needs to exist. Let's go to the next section that describes how to add a user How to Create Users in Linux In Linux, you can create a user account and assign the user to different groups using the useradd command. The general syntax for the useradd command is as follows: useradd [OPTIONS] USERNAME NOTE: To be able to use the useradd command and create new users you need to be logged in as root or a user with sudo access. To create a new user account type useradd followed by the username. For example to create a new user named username you would run: useradd username The command adds an entry to /etc/passwd /etc/shadow /etc/group /etc/gshadow files To be able to log in as the newly created user, you need to set the user password. To do that run the passwd command followed by the username: passwd username You will be prompted to enter and confirm the password. In most Linux distros, when creating a new user account with the useradd command the user home directory is not created. Use the -m (--create-home) option to create the user home directory as /home/username: useradd -m username The command above creates the new user’s home directory and copies files from /etc/skel directory to the user’s home directory.
  3. wildweaselmi

    general images

    some linux focused images
  4.  
×
×
  • Create New...