sudo是linux系统管理指令,是允许系统管理员让普通用户执行一些或者全部的root命令的一个工具,如halt,reboot,su等等。 这样不仅减少了root用户的登录和管理时间,同样也提高了安全性。 sudo不是对shell的一个代替,它是面向每个命令的。 在教程中,将向你展示如何在 CentOS 上创建具有 sudo 权限的新用户。你可以使用 sudo 用户在 CentOS 机器上执行管理任务,而无需以 root 用户身份登录。
默认在 CentOS 上,组轮中的用户被授予 sudo 访问权限。如果要为现有用户配置 sudo,只需将你的用户添加到
wheel
组中,如步骤 4 所示。 按照以下步骤在你的 CentOS 服务器上创建一个 sudo 用户:
首先以 root 用户身份通过ssh登录到你的 CentOS 服务器:
> ssh root@server_ip_address
使用useradd 命令创建一个新用户帐户:
>
useradd rumenz
替换
rumenz
为你要创建的用户名。
运行
passwd
命令为新用户设置密码:
>
passwd rumenz
系统将提示你确认密码。确保使用强密码。
Changing password for user rumenz.New password:Retype new password:passwd: all authentication tokens updated successfully.
sudo
组中默认情况下,在 CentOS 系统上,组成员
wheel
被授予 sudo 访问权限。将新用户添加到wheel组:
> usermod -aG wheel rumenz
切换 到新创建的用户:
>
su
-
rumenz
要使用 sudo,只需在命令前加上
sudo
。
>
sudo
[COMMAND]
例如,要列出
/root
你将使用 的目录的内容:
>
sudo ls
-l
/root
第一次从该帐户使用 sudo 时,你将看到以下横幅消息,并提示你输入用户帐户的密码。
We trust you have received the usual lecture from the local SystemAdministrator. 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 rumenz:
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有