How to create ubuntu server 16.04 autologin?
In Ubuntu 16.04, which uses systemd
, the method is slightly different. I'll quote the relevant bits of my related post How do I override or configure systemd services?:
Say I want to have TTY2 autologin to my user (this is not advisable, but just an example). TTY2 is run by the
getty@tty2
service (tty2
being an instance of the template/lib/systemd/system/getty@service
). To do this, I have to modify thegetty@tty2
service.[…]
In particular, I have to change the
ExecStart
line, which currently is:$ systemctl cat getty@tty2 | grep Exec ExecStart=-/sbin/agetty --noclear %I $TERM
To override this, do:
sudo systemctl edit getty@tty2
And add:
[Service] ExecStart= ExecStart=-/sbin/agetty -a <USERNAME> --noclear %I $TERM
[…]
Now:
$ systemctl cat getty@tty2 | grep Exec ExecStart=-/sbin/agetty --noclear %I $TERM ExecStart= ExecStart=-/sbin/agetty -a <USERNAME> --noclear %I $TERM
And if I do:
sudo systemctl restart getty@tty2
and press CtrlAltF2, presto! I'll be logged into my account on that TTY.
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
Something has changed in server 16.04 LTS, I can't find tty1, but I need to make an auto-login on tty1 (in console mode), in 14.04 LTS I can make this work.
I can't find
/etc/init/tty1.conf
How to, or a link?
-
Zac about 8 yearsThat procedure brings to me a blank tty screen.
-
muru about 8 years@Zac and what does
systemctl status getty@tty2
report for you? -
Zac about 8 yearsI was in a virtual machine with just 1 tty, and I was not able to log in anymore! (blessed snapshots!) I solved as I wrote here.
-
muru about 8 years@Zac if you says so. This works fine for me on Arch Linux and Ubuntu.
-
muru over 7 yearsThis answer won' t work for 16.04 because it uses systemd by default and not upstart. Even for upstart systems, you should use
agetty
's-a
option instead of this. -
345422 over 7 yearsThat's strange, as I was pretty sure I was running 16.04 Server. That would't change just because I was using a PPC, would it?
-
Nam G VU over 7 yearsI followed your guide and my machine can log in automatically now. BUT I cannot ssh to the machine as possible before. Please help me to get back to my SSH connection.
-
muru over 7 years@NamGVU since the guide doesn't touch SSH settings at all, the cause must be elsewhere. Does reverting the changes given here fix SSH?
-
VarunAgw almost 7 yearsIs there any way to automate this using a script?
-
muru almost 7 years@VarunAgw sure, create
/etc/systemd/system/[email protected]/override.conf
with the additional lines, and runsystemctl daemon-reload
. -
VarunAgw over 6 yearsFor some reason, tty2 doesn't auto login at reboot while tty1 does.
who -u
shows only tty1 after login -
muru over 6 years@VarunAgw even after you switch to tty2?
-
VarunAgw over 6 years@muru I can't switch using Ctrl+Alt+F2. I have develop a program which use ttyecho to launch a program in tty2 and then take regular screenshots using fbgrab
-
Tomilov Anatoliy over 6 yearsHow to revert these changes?
-
muru over 6 years@Orient delete the override file in
/etc/systemd/system/getty*.service.d
-
Tomilov Anatoliy over 6 years@muru Can I just edit
/etc/systemd/system/getty.target.wants/[email protected]
instead ofsystemctl edit getty@tty1
? -
muru over 6 years@Orient the usual method to manually do this is to create .conf files
/etc/systemd/system/[email protected]/
and runsystemctl daemon-reload
. I'm not so sure of using other directories.