- id – Give information about your current user, your user id, group id and the group you are belonged to.
If we give it a username then it will give information about this username.For example if I want information about julia then I just run id julia
$ id julia uid=1001(julia) gid=1001(julia) groups=1001(julia)
- useradd <username> – will create a new user with the given username.
we can use the “-m” option and it will create the home directory for the user.
useradd -m oren
will create user with the username “oren” and will create for it home directory (because the “-m” param).
when we create home directory, all the files in /etc/skel will be copied into the new home directory.
- userdel <username> – will delete the given username.
we can use -r for deleting the home directory of the user to be deleted.In the below example we remove the user julia together with its (user) home directory:
userdel -r julia
- usermod – changing user
- for example to update the comment of user julia to “user julia”, we will use the “-c” option:
$ usermod -c "user julia" julia
The -s option is used to change the login shell.
If we have service user account and we want to prevent login from this account, then we can change the login shell to “/bin/false”.
For example say we have an account “apache” and we want to prevent login from this account:
bob@vmUbuntu:~$ sudo usermod -s /bin/false apache
- We can use ~ to navigate to our home directory, or ~username to navigate to user name home directory.
For example if we want to navigate to julia home directory:
- we can use passwd -l to lock user account.
For example to lock bob account:
passwd -l bob
We can also use usermod -L command to do the same:
usermod -L bob
will lock bob account.
if we want to unlock its account we can use passwd -u
passwd -u bob
will unlock bob account.
- reserved for the system account < 100
- demon accounts between 100 and 500
File store information about users and groups
- /etc/passwd – list of all users, the login shell, home directory, user id.
- /etc/shadow – contain the password of the users in their hash format.
- /etc/group – contain a list of all groups and the group id