每次都使用 tty 而不登录

每次都使用 tty 而不登录

在基于 Ubuntu 的系统中,从桌面环境中,可以从终端仿真器打开多个选项卡,而无需每次都登录:用户已经登录了每个选项卡(通常每个选项卡对应一个/dev/pts/x设备)。

通过按 Ctrl+Alt+F1 ... F6 可以访问tty全文本全屏终端。但与图形终端仿真器选项卡不同,每次执行新操作时都需要重新登录tty

有没有办法避免这种情况?当我从图形环境(我登录的地方!)访问那些文本终端时,我希望按下 Ctrl+Alt+F1 ... F6 时已经登录。

答案1

Ubuntu 默认使用agetty来管理 TTY。它的手册页定义了-a, --autologin username自动登录指定用户名的选项。因此,可以执行以下操作:

  1. 在您最喜欢的文本编辑器中打开具有 root 权限的/etc/init/tty1.conf文件。我正在这样做,sudo vim /etc/init/tty1.conf但您可以使用pkexec gedit /etc/init/tty1.conf

  2. 将默认行更改exec /sbin/getty -8 38400 tty2exec /sbin/getty --autologin myUserName -8 38400 tty2

  3. 保存并退出。根据需要对其他 tty 文件重复上述操作

请注意,对于单用户系统来说,这是合适的,但当您有多个用户时不建议这样做(出于明显的隐私原因)

答案2

请参阅man screen其中部分内容:

DESCRIPTION
       Screen  is  a  full-screen  window  manager that multiplexes a physical
       terminal between  several  processes  (typically  interactive  shells).
       Each  virtual  terminal  provides the functions of a DEC VT100 terminal
       and, in addition, several control functions from the ISO 6429 (ECMA 48,
       ANSI X3.64) and ISO 2022 standards (e.g. insert/delete line and support
       for multiple character sets).  There is a scrollback history buffer for
       each virtual terminal and a copy-and-paste mechanism that allows moving
       text regions between windows.

CTRLAltFn我经常在屏幕上使用它

相关内容