HOWTO: Autologin as root or as any other user in Linux in console mode
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
debian login:
And normally you enter your username and password to get the shell prompt:
debian:~#
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
to
1:2345:respawn:/sbin/mingetty --autologin <user-name> --noclear tty1
You can replace <user-name> with either “root” or with your own user-name.
Example:
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
with
2:23:respawn:/sbin/mingetty --autologin root --noclear tty2
And similarly you can do for rrt3, tty4, and so on.
Happy Autologin.


Email Subscription









April 30th, 2009 at 8:09 pm
[...] If you are looking how to autologin as “root” or as any other user in console mode only i.e. when you don’t have “X”/Graphical environment installed, you can learn it here. [...]
July 30th, 2009 at 1:31 pm
Just tried this. Works like a dream!
Reply to this comment
August 12th, 2009 at 5:42 pm
[...] Pouco se comenta, mas também é possível configurar o login automático no modo texto. Acompanhe, abaixo, um pequeno tutorial baseado em um artigo publicado pelo site KoolWall. [...]
October 12th, 2009 at 4:22 am
Hi,
I am working on embedded platform.
I have TI’s OMAP processor board and using angstrom 2.6.28-omap1 Linux distribution.
At the end of booting Linux distro, I need to type “root” from the Teraterm ( serial connection ) to enter into root mode on the board. Then it goes to root like
“root@Board:” is displayed. Now I can load my application and execute the program.
But I would like to remove this dependency of giving input from the user.
Could you please tell me how should I remove this dependency ?
Someone suggested to look at /etc/inittab and change
id:5:initdefault: to id:1:initdefault:
But it is not worked out.
I also tried to change the line
1:2345:respawn:/sbin/getty 38400 tty1
to
1:2345:respawn:/sbin/mingetty –autologin root –noclear tty1
But it is also not worked out… still asking for login.
Below is inittab file
============================================================
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
# The default runlevel.
id:5:initdefault:
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS
# What to do in single-user mode.
~~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
#z6:6:respawn:/sbin/sulogin
S:2345:respawn:/sbin/getty 115200 ttyS2
# /sbin/getty invocations for the runlevels.
#
# The “id” field MUST be the same as the last
# characters of the device (after “tty”).
#
# Format:
# :::
#
1:2345:respawn:/sbin/getty 38400 tty1
==========================================================
Do I need to modify any other files other than this?
Your help is appreciated.
TIA
Reply to this comment
October 14th, 2009 at 6:20 am
After changing below modifications to above file it worked for my distro and board..
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
S:2345:respawn:/sbin/mingetty –noclear –autologin root ttyS2
at the end line commented ….
#1:2345:respawn:/sbin/getty 38400 tty1
Reply to this comment
November 10th, 2009 at 2:48 pm
hello hari
by the look of it it looks like you are working with the beagleboard here? could you tell me please how you got mingetty onto the board? im interested i doing the same auto login as root thing. thanks
jimmy
Reply to this comment
November 24th, 2009 at 9:57 am
Don’t reboot, just type “init q”
Reply to this comment
April 7th, 2010 at 1:30 am
Thanks for this quick solution!
Although I had to remove ‘–noclear’, otherwise it sort of hangs during boot, until I press ALT-F1 myself to get into the logged in shell.
Reply to this comment
August 31st, 2010 at 9:38 am
Nice article.
Note that the line :
2:23:respawn:/sbin/mingetty –autologin root –noclear tty2
should be :
2:23:respawn:/sbin/mingetty –noclear –autologin root tty2
with –noclear before –autologin or console will hang or put message like “init: Id “x” respawning too fast: disabled for 5 minutes.”
Reply to this comment
January 31st, 2013 at 1:37 pm
gracias me funciono perfecto en raspbian
Reply to this comment
January 31st, 2013 at 1:39 pm
[...] http://linux.koolsolutions.com/2009/04/30/autologin-linux-console-mode/ [...]