User and Group Administration

User and Group Administration

User and Group Administration is used on GNU/Linux for access control — that is, to control access to the system’s files, directories, and peripherals, we discuss some useful commands on user and group management.

User and Group Administration

 

User and Group Administration commands are given below

To add a user

#adduser <username>

#useradd <username>

Set password for user

#passwd

Set user ID

#useradd -u

To change user id

#usermod -u

To set user home directory

#useradd -d

To change user home directory

#usermod -d

To list shell details

#chsh -l

To set user login shell

#useradd -s

To change user login shell

#usermod -s

To change user login shell

#chsh -s

To avoid creation of home directory for the user account

#useradd -M

Add user comments

# usermod -c

To change user name

#usermod -l

set primary group for user,while user creation

#useradd -g

Add user to secondary group,while user creation

#useradd -G

Change primary group for user

#usermod -g
User Info

Display connected users, login time & their console

finger

Display info about that user shell, home dir

finger <username>

To view uid, gid & groups details of that user

id <username>
Group

Group contain two types as “Primary Group” & “secondary group/supplementary” group.If we create a user, group is created along with the user’s name.It is called Primary Group.Other groups are secondary group.We modify the user either primary or secondary group.

Display user’s group

#group

Add group

#groupadd

Change group ID.(Values 0 to 999)

#groupmod -g

Change group name

#groupmod -n

To set group password

#gpasswd group

Remove group password

#gpasswd -r

To remove user from group

#gpasswd -d

Add user to group

#gpasswd -a

set particular user as administrator for group

#gpasswd -A

Remove all administrator from group

#gpasswd -A “”

M-option is used to add multiple user in group

#gpasswd -M

set primary group for user,while user creation

#useradd -g

Add user to secondary group,while user creation

#useradd -G

Change primary group for user

#usermod -g

Add user to multiple Groups

#usermod -a -G g1,g2,g3
ACL – Access Control List
user’s ACL:-

To check file (ACL) permission

#getfacl

To set user (ACL) permission for file

#setfacl -m u:user:rwx

To set default ACL permission. If you have defaults set on a parent directory, new files in that directory inherit those settings

#setfacl -m d:u:user:rwx

To set mask value for directory.(its applicable for all groups and all named users)

#setfacl -m m:rwx

Copying the ACL from a file to another file

#getfacl | setfacl –set-file=-

To remove particular user’s permission

#setfacl -x u:user

To remove all ACL permission

#setfacl -b

Note:-We use -R option for apply ACL to all files and directories recursively.
Group’s ACL:-

Set acl for group

#setfacl -m g:group:rwx

Remove group ACL permission for file

#setfacl -x g:group

Set Default Acl for group in file

#setfacl -m d:g:group:rwx

Note:-We use -R option for apply ACL to all files and directories recursively.

User age & group Age

-m = minimum

-M = maximum

-W = warning

-I = Inactive

Display passwd age details for user

chage -l

chage -m

chage -M

chage -W

chage -I

===============Blass===================




Leave a Reply

Your email address will not be published. Required fields are marked *