更新

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 pon 命令创建sudo用户

root@6805b104cdc1:/vagrant# adduser pon
Adding user `pon' ...
Adding new group `pon' (1000) ...
Adding new user `pon' (1000) with group `pon' ...
Creating home directory `/home/pon' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for pon
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 pon

root@6805b104cdc1:/vagrant# usermod -aG sudo pon

输入 su - username 命令切换到新创建的用户:

执行命令后输入如下:

root@a6ef0c93187f:/vagrant# su - pon
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

pon@a6ef0c93187f:~$ 

使用 sudo 命令运行 whoami 命令,可以看到如下的输出,root 代表当前用户有特权

pon@a6ef0c93187f:~$ sudo whoami
[sudo] password for pon: 
root

universe_king
3.4k 声望678 粉丝