In Linux, the useradd command is one of the most popular commands for adding a normal user for Linux distribution. On contrary to what one may think, it is really possible to create a user without making use of the useradd command. In this tutorial you'll get to know the method to create a user without the usage of useradd command.
Make an entry of user details in /etc/passwd location, your syntax for the entry must be as follows.
Add a new entry in /etc/passwd file by making use of the following action.
[root@localhost ~]# vim /etc/passwd user1:x:503:503:testuser:/home/user1:/bin/bash
You will have to create a group with same name. So add a new entry in /etc/group by making use of the following action.
[root@localhost ~]# vim /etc/group user1:x:503:
Now, you need to assign a password to the user and for that you shall use the following command.
[root@localhost home]# passwd user1 Changing password for user user1. New password: Retype new password: passwd: all authentication tokens updated successfully.
After that, you shall check and see the password by using the following command.
[root@localhost home]# cat /etc/shadow |grep user1 user1:$6$26iFvYjR$tMtV35CcMTMjZKaFGUG4A30drTZIvqdSDkhNW8rG0PQ44U6ij4hLo9/H/Jxrr7QPmgExum2cKMTQayK99uINC1:17494::::::
You shall now try to login with your newly created user. Do it the following way.
[root@localhost home]# su user1 bash-4.1$ bash-4.1$ bash-4.1$
You should see [user1@localhost ~]$ instead of bash-4.1$, this is because the newly created user doesn't have home directory, and you should add .bash files from /etc/skel in the following manner.
[root@localhost home]# mkdir /home/user1 [root@localhost home]# cd /home/user1 [root@localhost user1]# cp -v /etc/skel/.bash* . `/etc/skel/.bash_logout' -> `./.bash_logout' `/etc/skel/.bash_profile' -> `./.bash_profile' `/etc/skel/.bashrc' -> `./.bashrc'
You can check out the bash files in the newly copied location by making use of the list command.
[root@localhost user1]# ls -la total 20 drwxr-xr-x 2 root root 4096 Nov 24 15:26 . drwxr-xr-x. 4 root root 4096 Nov 24 15:26 .. -rw-r--r-- 1 root root 18 Nov 24 15:26 .bash_logout -rw-r--r-- 1 root root 176 Nov 24 15:26 .bash_profile -rw-r--r-- 1 root root 124 Nov 24 15:26 .bashrc
Now, try to switch over to your new user by making use of the following command.
[root@localhost user1]# su user1 [user1@localhost ~]$
With this, this tutorial comes to an end.
Thank you! for using Linux Help.
You find this tutorial helpful? Share with your friends to keep
For more help topics browse our website www.linuxhelp.com
Be the first to comment, we value your suggestions. For further queries please comment below.