Skip to content

Auto login ubuntu

If you want to bypass the login prompt (such as in a graphical interface) or enable auto-login for a user:

For Command Line (Terminal) Auto-Login:

  1. Auto-login in a non-graphical environment:

Edit the /etc/systemd/system/getty@tty1.service.d/autologin.conf file (create it if it does not exist):

bash sudo mkdir -p /etc/systemd/system/getty@tty1.service.d sudo nano /etc/systemd/system/getty@tty1.service.d/autologin.conf

Add the following content:

ini [Service] ExecStart= ExecStart=-/sbin/agetty --autologin username --noclear %I $TERM

Replace username with the actual username you want to auto-login.

  1. Auto-login in a graphical environment:

If you're using a display manager (like gdm, lightdm, or sddm), you need to configure it for auto-login:

  • For LightDM:

    Edit the LightDM configuration file:

    bash sudo nano /etc/lightdm/lightdm.conf

    Add or modify the following lines:

    ini [Seat:*] autologin-user=username autologin-user-timeout=0

    Replace username with your actual username.

  • For GDM (GNOME Display Manager):

    Use gsettings to set auto-login (ensure you have the gnome-control-center package installed):

    bash sudo gsettings set org.gnome.login-screen auto-login-user 'username' sudo gsettings set org.gnome.login-screen auto-login-enabled true

    Replace username with your actual username.

  • For SDDM (Simple Desktop Display Manager):

    Edit the SDDM configuration file:

    bash sudo nano /etc/sddm.conf

    Add or modify the following lines:

    ini [Autologin] User=username Session=your-session.desktop