tags: os operating-system computer linux unix is_child_of: operating-systems
Users
Adding users
We can add users using command useradd
useradd nitin
We have to create a directory of this user and user permissions to that directory.
mkdir /home/nitin
chown nitin /home/nitin
Now if we see the permissions we will see,
root@515d32d1d259:/home/hemant# ls -alrt /home
total 12
drwxr-xr-x 1 nitin root 4096 Apr 6 11:27 nitin
drwxr-xr-x 1 root root 4096 Apr 6 11:27 ..
drwxr-xr-x 1 root root 4096 Apr 6 11:39 .
There is one more way to create a user.
adduser nitin
This does everything for you.
Deleting user
userdel nitin
rm -rf /home/nitin
or
deluser nitin
Switching user
su nitin
su
is switch user command.
Changing the password
passwd nitin
New Password:
Retype New Password:
Groups
A group is a collection of users with a set of permissions.
Creating a group
groupadd bitphile
Adding group to directory and file
chgrp nitin /home/nitin
Adding user to the group
usermod -aG bitphile nitin
-aG
means add group.
Delete user from the group
gpasswd -d bitphile nitin
Delete group
groupdel bitphile
See also
- sudoers file