184

How do I disable the guest session in Ubuntu 11.10 or higher? I don't want people to be able to use my computer without using a password to log in!

2
  • 11
    Can't you really think of any use case where one would want to disable the guest account? :P In my case, I'm the only one working on my PC so it doesn't make any sense for me to have it enabled. And I can think of other scenarios as well, but would go offtopic I guess :)
    – Nejest
    Oct 21, 2012 at 17:43
  • @mikewhatever - LightDM is a desktop manager, not a security manager. It as no business doing anything security and user related. Breaking the Unix security model should be enough. But if its not, then try searching for the security related bug reports. Folks keep accidentally breaking out of the Unity/LightDM sandbox (I filed at least two myself). What do you think an attacker could do?
    – user207039
    Feb 17, 2014 at 12:51

12 Answers 12

122

Updated: 2016-Aug

For Ubuntu 16.04 LTS (15.10 or later)

Adapted from: LightDM Ubuntu Wiki - Configuration

  • System provided configuration files in /usr/share/lightdm/ are not intended to be user editable. Instead users should use: /etc/lightdm/
  • Newer versions of LightDM (Ubuntu 15.10, or later) use [Seat:*] instead of [SeatDefaults]

Just run this (once) at terminal:

sudo sh -c 'printf "[Seat:*]\nallow-guest=false\n" >/etc/lightdm/lightdm.conf.d/50-no-guest.conf'

To undo (restore Guest option), remove the file created:

sudo rm /etc/lightdm/lightdm.conf.d/50-no-guest.conf

For Ubuntu 14.04 LTS (up to 15.04)

Adapted from: Ubuntu Forums - lightdm config files location in 14.04

Just run this (once) at terminal:

sudo sh -c 'printf "[SeatDefaults]\nallow-guest=false\n" >/usr/share/lightdm/lightdm.conf.d/50-no-guest.conf'

You will no longer have 'Guest' as login option, on your next login.

To undo (restore Guest option), remove the file created:

sudo rm /usr/share/lightdm/lightdm.conf.d/50-no-guest.conf

For Ubuntu 12.04 LTS (up to 13.10)

Simplest method.

Just run this (once) at terminal:

sudo /usr/lib/lightdm/lightdm-set-defaults -l false

You will no longer have 'Guest' as login option, on your next login.

  • This simply appends allow-guest=false to /etc/lightdm/lightdm.conf.

  • Should work from 11.10 onwards (since these use LightDM as well).

To undo (restore Guest option):

sudo /usr/lib/lightdm/lightdm-set-defaults -l true
10
  • 4
    This works for me on 13.10.
    – wim
    Oct 22, 2013 at 12:17
  • 2
    Worked for me on 14.04 beta 2. BTW, SeatDefaults is not a spelling mistake, don't change it to SetDefaults. Apr 12, 2014 at 8:29
  • 1
    This worked for me on Xubuntu 14.04.1 LTS. However, I’d correct this sentence: “You will no longer have 'Guest' as login option, on your next login.” In fact, it remained until lightdm was restarted in my case.
    – Melebius
    Jun 30, 2015 at 6:53
  • 1
    Unnecessary quoting in the latest edit; please see help.ubuntu.com/stable/ubuntu-help/… Also: the /etc/lightdm/lightdm.conf.d folder is created automatically only in 16.04.1, so on previous versions it needs to be created before the command is run (sudo mkdir /etc/lightdm/lightdm.conf.d). Jul 18, 2016 at 23:22
  • 1
    Worked for 16.04, though have to restart lightdm to apply this change (note: this will also end your current session): sudo /etc/init.d/lightdm restart
    – Jeff Ward
    Mar 17, 2018 at 1:51
115

Only use this method if you are using Ubuntu Desktop. If you are using another flavour such as Xubuntu or Lubuntu please refer to this answer instead.

If you're using the default LightDM, edit /etc/lightdm/lightdm.conf so that it looks like this:

