5

I am trying to autologin and auto startx on my ubuntu minimal installation (15.04 Vivid Velvet 32bits, mini.iso) I am following several guides that I found but none of them work (the startx part works, but not the autologin)

For example: https://rowen121.wordpress.com/2011/09/14/enable-automatic-login-and-startx-in-ubuntu/ https://wiki.ubuntuusers.de/autologin

One of the problems is everytime I go and look for the file they tell me to edit, it's not there. When I do sudo nano whatever the file, it is empty (tty1.conf for example, or inittab) In all the guides they say to uncomment a line and add another, but all those files are empty for me. Maybe it is because they refer to Debian and things change.

I have managed to make it work installing nodm. Then I don't need to write my username nor password, and then, it auto startx (I added startx in .bash_profile), and finally takes me to i3-wm. I haven't installed a display manager (well, just nodm as the last option to try) nor desktop environment.

I would like to get it working without the need of installing a display manager (rungetty/mingetty/getty/whatever works and it's easy on resources) Please if you know the steps that work for you and ubuntu, or a guide that I can follow I would appreciate it. Thanks in advance

Note: nothing is encrypted

tom_len
  • 163

2 Answers2

7

It seems you were right Serg, Ubuntu 15.04 now uses systemd, and apparently things have changed. So I kept on searching now for systemd autologin and got it working. I found this guide that served me well: http://memo-linux.com/debian-8-systemd-autologin-sans-display-manager/

This is what I did:

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

and edited the file as follows:

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin username --noclear %I 38400 linux

Change "username" with yours.

Save and close (CTRL+O, CTRL+X)

Now:

systemctl enable getty@tty1.service

Write your password (I was asked twice)

That would be for the autologin part. Next, to start X automatically, continue with this:

sudo nano ~/.bash_profile

and edit that file so it reads:

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

Save and close (CTRL+O, CTRL+X) (Source: wiki archlinux Autostart_X_at_login)

At this point I found another possibility for that file here: https://unix.stackexchange.com/questions/42359/how-can-i-autologin-to-desktop-with-systemd

if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
 exec startx
fi

But I haven't tested it and I don't really know the difference, sorry.

In this last link they advised to do a last step "You will have to modify your ~/.xinitrc to start your desktop environment, how to do that depends on the DE" So I did:

sudo nano ~/.xinitrc

and added this line

exec i3

Save and close (CTRL+O, CTRL+X)

Last thing to do:

sudo reboot

Now it auto logins and auto starts X, and no display manager was needed. I think I read if you already have a display manager you have to remove it first. I hope this can be useful for you. Feel free to comment and improve it.

tom_len
  • 163
0

For Ubuntu Minimal 24.04.2 this worked:

Run this command:

sudo systemctl edit getty@tty1

Paste this

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

Reload systemd and restart service:

sudo systemctl daemon-reexec
sudo systemctl restart getty@tty1