Home » Questions » Computers [ Ask a new question ]

How can I create a non-login user?

How can I create a non-login user?

I'd like to create a user and a group both called subversion on a RHEL 5 system. I looked at the man page for useradd and I guess the command would be just be...

Asked by: Guest | Views: 307
Total answers/comments: 5
Guest [Entry]

"You can use the -M switch (make sure it's a capital) to ensure no home directory will be created:

useradd -M subversion

then lock the account to prevent logging in:

usermod -L subversion"
Guest [Entry]

"Another solution to create a system user, using adduser :

adduser --system --no-create-home --group yourusername

You can remove --group if you don't need group yourusername, and --no-create-home if you do need a home for this user.

As mentionned by py4on in comments, on some systems one may need to use the --disabled-login option in order to, well, disable login for this user. It seems to be the default behaviour under Debian, though.

Beware that the numeric ID of the user will be of a system account. You can fix the uid using the --uid option, though.

Finally, note that on some systems (e.g. Fedora) adduser is a symlink to useradd, in which case this answer is not valid."
Guest [Entry]

"In Debian, you could create a system user (without home directory) and login shell:

useradd --system --shell=/usr/sbin/nologin <username>

If your nologin program is in /sbin/nologin, please change accordingly."
Guest [Entry]

"On a CentOS 7 machine you can use the following commands:

If the user does not exist:

useradd testuser --shell=/sbin/nologin

if you want to modify an existing user:

usermod testuser --shell=/sbin/nologin"
Guest [Entry]

"Start by generating an encrypted password for the user with a maximum of 8 characters long by doing:

openssl passwd -crypt new_password_less_than_eight_chars_long

Then you do:

useradd -m -g groupname -G otherGroupsSeperatedByComma -p encryptedPassword username"