Ubuntu – Set or determine the UID range for guest accounts

adduserguest-sessionuiduser-managementusers

For a special purpose it seems like I need to know the UID (user ID) of my guest accounts.

As guest accounts are created and (usually) removed automatically whenever one is needed, the UIDs are not fixed but assigned dynamically. If I observed it correctly, they take the first free UID that is greater than 100, but I am not sure.

However, I need to know for sure that all guest accounts and only guest accounts, no other users, are in a specific UID range, for example in range 800-899 which should be free and is still invisible because it's lower than 1000.

How can I set my Ubuntu 15.10 machine (with Unity DE) up so that it assigns all future guest accounts UIDs in that specific range and that no other users may get into it?

You're free to suggest other different solutions that help me solving my linked problem as well.

Best Answer

  • There is a configuration entry in your LightDM configuration (more about the configuration of lightdm, see below):

    guest-account-script=
    

    Per default, the script /usr/sbin/guest-account is used. In this script you can find the line

    adduser --system --no-create-home --home / --gecos $(gettext "Guest") --group --shell /bin/bash $USER
    

    which means, the guest account is added as a system user. To change the behavior you have to change the line and to replace the ID with another value, but not greater than 499.

    adduser --system --uid ID --no-create-home --home / --gecos $(gettext "Guest") --group --shell /bin/bash $USER

    Or you could write your own script ;)


    More about the configuration files here.

    System provided configuration is stored in /usr/share/lightdm/lightdm.conf.d/*.conf and is not user editable. System administrators can override this configuration in /etc/lightdm/lightdm.conf.d/*.conf and /etc/lightdm/lightdm.conf. Files are read in the above order and combined together to make the LightDM configuration.

    For example, if you want to override the system configured default session (provided in /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf) you should make a file /etc/lightdm/lightdm.conf.d/50-myconfig.conf