Linux系统字符终端自动登录的一解决办法:
Linux中如何自动登录虚拟控制台
This article describes how to automatically login to a virtual console at the end of the boot process. This article only covers console logins; methods for starting an X server are described in Start X at Boot.
Using mingetty
This is the preferred (i.e. clean) method.
Install the mingetty package from the AUR. mingetty is designed to be a minimal getty and allows automatic logins. Then, in /etc/inittab change:
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
to
c1:2345:respawn:/sbin/mingetty --autologin USERNAME tty1 linux
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
The user can change every line to use mingetty if preferred, but it is not necessary.
Using a C login program
As an alternative, a C login program can be written:
File: autologin.c
#include
int main() {
execlp( "login", "login", "-f", "USERNAME", NULL);
}
Here, the C function execlp executes the command login -f USERNAME.
The program must be compiled and copied to an appropriate location:
# gcc -o autologin autologin.c
# cp autologin /usr/local/sbin/
Finally, edit etc/inittab and change:
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
to:
c1:2345:respawn:/sbin/agetty -n -l /usr/local/sbin/autologin 38400 tty1 linux
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux