Understanding Linux users and groups
Manage user accounts
Manage group accounts
Creating user account at the command line
useradd
userdel
passwd
Modifying user accounts
usermod
useradd -D
-c "bablu kumar"
=> comment
-s "/bin/ksh"
=> setting a shell
By default, a user is a member of its own group.
(*
) => indicates they can't login because they are service accounts.
(!!
) => indicates that no password is set yet.
To make sure, all new members get, for example a company policy, in their home directory. We can add that to the /etc/skel
usermod -L bk
=> Locks the bk's account
Looking into the /etc/shadow
file indicates the account has been locked.
usermod -U bk
If you just want to delete the user; userdel username
In this case, the user's home directory remains intact.
Deleting a user including her/his home directory: userdel -r username
Remember to take a backup before doing it though.
Creating groups at the command line
groupadd
groupdel
Creating groups in the GUI
Modifying groups
groupmod
-a
=> append to
-G
=> a supplemental group
-g
=> switch a primary group
You can also check the group information in /etc/group
:
usermod -aG wheel bkumar # Now bkumar can use sudo do tasks that require priviledges on Red Hat systemsusermod -aG admin bkumar # used in Ubuntu (Debian) systems for the same purposes.
su -
it logs into the root account if you have the root's password
sudo -i
it also does the same but once you are in the wheel group, you need to type in your password rather than the root's password which is a safer way.
sudo visudo
contains the configuration file for the sudo management.
/etc/sudoers.d/
contains some snap in files that lets you add these configurations as snap-ins.
Delete the group: groupdel groupname