解锁raspibian系统的root帐号
正常情况下,Raspbian
系统默认并没有开启root
帐户,首先需要开启root
帐户。先使用pi
帐户登录系统(默认密码是:raspberry
),然后执行下面的命令:
localhost:~ king$ ssh pi@192.168.0.110
pi@192.168.0.110's password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Jul 28 16:04:49 2016 from 192.168.0.109
pi@raspberrypi:~ $ sudo passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
pi@raspberrypi:~ $ sudo passwd --unlock root
passwd: password expiry information changed.
pi@raspberrypi:~ $ su root
Password:
root@raspberrypi:/home/pi# vi /etc/systemd/system/getty.target.wants/getty\@tty1.service
查看系统启动相关配置文件
打开系统登录配置文件,内容如下:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service
After=rc-local.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes
# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by serial-getty@.service, not this
# unit.
ConditionPathExists=/dev/tty0
[Service]
# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/agetty --noclear %I $TERM
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes 36 TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes
# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPH ONE= LC_MEASUREMENT= LC_IDENTIFICATION=
[Install]
WantedBy=getty.target
DefaultInstance=tty1
修改系统配置文件
我们只要把第28
行从:
ExecStart=-/sbin/agetty --noclear %I $TERM
改为:
ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM
保存后,重启就可以自动以root用户登录了。
后记
在比较后的
raspbian
系统中,SysV
系统中使用/etc/inittab
文件来管理相关配置,所以在网上查的资料大部分是关于这个文件设置的,较新的系统一般使用了systemd
来管理相关配置,所以配置文件已经变以了博文中所修改的那个文件了。-_-#