解鎖raspibian系統的root帳號
正常情況下,Raspbian
系統默認並沒有開啓root
帳戶,首先需要開啓root
帳戶。先使用pi
帳戶登錄系統(默認密碼是:raspberry
),然後執行下面的命令:
localhost:~ wangzhizhou$ 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 [email protected], 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
來管理相關配置,所以配置文件已經變以了博文中所修改的那個文件了。-_-#