Ubuntu root用户自动登录系统

Ubuntu为了系统安全,root帐号的密码是随机的,如果临时需要提升至root权限以执行一些命令,

需要使用sudo命令。产线上有几台使用Ubuntu的机器,因为使用者不固定,并且执行程序时需要使

用到root权限,所以需要将这几台机器配置为自动登录到root账户。查阅了相关资料后,可以通过

以下两步来实现这个目的:

1. 为root账户修改一个密码;

    在终端下输入”sudo passwd root”命令,终端会提示输入当前账户密码,正确输入后,再输

入两次你想要为root账户赋予的密码即可。

2. 设置root账户自动登录;

 (a) 查看/etc/gdm/目录下是否存在custom.conf文件,如果存在,则直接跳到下一步,如果不存在

,则依次打开”SystemàAdministrationàLogin Screen”,点击“Unlock”后,修改Login Screen

Settings的某一项设置,比如Enable或者Disable一下“Log in as automatically”,然后关闭该

窗口,再查看一下/etc/gdm/目录下,custom.conf文件应该就会存在了。

s

(b) 编辑/etc/gdm/custom.conf文件,修改其中的AutomaticLoginEnable,AutomaticLogin,

TimedLogin三项,具体如下所示:

[daemon] AutomaticLoginEnable=true 这个修改为true AutomaticLogin=root             这个修改为root TimedLoginEnable=false TimedLogin=root                    这个修改为root TimedLoginDelay=10 DefaultSession=gnome