User and Group Administration

User and  Group Administration-
User(u)    -u
Group(g) -
Owner(own)


Command Mode Practice These Steps:-

vim  /etc/passwd : contains user information

vim  /etc/shadow  : contains users password information
vim  /etc/group : contains groups information

cat /etc/passwd : to view total users info

cat /etc/passwd | grep sam  (or) getent passwd sam : to view only sam users information
cat /etc/shadow : to view passwords of all existing users
cat /etc/shadow | grep sam (or) getent shadow sam : to view only sam users password
cat /etc/group : to view all groups information
cat /etc/group | grep hr (or) getent group hr : to view only hr group information.

useradd <option> <username>

-u : TO change uid

syn: useradd -u <uidno> <username>
ex: useradd -u 1000  sraviin

-g : to add an user into a group

useradd -g <groupname> <username>

ex: useradd -g cyber sravn


-G :to add an user into a group

useradd -G <groupname> < username>

-s :to change shell

useradd -s <shell> <username>
/sbin/nologin: user can't able to login from this pc(he can login from remote pc)
syntax: useradd -s /sbin/nologin admin
/bin/false : user can't login from this pc from remote pc
useradd -s /bin/false <username>
-d : to change home directory of an user
syntax:useradd -d <home dir place> <username>
useradd -d /usr/mahi  mahi

To modify an existing users account


usermod : usermod is the command to change modifications to an exisiting user account.


usermod -u <username> : to change uid of an existing user

usermod -G <groupname> <username> : to add an user into an existing group along with his primary group
usermod -g <groupname> <username> : to add an existing user into an existing group with out his primary group
usermod -d <home directory> <username> : to change an existing users home directory.
usermod -s <shell> <username> : to change shell for an existing user

gpasswd -a  : to add an user into ennumber of groups
syntax: gpasswd -a <username> <groupname>
ex: gpasswd -a  srinu  hr
here we are adding srinu  into hr group

gpasswd -d : to remove an user from a group
syntax: gpasswd -d <username> <groupname>
ex: gpasswd -d srinu  hr
here we are removing srinu from hr group

gpasswd -M : to add N number of existing users into  a group 
syntax: gpasswd -M <user1>,<user2>,<user3> <groupname>
ex: gpasswd -M  mahti,nabi,rajaa  hr
here we are adding mahti,nabi,rajaa  into hr group

userdel -r :delete an user account
syntax: userdel -r <username>
ex: userdel -r nabi (here we are deleting user nabi)


Group: group is nothing but logical grouping of users :

groupadd : this is the command to add a group
syntax: groupadd <groupname>
ex: groupadd  itdprt

groupdel : groupdel is the command to remove a group.
syntax: groupdel <groupname>
ex: groupdel itdepart (here we are deleting itdepart group).

groupmod : used to modify an existing group.
options:
-n : to change name of a group
syntax: groupmod -n <newname> <oldname>
ex: groupmod -n itdepartment  itdpt

chgrp : chgrp is the command to change group ownership 
syntax: chgrp <groupname> <file or dir name>
ex: chgrp itdepart   /bds
here we are changing groupownership of /net to itdept  group

chown : chown is the command to change ownership of a file or directory
synax:  chown <username> <file or dir name>
ex: chown nabi   /obs/oops
here we are changing ownership of /java/oops to mahesh

chown -R :to change ownership & groupownership  directory file also same
syntax: chown -R <owner:groupowner> <file or dir>
ex: chown -R mahesh:itdepartment  /java/oops
here we are changing ownership of /java/oops to mahesh & groupownership to itdepartment group

Comments

Popular posts from this blog

Linux Basic Commands and Memory relarated commands Very usefull

Job Scheduling or Scheduling jobs Manually

System Run level or INIT Process