Managing Users and Groups in Linux
This tutorial describes How to Managing Users and Groups in Linux
The most important part of system administration is configuring and managing users and groups. This article describes how to manage users and groups.
User Administration in Linux
When we create a new user in linux, following process are taking place.
* User informations stored in /etc/passwd
* Encrypted password information stored in /etc/shadow
* Creating a home directory under /home/username
* Creating a mail box in /var/spool/mail/username
/etc/passwd
Let's begin with /etc/passwd file,/etc/passwd file stores user account information. /etc/passwd is a text file, which contains username,password,user id,group id,user id information,login shell, separated with colon (:) .
# vim /etc/passwd
Note:
For root user entry in /etc/passwd file will be like this :- root:x:0:0:root:/root:/bin/bash
To deactivate a user's login, change login shell parameter /bin/bash to /sbin/nologin
/etc/shadow
/etc/shadow file stores encrypted password information. Each line of this file contains 9 fields, separated by colons (“:”), in the following order:# vim /etc/shadow
/etc/group
It stores group information. It defines the groups to which users belong. Each line of this file contains 4 fields, separated by colons (“:”), in the following order:# vim /etc/group
Commands
Create new user
# useradd alleria
Update user password
# passwd alleria
Change home directory of a user at the time of useradd
# useradd -d /admincool pugnaSwitch a user
# su - pugna
Delete user
# userdel -r alleriaCreate a group
# groupadd group1Delete a group
# groupdel group1Add a new user to a group
# useradd -g group1 alleriaPrint groups of a user
# groups alleriaSpecify secondary group
# useradd -G group2 pudge# groups pudge
Modify an existing user using usermod command
# usermod -g group2 alleria
# groups alleria
Assign multiple groups to a user
# usermod -G group1,group2,group3,group4,group5 alleria# groups alleria
I am really interested in this topic. Is more coming?
ReplyDelete