- A+
所属分类:VPS教程
Sudo命令被设计用来允许用户使用其他用户的安全权限运行程序,默认情况下为root用户。在本指南中,我们将向您展示如何在CentOS上创建具有sudo权限的新用户,您可以使用sudo用户在CentOS计算机上执行管理任务,而无需以root用户身份登录。
创建sudo用户
在CentOS上,默认情况下wheel组中的用户被授予sudo访问权限。如果要为现有用户配置sudo,就像下面步骤4的做法一样,只需将用户添加到wheel组中。
按照以下步骤在CentOS服务器上创建一个sudo用户。
首先以root用户身份登录CentOS服务器,使用useradd命令创建新用户帐户:
useradd username
替换username为您要创建的用户名。
使用此passwd命令为新用户设置密码。
passwd username
系统将提示您确认密码。确保使用强密码。
Changing password for user username.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
将新用户添加到wheel组。
usermod -aG wheel username
如何使用sudo
切换到新创建的用户:
su - username
要使用sudo,只需在命令前加上前缀sudo和空格即可。
sudo [COMMAND]
例如,要列出/root您将使用的目录的内容:
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:
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:
总结,你已在CentOS系统上成功创建了一个sudo用户。您现在可以使用此用户在服务器上执行管理任务。
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