CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CentOS创建sudo用户大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

  sudo命令提供了临时使用root权限的机制,使普通用户可以执行超级管理员任务。   我要在CentOS系统上创建一个新用户,并且有执行sudo命令的权限。我并不直接修改sudoers文件。   首先创建一个新用户,如果你使用已存在的用户,可以跳过这一步。只有root用户有权限添加新用户: [root@centos ~]# adduser lwk 把username替换为你的用户名。 设置用户
@H_673_6@
@H_673_6@

  sudo命令提供了临时使用root权限的机制,使普通用户可以执行超级管理员任务。

  我要在CentOS系统上创建一个新用户,并且有执行sudo命令的权限。我并不直接修改sudoers文件

  首先创建一个新用户,如果你使用已存在的用户,可以跳过这一步。只有root用户有权限添加新用户

[root@centos ~]# adduser lwk

把username替换为你的用户名

设置用户密码:

[root@centos ~]# passwd username
[root@centos ~]# passwd lwk
Changing password for user lwk.
New @H_674_41@password: 
BAD @H_674_41@passworD: The password is shorter than 8 characters
Retype new @H_674_41@password: 
@H_674_41@passwd: all authentication tokens updated successfully.
[root@centos ~]# 

在这用户并不能执行root任务。

用户添加到wheel组

[root@centos ~]# usermod -aG wheel lwk

在CentOS上,wheel组里的成员有执行sudo的权限。

测试
使用su命令切换到新用户

[root@centos ~]# su - lwk
Last Failed login: Tue Apr 17 11:16:18 CST 2018 from 192.168.2.182 on ssh:notty
There were 10 Failed login attempts since the last successful login.
[lwk@centos ~]$

执行root任务:

[lwk@centos ~]$ sudo yum update
[sudo] password for lwk: 
Loaded plugins: fastestmirror,langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
base                                                                                              | 3.6 kB  00:00:00     
extras                                                                                            | 3.4 kB  00:00:00     
gitlab_gitlab-ce/x86_64/signature                                                                 |  836 B  00:00:00     
gitlab_gitlab-ce/x86_64/signature                                                                 | 1.0 kB  00:00:00 !!! 
gitlab_gitlab-ce-source/signature                                                                 |  836 B  00:00:00     
gitlab_gitlab-ce-source/signature                                                                 |  951 B  00:00:00 !!! 
jenkins                                                                                           | 2.9 kB  00:00:00     
updates                                                                                           | 3.4 kB  00:00:00     
(1/2): jenkins/priMary_db                                                                         |  23 kB  00:00:00     
(2/2): updates/7/x86_64/priMary_db                                                                | 6.9 MB  00:00:01     
(1/2): gitlab_gitlab-ce-source/priMary                                                            |  175 B  00:00:02     
(2/2): gitlab_gitlab-ce/x86_64/priMary                                                            | 1.2 MB  00:00:03     
Determining fastest mirrors

至此完成相应任务。

文献

大佬总结

以上是大佬教程为你收集整理的CentOS创建sudo用户全部内容,希望文章能够帮你解决CentOS创建sudo用户所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
猜你在找的CentOS相关文章