如何在CentOS Linux 7.5上创建一个sudo用户

创建sudo用户的步骤

1)以root用户身份登录到您的CentOS服务器:

ssh root@server_ip_address

2)使用useradd命令创建一个新的用户帐户:

useradd username

将username替换为您要创建的用户名。

3)使用passwd命令为新用户设置密码:

passwd username

输出:

Changing password for user username.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

4)将新用户添加到组成员。

usermod -aG wheel username

找到授予sudo访问权的文件中的行

在CentOS默认情况下,组轮中的用户被授予sudo访问权限。

如何使用sudo

切换到新创建的用户:

su - username

要使用sudo,只需在命令前加上sudo和一个空格即可。

sudo ls -l /root

您第一次使用此帐户中的sudo时,您将看到以下标题消息,并且系统会提示您输入用户帐户的密码。

输出:

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for username:

就这样! 如果您有任何问题,请随时留下评论。

猜你喜欢

转载自www.linuxidc.com/Linux/2018-05/152577.htm