标题Ubuntu 开机自动登录(命令行模式)
GUI的自动登录,直接在Setting>User accounts里面enable就行了,本文介绍的是如何自动登录命令行模式
方法实现
- 进入vim /etc/init/ 下找到你需要的tty
fire@fire-test:/dev/pts$ vim /etc/init/tty
tty1.conf tty2.conf tty3.conf tty4.conf tty5.conf tty6.conf
- 修改ttyX.conf中的文件
tty1 - getty
#
# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.
start on stopped rc RUNLEVEL=[2345] and (
not-container or
container CONTAINER=lxc or
container CONTAINER=lxc-libvirt)
stop on runlevel [!2345]
respawn
exec /sbin/getty -8 38400 tty1
- 修改其中的exec /sbin/getty -8 38400 tty1,改为自动登录exec /sbin/getty --autologin username tty1
exec /sbin/getty --autologin username tty1
过程中需要用到的一些命令
如何查看自己的ttyX?
可以使用who命令,查看,如:
fire@fire-test:/dev/pts$ who
fire tty7 2019-06-10 09:23 (:0)
如何确认getty的命令
可以使用getty --help或者man getty
fire@fire-test:/dev/pts$ getty -h
Usage:
getty [options] <line> [<baud_rate>,...] [<termtype>]
getty [options] <baud_rate>,... <line> [<termtype>]
Open a terminal and set its mode.
Options:
-8, --8bits assume 8-bit tty
-a, --autologin <user> login the specified user automaticall