Purpose: In one of my previous articles we saw how to autologin as “root” or as any other user when you are using a Graphical Environment like GNOME, KDE, LXDE, Xfce. In that we saw we can bypass the GDM, KDM and XDM login screens. However what to do if you are not using any graphical environments (No X server)? Hhow do you automatically login as “root” or as any other user when you are just booting into console mode.
Normally, when you just install a plain base system you usually boot to a login prompt on your tty1 console like this:
Welcome to Debian GNU/Linux 5.0 debian tty1
And normally you enter your username and password to get the shell prompt:
Now suppose we want to bypass the step where we enter username and password. How do we do that?
Let’s get started.
Step 1: Install mingetty
The first step is to install the a program called mingetty which we will use instead of the regular “getty” which is responsible for generating the login console.
# apt-get install mingetty
Step 2: Edit inittab file
Now we will edit the inittab file:
# nano /etc/inittab
and change the line
1:2345:respawn:/sbin/getty 38400 tty1
1:2345:respawn:/sbin/mingetty --autologin <user-name> --noclear tty1
You can replace <user-name> with either “root” or with your own user-name.
1:2345:respawn:/sbin/mingetty --autologin root --noclear tty1
Note: It’s a good idea to make a backup of inittab file first.
save and quite the file.
Step 3: Restart your system
# shutdown -r now
Simply restart your system and will be automatically taken to the bash shell prompt without entering the username and password.
Step 4: Make other tty autologin also (optional)
You must have notice that by default Debian Linux generate 6 tty based login console which you can switch to with “Alt-F2”, “Alt-F3”, “Alt-F4”, etc.
So far we have just made tty1 console (default) autologin enabled. What if you want to make all ttys or some ttys autologin just like tty1? It’s very simple. Edit the /etc/inittab file and to make tty2 autologin:
replace the line
2:23:respawn:/sbin/getty 38400 tty2
2:23:respawn:/sbin/mingetty --autologin root --noclear tty2
And similarly you can do for rrt3, tty4, and so on.