你好,游客 登录 注册 搜索
背景:
阅读新闻

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

[日期:2011-12-22] 来源:Linux社区  作者:tiancong [字体:大 中 小]

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

linux
相关资讯       Ubuntu基础知识 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款