Setup Autologin on ArchLinux

By Krolyxon2 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

  1. Open /etc/systemd/system/getty.target.wants/getty@tty1.service in your text editor of choice.
    • You will see the following contents
    ~~~~~~
    ~~~~~~
    [Service]
    # The '-o' option value tells agetty to replace 'login' arguments with '--' for
    # safety, and then the entered username.
    ExecStart=-/sbin/agetty -o '-- \\u' --noreset --noclear - ${TERM}
    Type=idle
    Restart=always
    RestartSec=0
    ~~~~~~
    ~~~~~~
    
  2. Replace the line ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear - $TERM to ExecStart=-/sbin/agetty -a <username> - $TERM
  3. Make sure to put your username instead of <username>
  4. Reboot your system.

Method 2

  1. Go to /etc/systemd/system/getty@tty1.service.d and inside that directory, create a file autologin.conf

    Note

    The directory may not exist already, so create it if it does not exist.

  2. in autoconf.conf put the following contents:
    [Service]
    ExecStart=
    ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin <username> %I $TERM
    
  3. Again, make sure to replace <username> with the actual username with which you want to autologin as.
  4. Reboot the system.