2021年8月27日 星期五

Linux 不透過 Display manager 完成自動登入及執行 startx 進入 xwindow 圖形界面

某台電腦需要自動登入及進入 xwindow 才能啟動要用的功能,

找到下方這篇文章可以透過 systemd 的本機自動登入功能,

再加上登入後自動執行 startx 完成自動進入 xwindow 圖形界面環境。

Autologin and startx without a display manager.

https://forums.bunsenlabs.org/viewtopic.php?id=5544

先建立資料夾

#mkdir /etc/systemd/system/getty@tty1.service.d


建立自動登入設定檔案

#vim /etc/systemd/system/getty@tty1.service.d/override.conf

檔案內容:

[Service]

ExecStart=

ExecStart=-/sbin/agetty --autologin yourusername --noclear %I 38400 linux

其中 yourusername 換成要登入的使用者名稱

然後再到該使用者的家目錄下建立自動執行 startx 檔案


#vim /home/yourusername/.profile

檔案內容

#Startx Automatically
if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
. startx
logout
fi

這樣就算從 xwindow 登出,還是會再自動進入 xwindow

沒有留言:

張貼留言