How To Create User In Red Hat

User and Group Management :

User :

1. USER : All linux user have a used ID and a unique numeric identification number called User Id (UID).

Every user of the system is assigned a unique User ID number. User’s name and UID are stored in /etc/passwd.

User are assigned a home directory and a program that is run when they log in (usually called shell).

Users can not read, write or execute each other files and directory without permission

Types of User User ID
1. Superuser 0
2. System User 1-499
3. Normal User 500-60000

Group :

2. GROUP : All Linux users have a group ID and a unique numeric identification number called Group Id (GID). Users are assigned to group with unique Group ID number. GID are stored in /etc/group file. Each user is given their own private group, they can also be added to other groups to gain the additional access of a particular file or directory. All users in a group can share files that belong to the same group.

When a user is get created in linux its entry is recorded in the following files.

  • 1. /home(user directory)
  • 2. /etc/passwd (uid and gid)
  • 3. /etc/shadow(password )
  • 4. /etc/group(user group)
  • 5. /etc/default/useradd (command)

User creation :

User pid gid
Root (administrator) 0 0
.. .. ..
.. .. ..
End of supper user 499 499

Normal User

User pid gid
Root (administrator) 0 0
Mark 500 500
Tony 501 501
End of normal user 60000 60000

Root=admin, root has 0 pid, user has low pid is power full then the other users.

How to create a user?

Command
#useradd Mark (or)
#adduser Tony

How to create a user with pid 510 in red hat?

Command
#useradd –u 510 Mark

How to give the password the user?

Command
#passwd Mark
New password:*******
Conform password:*******

How to create user by graphical?

Command
#system-config-users
Notepad

Note:- when you create a user then it’s home- directory create in /home
:- it’s mail box is also create in /var/spool/mail/username

Delete user in Red Hat :

#userdel is used for user delete

Command
#userdel Mark

How to delete user and it’s directory?

Command
#userdel -r Mark

Chek :

Command
#ls /home
#cat /etc/passwd
#ls /var/spool/mail/username

Su (switch user) in Red Hat :

How to switch user in Red Hat?

Command
[root@localuser~]#su  -  Mark
[sumit@localuser~]$ ------------(normal user)
[sumit@localuser~]$su - Mark 
Password:*********----------  (give password of Mark)
[raj@localuser~]$
Notepad

Note : Normal user can not login in to other user they have to give the password.

How to create normal user to root?

Command
[Mark@localuser~]$su 
Password:----------(give password of root)
[root@localhost Mark]#

User components :

When you create the user then It’s components create.

Command
#cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
damone:x:2:2:damone:/damone:/sbin/nologin
Mark:x:500:500::/home/mark:/bin/bash
--------------------------------------------------------------
  • (root:) : Username
  • (x:) : password
  • (0:) : uid
  • (0:) : gid
  • (root:) : comment
  • (/root:) : home directory
  • (/bin/bash) : shell

Create a user with uid “700”, comment "sales” home dir in “/tmp/mark”, shell “/bin/ksh”

Command
#useradd -u 700 -c sales -d /tmp/mark -s /bin/ksh mark

Check in the passwd file.

Command
#cat /etc/passwd
Mark:x:700:700:sales: /mp/mark:/bin/ksh

User modification :

How to Lock user in Red Hat?

Command
# usermod –L username

How to unlock user in Red Hat?

Command
#usermod -U username

How to change the comment or give a comment to user in Red Hat?

Command
# usermod -c username

How to change the shell in Red Hat?

Command
# usermod -s /bin/ksh username

How to change the login name in Red Hat?

Command
#usermod –l new-username old-username

How to expire user in Red Hat?

Command
#usermod  -e
#User_and_Group_Management_in_red_hat #User_creation_in_red_hat #How_to_create_a_user_with_pid_in_red_hat #Delete_user_in_Red_Hat #Su_(switch_user)_in_Red_Hat #User_components_in_red_hat #User_modification_in_red_hat

(New page will open, for Comment)

Not yet commented...