Setup Autologin on ArchLinux
By Krolyxon • 2 minutes read •
Table of Contents
Autologin
Why avoid using autologin?
Well, its no secret that making your Operating System login automatically when you boot up your computer is a huge security risk. Anyone can just boot up your system, especially if you are using laptop or notebook and then have direct access to your shell without having to log in.
So in normal circumstances you should avoid setting up autologin on your system.
In which circumstances it becomes useful?
In case, you have encrypted your boot drive using LUKS, you may find it that you have to enter your password twice. One to decrypt and mount your partitions and then one again to login into your system. If you think about it, having to enter the login password won’t make any difference to your security, since the hard disk is encrypted anyways.
So it would be convenient for the user to just setup autologin, so whenever you enter the decryption password, once it is decrypted it will automatically login to your system and start the TTY.
Lets get started!
There are two ways to setup autologin in arch linux, using any one of them will give you the same results, so lets start.
Method 1
- Open
/etc/systemd/system/getty.target.wants/getty@tty1.service
in your text editor of choice.- You will see the following contents
# The '-o' option value tells agetty to replace 'login' arguments with '--' for # safety, and then the entered username. ExecStart=-/sbin/agetty Type=idle Restart=always RestartSec=0
- Replace the line
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear - $TERM
toExecStart=-/sbin/agetty -a <username> - $TERM
- Make sure to put your username instead of
<username>
- Reboot your system.
Method 2
- Now this is my preferred method, since it is less clunky and gives a much safer feeling. So follow the steps given below.
- Go to
/etc/systemd/system/getty@tty1.service.d
and inside that directory, create a fileautologin.conf
Note
The directory may not exist already, so create it if it does not exist.
- in
autoconf.conf
put the following contents:ExecStart= ExecStart=-/sbin/agetty
- Again, make sure to replace
<username>
with the actual username with which you want to autologin as. - Reboot the system.