How to create user in Linux

How to create user in Linux ?


Today we will see in this post that how to create user and group in Linux through command line. It's very easy to create, change, modify and delete user and group information. Please read full articles if you face any problem regarding this articles so please leave comments or drop email within 24 hours you will get reply by our team. 

Please leave comment if this article good and share it also. 


About Users


To create an user:

[root@localhost ONS]# useradd test

To set password on a user:

[root@localhost ONS]# passwd test
Changing password for user test.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

To add comment user:

[root@localhost ONS]# useradd -c “IT” test

To set/Change UID on user:

[root@localhost ONS]# useradd -u 0786 test

To set/change directory of user:

[root@localhost ONS]# useradd –d /home/test test

To add a user to a primary group and supplementary group:

[root@localhost ONS]# useradd -g “head” -G “faculty” test

To Lock the user account:

[root@localhost ONS]# passwd -L test
Locking password for user test.
passwd: Success

To unlock the user account:

[root@localhost ONS]# passwd -U test
Unlocking password for user test.
passwd: Success

To change login name of the user:

[root@localhost ONS]# usermod -l “test1” test

To remove/delete user with his home directory:

[root@localhost ONS]# userdel -r test

To delete/remove user only:

[root@localhost ONS]# userdel test



To set maximum days of change password:

[root@localhost ONS]# passwd -x 30 test

To set minimum days of change password:

[root@localhost ONS]# passwd -n 3 test

To set warning days to change password:

[root@localhost ONS]# passwd -w 25 test

To set all command in one command:

[root@localhost ONS]# passwd -x 30 -n 3 -w 25 test

To check user information

To check the user information such as UID, Home directory, login shell etc:

[root@localhost ONS]# vi /etc/passwd

To check the all information about user password information:

[root@localhost ONS]# vi /etc/shadow


Hope this will help to all of you and resolved your all query if you have any query or question so you may ask to send email on our email account (onlinenetworkssolution@gmail.com) or leave comment on page.



Share:

0 comments

Please leave your comments...... Thanks