更新
apt update
建立普通使用者
安裝必要的元件
apt install python3 python3-pip wget dos2unix sudo lsb-release iproute2
輸入 passwd root
命令修改root使用者的密碼
root@6805b104cdc1:/# passwd root
Enter new UNIX password:
Retype new UNIX password:
輸入 adduser jiuzhang
命令建立sudo使用者
root@6805b104cdc1:/vagrant# adduser jiuzhang
Adding user `jiuzhang' ...
Adding new group `jiuzhang' (1000) ...
Adding new user `jiuzhang' (1000) with group `jiuzhang' ...
Creating home directory `/home/jiuzhang' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for jiuzhang
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
並給剛剛建立的使用者新增 sudo 許可權 usermod -aG sudo jiuzhang
root@6805b104cdc1:/vagrant# usermod -aG sudo jiuzhang
輸入 su - username
命令切換到新建立的使用者:
執行命令後輸入如下:
root@a6ef0c93187f:/vagrant# su - jiuzhang
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
jiuzhang@a6ef0c93187f:~$
使用 sudo 命令執行 whoami 命令,可以看到如下的輸出,root 代表當前使用者有特權
jiuzhang@a6ef0c93187f:~$ sudo whoami
[sudo] password for jiuzhang:
root