0

My system has a lot of users, I'v never created, like mysql or tomcat. These users have no home directories inside /home

Obviously, a daemon programs run under these users.

What is the term for such users?

How to create my own user of such kind? For example, I wish to create a user for deluged, but I don't want to create and remember a password for it and also don't want to allow somebody to login with this user from console.

How to accomplish?

2

You can give useradd the -r or --system flags to tell it you want such a user (a system user as you already called it). Here's an excerpt from my system's man page:

-r, --system
       Create a system account.

       System users will be created with no aging information in
       /etc/shadow, and their numeric identifiers are choosen in the
       SYS_UID_MIN-SYS_UID_MAX range, defined in /etc/login.defs, instead
       of UID_MIN-UID_MAX (and their GID counterparts for the creation of
       groups).

       Note that useradd will not create a home directory for such an
       user, regardless of the default setting in /etc/login.defs
       (CREATE_HOME). You have to specify the -m options if you want a
       home directory for a system account to be created.

Though you can make any user unable to login from the console by setting their shell to /bin/false or /sbin/nologin or something like that. You can do that with -s to useradd or you can change an existing user with chsh -s /sbin/nologin for example.

  • Will I still be able to login such user with FTP for example or other client? – Dims Sep 30 '15 at 17:55
  • @Dims if you don't set a password for the user then you likely won't be able to login as it. These types of users are mostly commonly used by having root su to that user to adopt more restricted privileges, not for any sort of "normal" activity – Eric Renouf Sep 30 '15 at 17:59
  • I did this for deluge right now and found I am unable to do su for this user, because it asks a password, which was not created... – Dims Sep 30 '15 at 18:01
  • @dims are you root when you try to su to deluge? Non-root users have to provide the target user's password to become them – Eric Renouf Sep 30 '15 at 18:05
  • 1
    @dims well you could do sudo su - deluge to execute the su with root privileges – Eric Renouf Sep 30 '15 at 18:21
1

You add the users the same way as the normal ones. Just make their shell path /sbin/nologin and you're okay.

Read up on the useradd manual for more info: $ man useradd

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.