Ubuntu 16.04 设置 root 密码
- 1. `sudo`
- 2. parser
- References
1. sudo
sudo
(/ˈsuːduː/ or /ˈsuːdoʊ/) is a program for Unix-like computer operating systems that allows users to run programs with the security privileges of another user, by default the superuser. It originally stood for superuser do
as the older versions of sudo
were designed to run commands only as the superuser. However, the later versions added support for running commands not only as the superuser but also as other (restricted) users, and thus it is also commonly expanded as substitute user do
. Although the latter case reflects its current functionality more accurately, sudo
is still often called superuser do
since it is so often used for administrative tasks.
Ubuntu 16.04 Desktop (64-bit) 安装的时候,不像其他 Linux 发行版在安装的时候就需要设置 root 密码。因为 Ubuntu 16.04 Desktop (64-bit) 是面对普通用户,无 root 密码反而更加安全,在需要 root 用户的时候,可以再设置。
cheng@cheng-server:~$ sudo passwd
[sudo] password for cheng:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
cheng@cheng-server:~$
cheng@cheng-server:~$ su
Password:
root@cheng-server:/home/cheng#
root@cheng-server:/home/cheng# exit
exit
cheng@cheng-server:~$
strong@strong-sys:~$ sudo passwd
[sudo] strong 的密码:
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
strong@strong-sys:~$
strong@strong-sys:~$ su
密码:
root@strong-sys:/home/strong#
root@strong-sys:/home/strong# exit
exit
strong@strong-sys:~$
2. parser
终端输入 sudo passwd,然后输入当前账户密码认证。
cheng@cheng-server:~$ sudo passwd
[sudo] password for cheng:
当输入当前账户密码正确时,会提示输入新的 Unix 密码。该密码就是 root 账户密码。
当输入 2 次 Unix 密码一致时,会提示你密码更新成功。
cheng@cheng-server:~$ sudo passwd
[sudo] password for cheng:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
在终端输入 su,是 root 账户。然后要求你输入密码,这个不是账户密码,是刚才设置的 root 密码。当你输入正确的 root 密码之后,前面的用户名就换成了 root,可以通过 exit 退出 root 用户,切换回刚才的用户。
cheng@cheng-server:~$
cheng@cheng-server:~$ su
Password:
root@cheng-server:/home/cheng#
root@cheng-server:/home/cheng# exit
exit
cheng@cheng-server:~$
References
[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/