将用户添加到sudo组

usermod -aG sudo [username] 

验证sudo权限

sudo -l -U [username]
https://jumpcloud.com/blog/how-to-create-sudo-users-debian

1. Install sudo. Some installations do not come with sudo installed. If your does not, install sudo with apt.

# apt install sudo

2. Create a new user account with the adduser command. Use a strong password for the new user. You can enter values for the user information, or press ENTER to leave those fields blank.

# adduser example_user
Adding user `example_user' ...
Adding new group `example_user' (1001) ...
Adding new user `example_user' (1001) with group `example_user' ...
Creating home directory `/home/example_user' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for example_user
Enter the new value, or press ENTER for the default
        Full Name []: Example User
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y

3. Add the new user to the sudo group.

# adduser example_user sudo

4. Test by switching to the new user.

# su - example_user

Verify you are the new user with whoami, then test sudo access with sudo whoami, which should return root.

$ whoami
example_user
$ sudo whoami
[sudo] password for example_user:
root
How to use Sudo on a Vultr Cloud Server

标签: none

添加新评论