Thursday 23 June 2016

User and Group Management in CentOS 6/RHEL 6

User and Group Management

In linux operating system root is the administrator user who is having all the privileges, root user is also called superuser, root can access all files and commands on linux.
root user id is 0
If you want to check system user related information in /etc/passwd file

{In RHEL 6 by default UID assigned to users would start from 500 but in RHEL 7 change in UID allocation, any new users would get UIDs starts assigned from 1000. If you don't want  UID starts from 1000 you can change this in /etc/login.defs }

By default users home directory is created under /home

To create new user
[root@server ~]# useradd arun

Set password for newly created user
[root@server ~]# passwd --stdin arun
Changing password for user arun.
arun123
passwd: all authentication tokens updated successfully.

Check the details of new user account added in /etc/passwd

[root@server ~]# tail -n 1 /etc/passwd
arun:x:500:500::/home/arun:/bin/bash

Check the group account information in /etc/group
[root@server ~]# tail -n 1 /etc/group
arun:x:500:

To delete user account
#userdel arun

To delete user with home directory
#userdel -r arun

To create new group called mango
#groupadd mango

To create a group with particular group ID
#groupadd –g 555 mango

To modify existing user home directory
#usermod –d /home/apps arun
{above command will change the existing user arun home directory from /home/arun to /home/apps }

To change the user’s home directory with content
#usermod –m –d /home/newapps arun

To change user’s default shell using two command usermod & chsh
#usermod –s /bin/sh arun

(OR)

# chsh -s /bin/sh arun
Changing shell for arun.
Shell changed.

To view the available shell
#chsh –l

How to change default user home directory while adding a new user
[root@server ~]# cat /etc/default/useradd 
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes












No comments:

Post a Comment