[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
allow-guest=false

If you're using GDM (which was the default in previous Ubuntu releases), uninstall gdm-guest-session.


For Ubuntu 13.10 to 14.10, the file has moved to /etc/lightdm/lightdm.conf.d/50-unity-greeter.conf

For Ubuntu 14.10 or higher, the file has moved to /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf

8
  • 8
    Answer seems to be out-of-date for 13.10
    – wim
    Oct 22, 2013 at 11:56
  • 2
    The instructions are the same for 13.10, except that the file has moved to: /etc/lightdm/lightdm.conf.d/50-unity-greeter.conf Nov 5, 2013 at 15:05
  • 3
    @Andrew: It makes more sense to create a new file, e.g. /etc/lightdm/lightdm.conf.d/50-no-guest.conf. The allow-guest option is not unity-greeter specific. Feb 2, 2014 at 2:58
  • 3
    Ubuntu 14.04: I found the .conf here: /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf . To locate the file I used locate
    – Charles
    Feb 8, 2015 at 6:16
  • 1
    Works also in vivid (15.04), with config in /usr/share, too.
    – setempler
    Feb 9, 2015 at 16:28
24

Type this in the terminal

gksu gedit /etc/lightdm/lightdm.conf

You will see the following:

[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu

Add allow-guest=false to the end so your final result should look like:

[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
allow-guest=false

Save the document and quit the text editor.

Back in the Terminal, restart the display manager. (This will end the graphical login session, immediately quitting all programs running in it, so make sure your work--like any open documents--is saved first!)

sudo restart lightdm

With the graphical login session ended, you're returned to the login screen, where you'll notice that guest acount is disabled.

That's it--the guest account is no longer usable.

0
18

You can do that using Ubuntu Tweak.

To install it, use these commands:

sudo add-apt-repository ppa:tualatrix/ppa
sudo apt-get update
sudo apt-get install ubuntu-tweak

After installing, navigate to TweaksLogin Settings and switch off the "Guest account".

ubuntu tweak login settings

2
11

Just run

gksudo gedit /etc/lightdm/lightdm.conf

Add the following line

allow-guest=false

Then (this will immediately log you out, quitting any programs running in your graphical session, so save your work first):

sudo restart lightdm
0
4

How to disable this option in the future

I just ran into the same problem on my new trusty/14.04 installation. Also to my surprise I couldn't find the lightdm.conf.d folder inside /etc/lightdm/ just users.conf.

Investigation

$ find / -iname *lightdm* 2>/dev/null | grep -v /mnt | grep -v /media | grep -v /home
[...]
/usr/share/lightdm/lightdm.conf.d
[...]

Aha, there you are. What's in there?

$ ls -1 /usr/share/lightdm/lightdm.conf.d/
50-greeter-wrapper.conf
50-guest-wrapper.conf
50-ubuntu.conf
50-unity-greeter.conf
50-xserver-command.conf

Okay, what's in there?

$ cat /usr/share/lightdm/lightdm.conf.d/*
[SeatDefaults]
greeter-wrapper=/usr/lib/lightdm/lightdm-greeter-session
[SeatDefaults]
guest-wrapper=/usr/lib/lightdm/lightdm-guest-session
[SeatDefaults]
user-session=ubuntu
[SeatDefaults]
greeter-session=unity-greeter
[SeatDefaults]
# Dump core
xserver-command=X -core

Conclusion

We find a bunch of configuration files similar to the INI format following the naming scheme of 50-${some-descriptive-name}.conf and configuring keys for the section [SeatDefaults].

We're not going to edit any of these files as these are meant to be managed by the package manager, but now we how we should add and manage our custom configuration bits to /etc.

Solution

Given the above, that lightdm is the display manager and the configuration files look like the above. The following solution should work:

  1. Create the missing directories:

    $ sudo mkdir -p /etc/lightdm/lightdm.conf.d
    
  2. Add a custom configuration file by running:

    $ sudo nano /etc/lightdm/lightdm.conf.d/50-disable-guest-session.conf
    

    and paste the following lines:

    [SeatDefaults]
    allow-guest=false
    

    Then save (Ctrl+O) and close (Ctrl+X).

  3. Now logout and switch to a virtual terminal (Ctrl+Alt+F1), then run:

    $ sudo service lightdm restart
    

    The guest session option should now be gone. If something is not working quite right you now know where the default configuration is stored and that you didn't change it.

Further reading

1
  • Or, if you do not want to create an extra file put it into the existing /etc/lightdm/lightdm.conf
    – thomas
    Sep 8, 2014 at 9:35
3

For Ubuntu 13.10, add

allow-guest=false

to the file /etc/lightdm/lightdm.conf.d/10-ubuntu.conf.

3

13.04 and later

  1. Execute this command in a terminal

     sudo /usr/lib/lightdm/lightdm-set-defaults -l false
    
  2. Reboot your machine or restart lightdm with the following command
    (This will log you out immediately, save your data)

     sudo restart lightdm
    

Apparently, it works in 13.10 (can't test myself, but there's a comment here).

I'm using 13.04 and all this does it append allow-guest=false to /etc/lightdm/lightdm.conf, but it might be different in 13.10.

Originally by david6 from here: https://askubuntu.com/a/169105/176889

2
  • 1
    Thanks. It created a lightdm.conf file, the same as with you, with allow-guest=false in it.
    – 11chubby11
    Oct 21, 2013 at 7:56
  • You should also do sudo restart lightdm for the changes to take effect. Without that, the guest session will still be listed on the login screen when you log out.
    – Burhan Ali
    Oct 25, 2013 at 13:34
2

Install ubuntu-tweak, get to the tweak tab, turn off the guest button and reboot. That's it!

One may find the terminal easier, but in case the need to turn on the guest account arises then one would have to visit this page again and see the instructions (or rather undo). That's the advantage of the GUI thing... one remembers it easily.

2

Change allow-guest=true to 'false' in /etc/lightdm/lightdm.conf

You can then either reboot or restart the service in the terminal:

sudo restart lightdm

Assuming you are using lightdm which is standard in 11.10.

0

I'm in the same case, the file /etc/lightdm/lightdm.conf doesn't exist in UBUNTU 13.10.

I try to create the /etc/lightdm/lightdm.conf file with this line allow-guest=false, and CRASH, the system does not start properly, only console mode...

I try to edit the file /etc/lightdm/lightdm.conf.d/10-ubuntu.conf, and works properly.

Edit the file

sudo vim /etc/lightdm/lightdm.conf.d/10-ubuntu.conf

And enter the lines that you need

# to disable guest login
allow-guest=false
# to enable user login manually
greeter-show-manual-login=true

And the last one, restart your system

sudo reboot

I think that this works fine if you restart only the ligthgdm

sudo service lightdm restart
0

Open Terminal

gksudo gedit /etc/lightdm/lightdm.conf

Add the following line

allow-guest=false

Save and exit the file.

2
  • 1
    Also there was no gksudo (or gksu) in my Ubuntu 13.10.
    – 11chubby11
    Oct 21, 2013 at 8:04
  • Works fine in Ubuntu 14
    – thomas
    Sep 8, 2014 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .