Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is a quick one that I cant figure out. Does usermod actually create a new user if the user specified doesn't already exist?

Here is an example: usermod -s /bin/false $1

If user "tom" doesn't exist already, will he be created, or would I need a command like "adduser" first?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Short answer:

# usermod -s /bin/false xyz
usermod: user 'xyz' does not exist

man usermod tells you that this is to modify user accounts, hence you'll need an existing one.

NAME
       usermod - modify a user account

If you like to create a user with some specific shell in one shot use -s switch with useradd:

# useradd -s /bin/false _username_
share|improve this answer
    
Thank you for the reply. Is there a way to combine adding a new user and setting them to shell bin/false in a single command? –  James Willson Sep 30 '12 at 21:11
    
@JamesWillson: Try man useradd, note how similar it is to man usermod. :) –  Tom Wijsman Sep 30 '12 at 21:12
    
Should I be doing this? "useradd -s /bin/false tom" –  James Willson Sep 30 '12 at 21:13
    
@JamesWillson: That should work. –  Tom Wijsman Sep 30 '12 at 21:13
    
Superb, thank you. I have to wait 8 mins to accept the answer. –  James Willson Sep 30 '12 at 21:13
show 1 more comment

Your Answer

 
discard

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.