I've just made myself a persistent LiveUSB, running Ubuntu 12.04, and I've immediately found a problem - It logs you in automatically as root, and I don't need this since I'm going to keep files and private stuff on it.

My Question: How can I disable automatic login on a LiveUSB?


In the live Ubuntu 12.04 there is 1 graphical and 6 console automatic logins.

To disable the graphical login, use a text editor like GEDIT sudo gedit /etc/lightdm/lightdm.conf

Change the line:




and append the following to make the login greeter show up:


This is how you can disable the 6 console logins:

There are 6 files that specify the automatic logins. They are /etc/init/tty1.conf to /etc/init/tty6.conf.

First rename these files to any unused names, for example to /etc/init/custom-tty1.conf to /etc/init/custom-tty6.conf.

Then edit each file, replacing the line beginning with "exec" as shown below. Match the tty number to the number in the file name. For example, for file /etc/init/custom-tty1.conf, replace

exec /bin/login -f ubuntu </dev/tty1 > /dev/tty1 2>&1


exec /sbin/getty -8 38400 tty1
  • If you're curious, you can find more information on the LightDM options here: wiki.ubuntu.com/LightDM. – Keith Bentrup Aug 4 '13 at 23:03
  • Also, here's a quick line to edit the tty confs: for i in {1..6}; do sudo sed -i.old "s#^exec.*#exec /sbin/getty -8 38400 tty$i#" /etc/init/tty$i.conf; done – Keith Bentrup Aug 4 '13 at 23:07
  • Hmm ... unlike other changes, these edits do not persist after rebooting. Any suggestions, BigFinger? – Keith Bentrup Aug 5 '13 at 0:52

I just discovered that an Ubuntu live USB creates a user named Ubuntu with an id of 999, and a user named root with an id of 0. The assumption that the user is root is almost correct. It appears as if the user Ubuntu is granted super user privileges.

The steps required to remove this user is as follows:

  1. Press Control+Alt+Fx where x is any number from 1-5. This will give you a terminal you can work with. It will already be logged in as Ubuntu.

  2. Type sudo passwd root. This will prompt you for a root password. Anything you enter here will become the root password. Enter the same password twice.

  3. Login as root by typing su, press Enter and then entering the password from step 2.

  4. Make the changes noted in the answer above.

Note: You won't need to enter sudo in front of the commands since you are root!

Press Alt+F7 to get back to the graphical interface.

  1. Click on the gear/cogwheel in the upper left corner of the screen, select 'system settings -> user accounts'

  2. Create at least 1 administrative user. Set automatic login to [off] (if it's not set already) You may need to click on the lock in the upper left of this window.

  3. After making changes, Reboot the system by clicking the gear and selecting shut down. Select Reboot at the next screen.

  4. When the Ubuntu user autologs into the graphic screen select the gear at the top, then select log out.

  5. Press Control+Alt+Fx again (1-5). You should be prompted to log in.

  6. Log in as root with the root password you entered at step 2.

  7. Type deluser --force ubuntu ubuntu then press Enter.

  8. Press Alt+F7 to return to the graphic interface.

  9. Shut down and restart the system and all should be well. Your administrative user name is automatically entered into the sudo users table so you can use sudo to execute system commands. Don't use the root user for normal work. It just complicates system recovery efforts.

Now, if only I could figure out how to remove the Try or Install window my usb stick would be perfect.


What do you mean "it logs you in automatically as root"? I was under the impression that the root account is disabled in all flavors of Ubuntu, which means you need to go through sudo for running commands as root.

I'd suggest the following: boot your live USB and create a new user with a password. Now reboot/log out. Hopefully this user is the only available user, and you need a password to login with this user. If not, maybe there's a guest account there as well, so you just need to disable that then. When you've come this far, you just need to encrypt your home folder, and then you're good to go. Remember to use a strong password!

edit There's also the possibility to encrypt entire partitions during the Ubuntu install. Here's a guide, it's from 8.04 but it's the minimal installation so the steps should be essentially the same.

edit2 For autologin, there's AutoLogin on the Ubuntu Wiki.

  • 2
    Nope! On the LiveCDs, you can run things like GParted from the GUI without entering any sort of password, which makes me think that either there is automatic null-sudo completion or simply auto-login as root. – WindowsEscapist Jun 23 '12 at 20:09
  • 1
    True, but it should be equally trivial to just stop Ubuntu from automatically logging in as root and only allowing one user to login, and I think the AutoLogin article should help with that. It's also important to remember that even if you disable root, having physical access to the USB stick makes the encryption the only line of defense left, so strong encryption is all that matters, root enabled or not is irrelevant really since an attacker can just enable it again via the failsafe terminal. Ofcourse, full encryption is an option here, but I'd reinstall for that. – pzkpfw Jun 23 '12 at 20:13
  • Absolutely. I don't do much as to the inner workings of the LiveCDs though, so your opinion is better than mine! Just my own two cents. (Now if someone would comment on my questions!) – WindowsEscapist Jun 23 '12 at 20:19
  • @WindowsEscapist This question is asking about how to disable automatic login. Enabling password authentication for sudo would be a separate question, which you may want to post yourself. – Eliah Kagan Jun 23 '12 at 23:31
  • AHAHAHA Sorry, we got off on another topic didn't we? -_- I think I've been posting far too many questions recently though so I think I'll pass on posting that one. – WindowsEscapist Jun 25 '12 at 15:30

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.