Follow these steps to create a user without using useradd command in Red Hat Linux.
Step 1
Add an entry of user details in /etc/passwd
Step 2
You will have to create a group with same name. So add a new entry in /etc/group
Step 3
Assign a password to the user
Now let us try to login with our newly created user
You should see [user@test ~]$ instead of -bash-4.1$ prompt. So why does this happens?
Let us check the contents of its home directory
So, as you see none of the default contents of a normal user home directory is missing.
Final Step 4
NOTE:/etc/skel directory contains all the defaults files which are present inside the home folder of any user
So, copy the contents from /etc/skel inside /home/user using the below command
Now re login to the user
And you are good to go.
IMPORTANT NOTE: But one more thing, did you noticed I didn't touched /etc/shadow file while it also contains all the user related details. As soon as we assign a password to the user an entry for that user is created inside /etc/shadow
NOTE: Do not manually edit /etc/shadow file because it contains the encrypted password section which is automatically generated
Let me know your success and failures
How to give normal user root privileges using sudo in Linux/Unix
How to do Ethernet/NIC bonding/teaming in Red Hat Linux
How to install/uninstall/upgrade rpm package with/without dependencies
Step 1
Add an entry of user details in /etc/passwd
# vi /etc/passwd
user:x:501:501:test user:/home/user:/bin/bash
Step 2
You will have to create a group with same name. So add a new entry in /etc/group
# vi /etc/group
user:x:501:
Step 3
Assign a password to the user
# passwd user
Changing password for user user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Now let us try to login with our newly created user
# su - user
-bash-4.1$
You should see [user@test ~]$ instead of -bash-4.1$ prompt. So why does this happens?
Let us check the contents of its home directory
-bash-4.1$ ls -al
drwxr-xr-x 2 root root 4096 Jan 12 14:27 .
drwxr-xr-x. 3 root root 4096 Jan 12 14:27 ..
So, as you see none of the default contents of a normal user home directory is missing.
Final Step 4
NOTE:/etc/skel directory contains all the defaults files which are present inside the home folder of any user
So, copy the contents from /etc/skel inside /home/user using the below command
[root@test ~]# cp -v /etc/skel/.* /home/user/
cp: omitting directory `/etc/skel/.'
cp: omitting directory `/etc/skel/..'
`/etc/skel/.bash_logout' -> `/home/user/.bash_logout'
`/etc/skel/.bash_profile' -> `/home/user/.bash_profile'
`/etc/skel/.bashrc' -> `/home/user/.bashrc'
`/etc/skel/.emacs' -> `/home/user/.emacs'
cp: omitting directory `/etc/skel/.gnome2'
cp: omitting directory `/etc/skel/.mozilla'
Now re login to the user
[root@test user]# su - user
[user@test ~]$
And you are good to go.
IMPORTANT NOTE: But one more thing, did you noticed I didn't touched /etc/shadow file while it also contains all the user related details. As soon as we assign a password to the user an entry for that user is created inside /etc/shadow
NOTE: Do not manually edit /etc/shadow file because it contains the encrypted password section which is automatically generated
# cat /etc/shadow | grep user
user:$6$HG.agA9Q$X2scLxur6G6FIW0eb1ArgAQcnioNLJmeBjDX.FAvfchXUhElwVKhwa3hHCFMI/vNUdr3fgqcge2PTEaKFfzXW/:16082::::::
Let me know your success and failures
Follow the below links for more tutorials
How to unlink/delete a symbolic in LinuxHow to give normal user root privileges using sudo in Linux/Unix
How to do Ethernet/NIC bonding/teaming in Red Hat Linux
How to install/uninstall/upgrade rpm package with/without dependencies
Multiple connections to a server or shared resource by same user
How to extract files to different directory using tar in Unix/Linux
How to preserve Symbolic links with tar command in Unix/Linux
How to give permission to user to run some commands in Linux
How to set environment (PATH) variable permanently in Linux
How to extract files to different directory using tar in Unix/Linux
How to preserve Symbolic links with tar command in Unix/Linux
How to give permission to user to run some commands in Linux
How to set environment (PATH) variable permanently in Linux