让Ubuntu在字符界面下实现自动登录

最近正在研究学生机房虚拟化的解决方案,选用的是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.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/22962.html