如何在运行 Upstart 的 Ubuntu 中设置 tty 自动登录

10 auto-login runlevel

我试图找到/etc/inittab我进行自动登录的位置。但在 Ubuntu 11.04 中,该文件似乎丢失了。这是您在 Ubuntu 中的正确做法吗?

# Auto Login for Ubuntu how?
# 1. apt-get install mingetty
# 2. vim /etc/init/tty1.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]
stop on runlevel [!2345]
respawn
#exec /sbin/getty -8 38400 tty1
exec /sbin/mingetty --autologin <PUTYOUR_USERNAME_HERE> tty1
^
|____ edited only this line, seems to be working 
Run Code Online (Sandbox Code Playgroud)

enz*_*tib 14

/etc/inittab在 Ubuntu中没有,因为 Ubuntu 使用 upstart 来定义启动服务和运行级别。而这并不是从 Ubuntu 的最后一个版本开始,而是很久以前。

无论如何,您仍然可以使用inittab,只需创建一个。我报告一段来自/usr/share/doc/upstart/README.Debian.gz

How do I change the default runlevel?
-------------------------------------

If you have an /etc/inittab file, edit it.  Locate the following line:

    id:N:initdefault:

Where N is the default runlevel, change this to match.

Most people won't have that file, you can edit /etc/init/rc-sysinit.conf
and change the following line:

    env DEFAULT_RUNLEVEL=2
Run Code Online (Sandbox Code Playgroud)

但请记住,Ubuntu 不像其他 linux 发行版/unix 操作系统那样使用标准运行级别含义。旧标准是:

  • 0 - 关机
  • 1 - 单用户模式
  • 3 - 多用户文本模式
  • 5 - 多用户图形模式
  • 6 - 重启

但 Ubuntu 使用:

  • 0 - 关机
  • 1 - 单用户模式
  • 2 - 多用户图形模式
  • 6 - 重启

最后,如果你想有一个自动登录的虚拟终端,那么修改exectty1.conf似乎是正确的方法,虽然我不知道mingetty,所以不能说你是否正确使用它。