免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2838 | 回复: 1
打印 上一主题 下一主题

如何自动以root登录 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-08-17 22:14 |只看该作者 |倒序浏览
我们在plug computer( 基于arm )电脑上做一个监控系统,电脑随机提供一个Debian系统。
开机像我们pc上一样,也要用户名和密码。
请问如何开机自动以root登录?

论坛徽章:
0
2 [报告]
发表于 2012-07-07 13:56 |只看该作者
http://www.tecnojin.it/wordpress/?p=264

or:

HOWTO: Autologin as root or as any other user in Linux in console mode


Purpose: In one of my previous articles we saw how to autologin as “root” or as any other user when you are using a Graphical Environment like GNOME, KDE, LXDE, Xfce. In that we saw we can bypass the GDM, KDM and XDM login screens. However what to do if you are not using any graphical environments (No X server)? Hhow do you automatically login as “root” or as any other user when you are just booting into console mode.

Normally, when you just install a plain base system you usually boot to a login prompt on your tty1 console like this:

Welcome to Debian GNU/Linux 5.0 debian tty1
debian login:

And normally you enter your username and password to get the shell prompt:

debian:~#

Now suppose we want to bypass the step where we enter username and password. How do we do that?

Let’s get started.

Step 1: Install mingetty

The first step is to install the a program called mingetty which we will use instead of the regular “getty” which is responsible for generating the login console.

# apt-get install mingetty

Step 2: Edit inittab file

Now we will edit the inittab file:

# nano /etc/inittab




and change the line

1:2345:respawn:/sbin/getty 38400 tty1

to

1:2345:respawn:/sbin/mingetty --autologin <user-name>  --noclear tty1

You can replace <user-name> with either “root” or with your own user-name.

Example:
1:2345:respawn:/sbin/mingetty --autologin root --noclear tty1

Note: It’s a good idea to make a backup of inittab file first.

save and quite the file.

Step 3: Restart your system

# shutdown -r now

Simply restart your system and will be automatically taken to the bash shell prompt without entering the username and password.

Step 4: Make other tty autologin also (optional)

You must have notice that by default Debian Linux generate 6 tty based login console which you can switch to with “Alt-F2″, “Alt-F3″, “Alt-F4″, etc.

So far we have just made tty1 console (default) autologin enabled. What if you want to make all ttys or some ttys autologin just like tty1? It’s very simple. Edit the /etc/inittab file and to make tty2 autologin:

replace the line
2:23:respawn:/sbin/getty 38400 tty2

with

2:23:respawn:/sbin/mingetty --autologin root --noclear tty2

And similarly you can do for rrt3, tty4, and so on.

Happy Autologin.

Be Sociable, Share!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP