Feature #469

Automatically Start X and Login On Arch

Added by Daniel Curtis almost 8 years ago. Updated over 6 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
1.00 h
Spent time:


While setting up an Arch box, I needed to have the ability to automatically start X and login as a given user. This guide assumes that a base Arch installation has been setup, similar to Issue #207 and logged in as root.

Install a Desktop Environment

  • Start by installing the X Window Server and extra packages:
    pacman -S xorg xorg-server xorg-apps xorg-xinit
  • Now install a desktop environment, this guide uses LXDE:
    pacman -S lxde

Set Up Automatic Login

  • Create a new service file similar to getty.service@ by copying it to /etc/systemd/system/:
    cp /usr/lib/systemd/system/getty@.service /etc/systemd/system/autologin@.service
  • You will then have to symlink that autologin.service@ to the getty service for the tty on which you want to autologin, for example for tty1:
    ln -s /etc/systemd/system/autologin@.service /etc/systemd/system/
  • Modify the autologin.service@ to actually log you in automatically:
    vi /etc/systemd/system/\@tty1.service
    • Change the ExecStart line to read:
      ExecStart=-/sbin/agetty -a USERNAME %I 38400
    • NOTE: Change the USERNAME to the user that will automatically be logged in as.
  • Tell systemd to reload its daemon files and start the service:
    systemctl daemon-reload
    systemctl start getty@tty1.service

Set Up Automatic X Startup

  • If you then want to automatically start X, edit the users ~/.bash_profile:
    vi ~/.bash_profile
    • And insert the following snippet at the end:
      if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
       exec startx
  • Create a .xinitrc file:
    vi ~/.xinitrc
    • Then add the following to the end of the .xinitrc file:
      exec startlxde

By now you should be able to run startx and have a desktop environment. Now reboot and check to see that the desktop environment loads up correctly.



Updated by Daniel Curtis almost 8 years ago

  • Description updated (diff)
  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Updated by Daniel Curtis almost 8 years ago

  • Status changed from Resolved to Closed

Updated by Daniel Curtis over 6 years ago

  • Description updated (diff)

Updated by Daniel Curtis over 6 years ago

  • Description updated (diff)
  • Category set to Workstation
  • Target version set to Arch Linux

Also available in: Atom PDF