歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 讓Ubuntu在字符界面下實現自動登錄

讓Ubuntu在字符界面下實現自動登錄

日期:2017/2/28 16:00:56   编辑:Linux教程

最近正在研究學生機房虛擬化的解決方案,選用的是Ubuntu 10.10 Mini版本的操作系統,一切都是從頭開始安裝的,所以比較清楚自己安裝了些什麼。GUI我只是安裝了一個簡陋的Wmaker。只是,有一個問題產生了, 啟動的時候總是到字符界面等待用戶輸入用戶名和密碼。這個問題讓我郁悶了很久!不過,在今天終於解決了,是通過下面這個文檔成功的解決了。不用輸入用戶名密碼,直接登錄到指定用戶的圖形界面。是不是很酷呢!如果你感興趣的話,可以看看下面的內容,之所以沒有翻譯,是因為本人認為E文是不可避免的。呵呵!

Ubuntu makes it easy to enable automatic login if you’re using a login manager such as GDM. I was recently setting up a minimal Ubuntu 9.10 system with an LXDE desktop and no GDM. Here’s how I enabled automatic login.

Note: This was tested on Ubuntu 9.10. Previous versions of Ubuntu require different procedures because of changes to the way Ubuntu boots.

Open /etc/init/tty1.conf as root:

sudo nano /etc/init/tty1.conf

Change the last line of this file to (where USERNAME is the username of the user you want to log in):

exec /bin/login -f USERNAME < /dev/tty1 > /dev/tty1 2>&1

Reboot, and the user you chose should be logged in automatically after boot. If something goes wrong, you can switch to a different TTY with CTRL+ALT+F2 and log in normally.

If you want this user to be logged into a graphical environment instead of just a shell, there’s more work to be done. Open your user’s .bashrc file:

nano ~/.bashrc

Add the following to the end of the file:

if [ $(tty) == "/dev/tty1" ]; then
startx
fi

This code will start X (the graphical environment) whenever the user logs in on TTY1. You can add more code after startx that will be executed if the user logs out of X.

Copyright © Linux教程網 All Rights Reserved