Autologin without gdm,kdm,xdm etc

Other talk about Salix
Post Reply
pevsner
Posts: 81
Joined: 12. Apr 2010, 16:08

Autologin without gdm,kdm,xdm etc

Post by pevsner » 7. Aug 2011, 13:44

Does anyone know of a nice solution to autologin without gdm.

I found the below method, but it is rather old and there doesn't seem to be the line #NO_PASSWORD_CONSOLE tty1:tty2:tty3:tty4:tty5:tty6 in login.defs to edit. ( looks like pats made it super secure )

Code: Select all

Log in, Start X without a Display Manager
This is useful for people who are the only ones that use their systems, want to jump straight to the desktop when powered on, and don’t want the overhead of a display manager. First, create a text file containing the following code.

#include <unistd.h>

int main() {
  execlp( "login", "login", "-f", "YOUR_USER_NAME", 0);
}
Compile this file into a program with gcc. Note that YOUR_USER_NAME should be replaced with your regular user’s login name.

gcc -o autologin autologin.c
Now place autologin in /usr/local/sbin. Make sure it is owned by root with chown root:root /usr/local/sbin/autologin. There are three files that now need to be edited. First, open the /etc/inittab and locate the section looking like this.

# These are the standard console login getties in multiuser mode:
c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c2:1235:respawn:/sbin/agetty 38400 tty2 linux
c3:1235:respawn:/sbin/agetty 38400 tty3 linux
Change it so that it looks like this.

# These are the standard console login getties in multiuser mode:
c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c2:1235:respawn:/sbin/agetty 38400 tty2 linux
#c3:1235:respawn:/sbin/agetty 38400 tty3 linux
c3:235:respawn:/sbin/agetty -n -l /usr/local/sbin/autologin 38400 tty3 linux
Note that removing the one from the ‘c3:235’ prevents that console from activating in single user mode. Also, if you are currently using a graphical display manager (runlevel 4), switch back to console login (runlevel 3) by editing and reverting to id:3:initdefault:. Now edit /etc/login.defs and find the section looking like this.

# If defined, either full pathname of a file containing device names or
# a ":" delimited list of device names.  No password is required to log in
# as a non-root user on these devices.
#
#NO_PASSWORD_CONSOLE tty1:tty2:tty3:tty4:tty5:tty6
Change it so that it now looks like this.

# If defined, either full pathname of a file containing device names or
# a ":" delimited list of device names.  No password is required to log in
# as a non-root user on these devices.
#
#NO_PASSWORD_CONSOLE tty1:tty2:tty3:tty4:tty5:tty6
NO_PASSWORD_CONSOLE tty3
Lastly, edit the .bash_profile in the user’s home directory. You may not have one, in which case just create a new, blank one. Add this code to it.

if [ -z "$DISPLAY" ] && [ $(tty) == "/dev/tty3" ]; then
  startx
fi
You are now all set to reboot and automatically arrive in X! Console three will automatically start X, while the others remain just as they were before.
http://www.fprimex.com/linux/slackware/tips.html
Thanks in advance.

thom1
Posts: 28
Joined: 16. May 2011, 09:40

Re: Autologin without gdm,kdm,xdm etc

Post by thom1 » 7. Aug 2011, 14:11

You can put this command on your /etc/rc.d/rc.local :

Code: Select all

su --login bob -c '/bin/bash -l -c startx &> /dev/null' &
Thomas Bourdon

pevsner
Posts: 81
Joined: 12. Apr 2010, 16:08

Re: Autologin without gdm,kdm,xdm etc

Post by pevsner » 7. Aug 2011, 14:21

Thx thom1,
I just rebooted and autologged :)

Post Reply