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

让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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值