Tanti Technology

My photo
Bangalore, karnataka, India
Sandeep Kumar | Founder, Tanti Technologies At Tanti Technologies, I share practical knowledge, hands-on tutorials, and real-world solutions across Python, SQL, Docker, Kubernetes, CI/CD, AWS, Azure, Machine Learning, Generative AI, and Agentic AI. My mission is to simplify complex technologies and provide actionable insights that help developers, engineers, and businesses learn faster, build better, automate smarter, and innovate with confidence. 🚀 Learn • Build • Automate • Innovate Follow Tanti Technologies for practical technology insights and next-generation AI solutions.

Wednesday, 30 August 2017

User and Group Administration Concept On RHEL / CentOS 5&6


In 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

-u : TO change uid
syn: useradd -u
ex: useradd -u 1000  mahesh

-g : to add an user into a group(with out primary group)
useradd -g

ex: useradd -g cyber naveen

-G :to add an user into a group(with primary group)
useradd -G < username>

-s :to change shell
useradd -s
/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
-d : to change home directory of an user
syntax:useradd -d
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 : to change uid of an existing user
usermod -G : to add an user into an existing group along with his primary group
usermod -g : to add an existing user into an existing group with out his primary group
usermod -d : to change an existing users home directory.
usermod -s : to change shell for an existing user

gpasswd -a  : to add an user into ennumber of groups
syntax: gpasswd -a
ex: gpasswd -a  mahesh  hr
here we are adding mahesh  into hr group

gpasswd -d : to remove an user from a group
syntax: gpasswd -d
ex: gpasswd -d mahesh  hr
here we are removing mahesh from hr group

gpasswd -M : to add ennumber of existing users into  a group along with primary group.
syntax: gpasswd -M ,,
ex: gpasswd -M  mahesh,naveen,raju  hr
here we are adding mahesh,naveen,raju  into hr group

userdel -r : to delete an user account
syntax: userdel -r
ex: userdel -r naveen (here we are deleting user naveen)


Group: group is nothing but logical grouping of users :

groupadd : this is the command to add a group
syntax: groupadd
ex: groupadd  itdepart

groupdel : groupdel is the command to remove a group.
syntax: groupdel
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
ex: groupmod -n itdepartment  itdepart

chgrp : chgrp is the command to change group ownership of a file or directory
syntax: chgrp
ex: chgrp itdepartment   /java
here we are changing groupownership of /java to itdepartment  group

chown : chown is the command to change ownership of a file or directory
synax:  chown
ex: chown mahesh   /java/oops
here we are changing ownership of /java/oops to mahesh

chown -R :to change ownership & groupownership of a file or directory
syntax: chown -R
ex: chown -R mahesh:itdepartment  /java/oops
here we are changing ownership of /java/oops to mahesh & groupownership to itdepartment group

No comments:

Post a Comment