Is it possible to add a user in ubuntu linux without useradd command I think its possible by adding the entries in /etc/passwd and /etc/shadow but i don't know the exact steps to do it and the user should get its home directory and bash shell too.


It's not recommended to manually modify /etc/passwd, /etc/shadow, /etc/group or /etc/gshadow because the risk of breakage. If you're looking for an alternative command that is easier to use, take a look at adduser(8). All you have to run is:

sudo adduser user

The shell will be /bin/bash by default per /etc/adduser.conf.

Usually, if you wish to add a user with the bash shell, thereby create a home directory /home/user and a user group, you would use:

sudo useradd --create-home --shell /bin/bash --user-group user

This command is basically determining a free User ID $UID and Group ID $GID and then executing the next commands:

echo "user:x:$UID:$GID::/home/user:/bin/bash" | sudo tee -a /etc/passwd
echo "user:x:$GID:" | sudo tee -a /etc/group
echo "user:!:$DATE_OF_LAST_PASS_CHANGE:0:99999:7:::" | sudo tee -a /etc/shadow
echo "user:!::" | sudo tee -a /etc/gshadow

..and thereby possibly making a backup of the files.

The next manual pages about the file formats may be of interest to you:

  • hey, Lekensteyn, did you miss this first part of their post? "Is it possible to add a user in ubuntu linux without useradd command..." They want a solution without useradd :/ – Thomas Ward Jul 29 '11 at 14:46
  • 1
    @TheEvilPhoenix: I thought he was asking about an alternative for adduser. I've now included adduser as answer. It's indeed "without useradd" :) – Lekensteyn Jul 29 '11 at 14:53
  • No problem, wanted to point it out is all. and forgive me being semiconfrontational... long, bad days at work with cascade server failure does that to ya... – Thomas Ward Jul 29 '11 at 15:40
  • @All I want to create user without useradd by adding possible entries in /etc/passwd and /etc/shadow – mr_eclair Jul 29 '11 at 17:24
  • 2
    @m59 >> tries to open a file as the current (non-root) user which will fail with a Permission denied error. Using sudo tee bypasses that. Alternatively, you could wrap the command in a sudo sh -c '...' to avoid that issue. – Lekensteyn Nov 18 '16 at 16:33

Although not usually necessary or recommended, the answer to the question of How to add user without useradd command is to use sudo vipw

This will launch your system-defined editor while locking the passwd file. Enter a line for a new user. (In vi, shift-G to get to the last line then yy p to duplicate it.) Edit the username and create a unique user ID number.

After saving the file and exiting the editor, you'll be prompted to edit /etc/shadow. Use the same technique to create a new line and use "*" for the password hash. The new account is locked. Use passwd username to unlock it and set a password.

It's also necessary to create a home directory, copy files from the skeleton directory, set group permissions, etc. But vipw is your main resource. See also vigr.

Source: http://itguykelly.wordpress.com/2011/04/19/manually-add-new-user-to-red-hatfedoracentos/ (yes, these commands work across various flavors of *nix)


When the user is created in the system it has effect on the files such as /etc/passed , /etc/group , /etc/shadow so go through these files and make the manual entry . And finally from /etc/skel file add skeleton for user in user's home directory which you have to create in home directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.