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.

rssh22
  • 191
  • 1
  • 2
  • 5

2 Answers2

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.

Anwar
  • 77,855
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.

iND
  • 113
L. D. James
  • 25,444