How can I get autologin at startup working on Ubuntu Server 16.04.1?
Matthew Harrington
I have a problem with autologin at startup in Ubuntu Server 16.04.1 LTS.
I use this server only for listening internet radio so I do not care about security.
I was able to create a bash script to auto start mplayer but can't configure autologin.
I've tried at least 4 solutions (always editing the file /etc/init/tty1.conf and of course replacing USERNAME with actual user name):
change the line from
exec /sbin/getty -8 38400 tty1to
exec /sbin/getty -8 38400 tty1 -a USERNAMEchange the line from
exec /sbin/getty -8 38400 tty1to
exec /bin/login -f USERNAME < /dev/tty1 > /dev/tty1 2>&1Install
rungetty, comment the lineexec /sbin/getty -8 38400 tty1and add the line
exec /sbin/rungetty --autologin USERNAME tty1Install
mingetty, comment the lineexec /sbin/getty -8 38400 tty1and add the line
exec /sbin/mingetty --autologin USERNAME tty1
Nothing helps - I have to input my login and password at startup - any ideas what to do?
2 Answers
Try this:
sudo systemctl edit This will the create a drop-in file (if neccessary) and open it an editor. Add the following, replacing myusername with your user name:
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin myusername %I $TERM
Type=idleThis will:
- Create the folder
/etc/systemd/system/.dif necessary - Create the file
/etc/systemd/system/.d/override.confif necessary
agetty opens a tty port, prompts for a login name and invokes the /bin/login command.
This file overrides the config by default of agetty on systemd for tty1. This provides a new instance of tty1 with autologin for the user specified.
By the way, the parameter --noissue is used to hide the contents of /etc/issue on login, so not needed in your case.
The option Type=idle found in the default getty@.service will delay the service startup until all jobs are completed in order to avoid polluting the login prompt with boot-up messages. When starting X automatically, it may be useful to start immediately by adding Type=simple into the file.
More info: getty: Archlinux.org
1