5

I want to create an user with no login, no home and that not be shown in lightdm login screen window or User Accounts tool. Just like others users in /etc/passwd: sshd, syslog, avahi...

I've tried with this command line:

useradd -r -u 1001 -M -g 1001 media

But I still can see the user in user accounts tool:

enter image description here

Thanks in advance!!

Note: This question has been claimed to be duplicated but I don't think so. The main difference is what I want is to create a kind of user that never be shown in the lightdm login screen window neither User Accounts tool. An user that not have a properly defined $home is a different thing.

3
  • 1
    see second answer - use adduser instead of useradd and don't give a UID - let the system choose one <1000
    – Zanna
    Oct 26, 2016 at 6:54
  • 1
    I agree that this is not a duplicate. The other answers do not address this specific question Oct 28, 2016 at 6:53
  • If you have got the answer, please accept one by clicking the grey tick mark. This marks the question answered and helps the site. On the other hand if you solved the problem by some other way you can answer your own question
    – Anwar
    Nov 6, 2016 at 8:43

2 Answers 2

1

The standard way to achieve this without doing much fuss around user creation is just configuring lightdm as such.

In /etc/lightdm/users.conf add These lines

[UserList]
hidden-users=media

The user media will then be hidden from lightdm user list. That config file may already contain other users names like nobody nobody4 noaccess, in that case add your desired users name by separating with a space. So the line will become like this

hidden-users=nobody nobody4 noaccess media

You don't need to create users with uid less than 500 to achieve this.

And for the completion, You can create a user without home and making it system user with this command

sudo adduser --no-create-home --ingroup admin media

Here --no-create-home will prevent creating a home dir for the user and --ingroup admin will add the user to admin group, the default administrative group for Ubuntu. In older Ubuntu releases, that group was known as sudo or wheel.

0

Use this command:

$ sudo adduser --no-create-home --disabled-login --shell /bin/false --system --uid 1001 media
$ sudo addgroup --gid 1001 media

When running the test, using the man pages for the arguments, the -gid in the adduser command is suppose to create the group by the specified name and supplied number. However, in this functionality has apparently changed without the docs being updated. On the test, specifying the --gid fails with the error: adduser: The GID 1001 does not exist. So I dropped the --gid to create the new number when creating the user, and added a second command to create the group for the new user.

Update:

Edit a file by the UserID in the /var/lib/AccountsService/users dir to include these lines:

In this case run this command:

$ sudo nano /var/lib/AccountsService/users/media

Then ensure to include these two lines:

(If the user has logged on this the file should automatically be created. If the user hasn't logged on, then it won't exist. You can manually create it with the commandline above.)

[User]
SystemAccount=true

Now either reboot or restart the lightdm services (depending on your Ubuntu version):

(To avoid logging out you can restart Lightdm by with Ctrl+Alt+F2. Then run the command below from the console.)

$ sudo service lightdm restart

or (Ubuntu 16.04 and higher)

$ sudo systemctl restart lightdm

Note:
By default, a USERID below 500 is automatically hidden.

Some information in the update can be found in the /etc/lightdm/users.conf file.

3
  • 1
    I've followed the steps above but the user media is still being showed in the lighdm login screen window.
    – rssh22
    Oct 28, 2016 at 5:32
  • You should select a UID below 1000 to achieve that or let the system choose one (which should be below 1000 unless there's none left). Oct 28, 2016 at 8:42
  • @rssh22 Please check the update to the answer. Come changes have recently been made to how the user hiding is handled. I just tested the changes and any user can be hidden with this method. Oct 28, 2016 at 8:48

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.