How to make auto login work in Ubuntu? (no display manager)
It seems you were right Serg, Ubuntu 15.04 now uses systemd, and apparently things have changed. So I kept on searching now for systemd autologin and got it working. I found this guide that served me well: http://memo-linux.com/debian-8-systemd-autologin-sans-display-manager/
This is what I did:
sudo mkdir -pv /etc/systemd/system/[email protected]/
sudo nano /etc/systemd/system/[email protected]/autologin.conf
and edited the file as follows:
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin username --noclear %I 38400 linux
Change "username" with yours.
Save and close (CTRL+O, CTRL+X)
Now:
systemctl enable [email protected]
Write your password (I was asked twice)
That would be for the autologin part. Next, to start X automatically, continue with this:
sudo nano ~/.bash_profile
and edit that file so it reads:
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx
Save and close (CTRL+O, CTRL+X) (Source: wiki archlinux Autostart_X_at_login)
At this point I found another possibility for that file here: https://unix.stackexchange.com/questions/42359/how-can-i-autologin-to-desktop-with-systemd
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
exec startx
fi
But I haven't tested it and I don't really know the difference, sorry.
In this last link they advised to do a last step "You will have to modify your ~/.xinitrc to start your desktop environment, how to do that depends on the DE" So I did:
sudo nano ~/.xinitrc
and added this line
exec i3
Save and close (CTRL+O, CTRL+X)
Last thing to do:
sudo reboot
Now it auto logins and auto starts X, and no display manager was needed. I think I read if you already have a display manager you have to remove it first. I hope this can be useful for you. Feel free to comment and improve it.
Related videos on Youtube
Comments
-
tom_len almost 2 years
I am trying to autologin and auto startx on my ubuntu minimal installation (15.04 Vivid Velvet 32bits, mini.iso) I am following several guides that I found but none of them work (the startx part works, but not the autologin)
For example: https://rowen121.wordpress.com/2011/09/14/enable-automatic-login-and-startx-in-ubuntu/ https://wiki.ubuntuusers.de/autologin
One of the problems is everytime I go and look for the file they tell me to edit, it's not there. When I do sudo nano whatever the file, it is empty (tty1.conf for example, or inittab) In all the guides they say to uncomment a line and add another, but all those files are empty for me. Maybe it is because they refer to Debian and things change.
I have managed to make it work installing nodm. Then I don't need to write my username nor password, and then, it auto startx (I added startx in .bash_profile), and finally takes me to i3-wm. I haven't installed a display manager (well, just nodm as the last option to try) nor desktop environment.
I would like to get it working without the need of installing a display manager (rungetty/mingetty/getty/whatever works and it's easy on resources) Please if you know the steps that work for you and ubuntu, or a guide that I can follow I would appreciate it. Thanks in advance
Note: nothing is encrypted
-
Sergiy Kolodyazhnyy over 8 yearsSo you're saying
/etc/init/tty1.conf
is empty for you ? that's weird . . . It's not a difference between Debian or Ubuntu. By default there always should be init files. And autologin is simple just alter the lineexec /sbin/getty -8 38400 tty1
toexec /sbin/getty -a username -8 38400 tty1
-
tom_len over 8 yearsBy minimal installation, I should have specified that I am in fact using ubuntu mini.iso (MinimalCD). Yes, I am sure tty.conf was empty, and inittab empty too.
-
tom_len over 8 yearsSerg: I tried what you suggest but it doesn't work, I find myself in tty1 but I have to write my username and password. I re-tried the german wiki, but nothing. I have to write name and password
-
Sergiy Kolodyazhnyy over 8 yearsOk. So another possibility is that Ubuntu uses different system to start processes as of 15.04 . Init files belong to Upstart system but 15.04 uses systemd. Try this wiki.archlinux.org/index.php/Automatic_login_to_virtual_console
-
tom_len over 8 yearsOk, tried that but now it takes me to a black screen with blinking cursor, and I can't do anything.
-
tom_len over 8 yearsThis is what I did: sudo systemctl edit getty@tty1, then I added those three lines (changing username of course), and then CTRL+O (it said File Name to write: /etc/systemd/system/[email protected]/.#override.confac3305a12536440b) I pressed on ENTER, and then CTRL+X. Then sudo reboot, and that's what happened.
-
-
Jossef Harush Kadouri over 5 yearswhy is there
ExecStart
twice? I've tested it with only oneExecStart
and it did not work. I'm curious -
tom_len over 5 yearsTo tell you the truth, no idea. My answer was a compilation of the info I gathered when I was having this problem. I described what I tried and worked for me at the time. Maybe you can contact the creator of this blog here: link