Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was browsing through some Linux questions and saw this interesting question.

What steps to add a user to a system without using useradd/adduser?

The one possible way that comes to my mind is,

  • Add an entry for the user in /etc/passwd file.
  • Add an entry for the group in /etc/group file.
  • Create the home directory for the added user.
  • Set the new user password using the passwd command.

I tested the above approach and it worked fine.

Is this the only possible way or is there any other work around to achieve this?

share|improve this question
Good question, But where would this be useful? – Networker Sep 1 '14 at 22:40
@Networker, from the same link I posted in the answer, I found this information as well. It is sometimes necessary to create dummy accounts that are not used by people. For example, to set up an anonymous FTP server. – Ramesh Sep 1 '14 at 22:42
@Networker, may be practical cases it might be useless. However, still it is useful in some interview questions which is where I originally got this question. serverfault.com/a/225954 – Ramesh Sep 1 '14 at 23:10
thanks for this explanation, and your answer is useful indeed, I will give it a try in the future. – Networker Sep 1 '14 at 23:15
I think the text quoted from the link is just there to make the point that setting a password may not be a good idea for dummy accounts: when creating a dummy account, it's still generally easier to use useradd (not necessarily adduser, which automatically does a bunch of stuff which probably isn't needed for dummy users). That said, it's still nice to know what's being done internally, because that can help with various administrative tasks. – cpast Sep 2 '14 at 3:16
up vote 7 down vote accepted

The possible way to add an user is more or less similar to what I had put in the question. I got this approach from here.

To create a new account manually, follow these steps:

Edit /etc/passwd with vipw and add a new line for the new account. Be careful with the syntax. Do not edit directly with an editor. vipw locks the file, so that other commands won't try to update it at the same time. You should make the password field be `*', so that it is impossible to log in.

Similarly, edit /etc/group with vigr, if you need to create a new group as well.

Create the home directory of the user with mkdir.

Copy the files from /etc/skel to the new home directory.

Fix ownerships and permissions with chown and chmod. The -R option is most useful. The correct permissions vary a little from one site to another, but usually the following commands do the right thing:

  • cd /home/newusername
  • chown -R username.group .
  • chmod -R go=u,go-w .
  • chmod go= .

Set the password with passwd.

After you set the password in the last step, the account will work. You shouldn't set it until everything else has been done, otherwise the user may inadvertently log in while you're still copying the files.

share|improve this answer
shouldn't : be used instead of . to separate username from group? – pqnet Sep 2 '14 at 1:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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