Skip to content

antony@notes:~/misc$ cat "Ubuntu-Server-設定帳號自動登入.md"

Ubuntu Server 設定帳號自動登入

2022-08-07· misc ·Linux

Ubuntu Server 設定帳號自動登入

:::warning

:::spoiler 目錄

[TOC]

:::

Set auto-login

# 設定 bigboss 帳號自動登入 ( 在第 40 行 )
$ sudo nano -l /lib/systemd/system/getty@.service
ExecStart=-/sbin/agetty --autologin bigboss --keep-baud 115200,38400,9600 %I $TERM

Description :

當 getty@.service 的服務啟動時,執行 /sbin/agetty 這支程式,讓 bigboss 這位使用者自動登入,不用輸入帳號密碼。

名詞解釋 :

- what is getty ?
  getty 是“get tty”的縮寫,是在管理物理或虛擬終端 (TTY) 的主機上運行的 Unix 程序。 
  當它檢測到連接時,它會提示輸入用戶名並運行“登錄”程序來驗證用戶身份。
  
- getty@.service
  負責虛擬終端(VT) 登錄提示,即顯示在/dev/tty1和類似設備中的 VGA 屏幕上的提示。

- ExecStart
  服務啟動時執行的命令和參數。

- baud rate
  傳輸和接收數據的速度。9600 是標準速率,但在某些設備中其他速度是典型的。請記住,通信鏈中的所有環節都必須以相同的速度“說話”,否則數據會在一端或另一端被誤解。

/sbin/agetty Introduction

agetty | alternative Linux getty ( 替代 Linux getty )

描述 :
  agetty 打開一個 tty 端口,提示輸入登錄名並調用 /bin/login 命令。 它通常由 init(8) 調用。

參數 :
-/sbin/agetty
  The dash means that systemd will not treat non-zero exit codes as a failure.
  破折號表示 systemd 不會把 exit 0 之外的代碼,判定是錯誤代碼

--autologin username 
  Automatically log in the specified user without asking for a username or password.
  自動登錄指定用戶,無需輸入用戶名或密碼。
  
-s, --keep-baud
  Try to keep the existing baud rate.
  盡量保持現有的 baud rate。
  
%i
  Instance name,For instantiated units: this is the string between the "@" character and the suffix of the unit name.
  
%I
  Unescaped instance name,Same as "%i", but with escaping undone
  
What does "escaping" mean?
  轉義意味著更改特殊字符。 %i 將特殊字符 / 替換為破折號 - 和 \x20。
  
$TERM 
  conventions for naming terminal types
tags: Linux