Linux Tricks and Techniques

For Linux Experts

Use the website for easy leaning of Linux

Tuesday, 31 May 2016

Linux User Add Basics

 How to add user in Linux

Some basic commands to add user in Linux are as given below:

1. To add a user type

# useradd user1

user1 is the username

2. To add password for user1

# passwd user1
new password:&&&&
reenter password :&&&&

Password set successfully

3.To check the user added
# cat /etc/passwd

will show

username: password: UID: PID: User info: Home directory: Shell

4. How to create a user with different home directory

# useradd -d username

to check
#cat /etc/passwd  | grep username will show the details

5.How to create a user with specific UID

# useradd -u 999 username

6. How to add user with specific GID

# useradd -g 500 username

7.How to add a user to different groups

# useradd -G group1 group2 group3

8. How to add a user without home directory

# useradd -M username

9.How to add a user with comments

# useradd -c "comments" username

10. How to change the user shell

# useradd -s shellname username

11. To set the new default value for user

# useradd -D

No comments:
Write comments