The UserAdd Command is most popular command for addition of normal user for Linux distributions the trick is featured here for How to Create User Without Using UserAdd Command on Linux by following the steps carefully.
There are three types of users present in the Linux OS. So first let’s talk about the users.
- SUPER USER: Superuser has an administrative permission in Linux we called it as root user and Its user ID is 0.
- SYSTEM USER: System users are system created users and so that we can’t have permission to login through these users.
- NORMAL USERS: With these users, we can login into the system. While the installation it asks you to add one normal user of the system,so you can login into the system with this normal user or with the root user.
Step-1 (Add user using UserAdd Command)
# useradd techbrown # passwd gopal Changing password for user gopal. New password: ***** BAD PASSWORD: it is too short BAD PASSWORD: is too simple Retype new password: ***** passwd: all authentication tokens updated successfully.
Step-2 (Normal User Login)
# su – gopal
So let’s talk about what is exactly happening when we use the UserAdd Command.
Here I am explaining it using some steps, but you can use these steps in any order.
So now let’s create it manually
STEP-3 (The system creates a directory with the name of ‘user’ in “/home” directory)
Now we create a user with a username techbrown. So start with the first step
# mkdir /home/techbrown
It will create a home directory for user techbrown
STEP-4 (Creates an entry in /etc/passwd file)
# touch /var/spool/mail/techbrown
This command will create a file in the mail directory so that all mail’s come to the user techbrown directly stores in this file.
STEP-5 (Creates an entry in /etc/shadow file)
Now we create an entry in passwd file so that the getty script will discover a information about the user.
# vim /etc/passwd
Now it will show some users information which that are previously created.
So now just make an entry in it as following or simple way just copy one of the entry from it. By using “yy(yank or copy)” and “p(paste)” and then edit it.
techbrown:x:501:501:Hello techbrown :/home/gopal:/bin/bash 1 :2 :3 :4 :5: 6 : 7
Here in “/etc/passwd“file you have to create 7 entries. Let’s discuss about it shortly.
It indicates that the password is encrypted and stores in a shadow file
Home directory of the User
Last one shell prompt you can check it through “/etc/shells” file.
STEP-6 (Creates an entry in /etc/groups file)
Now we are going to make entry in the shadow file which stores the information about an user with the encrypted password.
# vim /etc/shadow
Now make entry in this file.
techbrown:! !:16244:0:99999:7: : : 1 :2 :3 :4:5 :6:7:8:9
You will see 9 entries presently available in the /etc/shadow file so we will also discuss about that.
Name of a user
Password in encrypted
since 1 January 1970 that the password last changed.
permitted before the password can be changed.
after which the password must be changed.
before the password expires that the user is warned.
after the password expires before the account is disabled.
since 1 January 1970 after which the account is disabled.
Reserved for the feature.
but in above we didn’t edit that so just do the following step
first go to the shell prompt and type following command
# grub-md5-crypt password:[type your password] retype password : [type above password again] $1$YgGpm1$hhDEbeY0mRpKccgyQsWQn0
Now copy and paste this password in this section.
STEP-7 (Create a file for mail address so that the mail come to that user will be shown in that file which is present in “/var/spool/mail/’username’”)
Now create a entry in the /etc/groups directory.
# vim /etc/groups techbrown :x : 501: 1 :2 : 3 :4
Here 1:2:3:4 as
List of users, which are associated with the group.
STEP-8 (create the bash prompts in its home directory)
# touch /var/spool/mail/techbrown
This will create a mail box for the user for techbrown so that the mail generated for user techbrown comes to this file.
Now use this command to login into user techbrown.
# su - techbrown -bash-4.1$[ctrl + d ]
This shows the above error that is a bash error. Means to enter into the user, you should have some bash files into the home directory of the user. So do the following steps.
# cd /etc/skel/ # cp .bash* /home/techbrown # su - techbrown $ [you are in user techbrown ]
Congratulations now you have created the user without useradd command on Alma / Rocky / Amazon Linux.