How can I disable automatic login on a LiveUSB?
Solution 1
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:
autologin-user=ubuntu
to
autologin-user=
and append the following to make the login greeter show up:
greeter-show-manual-login=true
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
with
exec /sbin/getty -8 38400 tty1
Solution 2
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:
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.
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.Login as root by typing
su
, press Enter and then entering the password from step 2.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.
Click on the gear/cogwheel in the upper left corner of the screen, select 'system settings -> user accounts'
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.
After making changes, Reboot the system by clicking the gear and selecting shut down. Select Reboot at the next screen.
When the Ubuntu user autologs into the graphic screen select the gear at the top, then select log out.
Press Control+Alt+Fx again (1-5). You should be prompted to log in.
Log in as root with the root password you entered at step 2.
Type
deluser --force ubuntu ubuntu
then press Enter.Press Alt+F7 to return to the graphic interface.
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.
Nick
Some say that graphic designers and illustrators have no place on sites, such as StackOverflow. Frankly, they are right!
Updated on September 18, 2022Comments
-
Nick over 1 year
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?
-
WindowsEscapist almost 12 yearsNope! 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.
-
pzkpfw almost 12 yearsTrue, 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.
-
WindowsEscapist almost 12 yearsAbsolutely. 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!)
-
Eliah Kagan almost 12 years@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. -
WindowsEscapist almost 12 yearsAHAHAHA 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.
-
Keith Bentrup almost 11 yearsIf you're curious, you can find more information on the LightDM options here: wiki.ubuntu.com/LightDM.
-
Keith Bentrup almost 11 yearsAlso, 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 almost 11 yearsHmm ... unlike other changes, these edits do not persist after rebooting. Any suggestions, BigFinger?
-
Meninx - メネンックス about 8 yearsRemove Try/Install askubuntu.com/questions/47522/…