新增一个普通用户并进入该用户:

[root@VM_0_7_centos ~]# groupadd mall
[root@VM_0_7_centos ~]# useradd mall -m -d /home/mall -g mall -s /bin/bash
[root@VM_0_7_centos ~]# passwd mall
Changing password for user mall.
New password:
BAD PASSWORD: The password is shorter than characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@VM_0_7_centos ~]# su - mall

  安装yum-utils失败了,提示需要root权限:

[mall@VM_0_7_centos ~]$ yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
You need to be root to perform this command.

  使用sudo获取root权限:

[mall@VM_0_7_centos ~]$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things: #) Respect the privacy of others.
#) Think before you type.
#) With great power comes great responsibility. [sudo] password for mall:
mall is not in the sudoers file. This incident will be reported.

  它说该普通用户没有在sudoers文件里,切换回root:

[mall@VM_0_7_centos ~]$ su - root
Password:
Last login: Wed Oct :: CST from 202.101.145.54 on pts/
Last failed login: Wed Oct :: CST from 110.119.120.10 on ssh:notty
There were failed login attempts since the last successful login.

  修改sudoers文件,加入写权限:

[root@VM_0_7_centos ~]# chmod +w /etc/sudoers
[root@VM_0_7_centos ~]# vi /etc/sudoers

  新增下面标红的那一行,把普通用户mall加进入:

  敲:wq保存后,撤销sudoers文件写权限:

[root@VM_0_7_centos ~]# chmod -w /etc/sudoers

  重新进入mall用户,下载yum-utils:

[root@VM_0_7_centos ~]# su - mall
Last login: Wed Oct :: CST on pts/
[mall@VM_0_7_centos ~]$ sudo yum -y install yum-utils device-mapper-persistent-data 1vm2
[sudo] password for mall:
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package yum-utils-1.1.-.el7.noarch already installed and latest version
Package device-mapper-persistent-data-0.8.-.el7.x86_64 already installed and latest version
No package 1vm2 available.
Nothing to do

  这回可以了,不过其实已经安装过了,白折腾了。

linux普通用户添加root权限的更多相关文章

  1. Linux给用户添加sudo权限

    一.linux给用户添加sudo权限: 有时候,linux下面运行sudo命令,会提示类似: xxxis not in the sudoers file.  This incident will be ...

  2. linux普通用户使用root权限执行命令的脚本

    上一篇有说到普通用户使用免密登录并使用root权限: http://www.cnblogs.com/01-single/p/8919254.html 现在使用脚本批量实现部署系统任务操作步骤: #!/ ...

  3. 给普通用户添加root权限

    >>提君博客原创  http://www.cnblogs.com/tijun/  << 第一步,以root用户查看/etc/sudoers [root@ltt2 hadoop] ...

  4. linux给用户赋予root权限

    1.到/etc目录下 2.使用 vi sudoers 3.将username添加到sudoers

  5. 04.给linux用户添加sudo权限

    linux给用户添加sudo权限: 有时候,linux下面运行sudo命令,会提示类似: xxxis not in the sudoers file.  This incident will be r ...

  6. Linux系统下给非root用户添加sudo权限

    Linux系统下给非root用户添加sudo权限 有时,在linux系统中非root用户运行sudo命令,会提示类似信息:  xxx is not in the sudoers file. This ...

  7. Linux中给普通用户添加sudo权限

    使用Linux系统时,经常会被要求使用超级权限,但是root的权限太过大了,一般慎用!!!因此可以通过给普通用户添加sudo权限,平常用普通用户进行操作,当需要root权限的时候进行sudo操作.以下 ...

  8. Linux学习笔记之如何让普通用户获得ROOT权限

    在学习sodu的时候,我发现一些命令只能由root用户使用,普通用户使用会提示此用户没有使用sudo的权限.我想到的解方法是把正在使用的普通用户获得root权限,于是我通过百度和询问老师知道了如何去实 ...

  9. linux gcc++漏洞:普通用户获得root权限

    linux gcc++漏洞:普通用户获得root权限 2012-02-06 10:22:38|  分类: linux安全|举报|字号 订阅       经我测试在RHEL5 / CentOS5 / F ...

随机推荐

  1. gradle 构建scala程序

    一.build.gradle 二.gradle build ===================== 执行scala scala main.scala

  2. 浏览器兼容问题--get/post

    问题描述: 人员通过发送位置在百度地图上显示出来.删除人员后,chrome地图上该人员也随即消失,但IE浏览器上仍旧存在.清除缓存后,才消失. 原因: IE下面同一个地址,不会多次去请求的.只有加一个 ...

  3. 常用的HTTP状态码,网站开发请求状态必备

    成功的状态码: 200 – 服务器成功返回网页 304 – 未修改 失败的状态码: 404 – 请求的网页不存在 503 – 服务器暂时不可用 500 – 服务器内部错误 下面的不是很常用,记住上面那 ...

  4. Java四种读取和创建XML文档的例子教程

    四种方法解析XML文档:Dom.SAX.JDOM.dom4j          1.了解XML XML,即可扩展标记语言(Extensible Markup Language),标准通用标记语言的子集 ...

  5. (转载) 从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn)

    这一篇是从0开始搭建SQL Server AlwaysOn 的第三篇,这一篇才真正开始搭建AlwaysOn,前两篇是为搭建AlwaysOn 做准备的 步骤 这一篇依然使用step by step的方式 ...

  6. 2019-2020-1 20199302《Linux内核原理与分析》第六周作业

    一 .万能函数 1.过程抽象 (1)接口:指明模块要做什么,标识符/类型.函数等,.h ,函数调用者 (2)实现:指明模块如何完成接口,一个接口多个实现(可能),.c ,函数实现者 (3)函数签名:函 ...

  7. [转载]JSON WEB TOKEN,简单谈谈TOKEN的使用及在C#中的实现

    https://www.cnblogs.com/chenwolong/p/Token.html

  8. 2019.11.29 Mysql的数据操作

    为名为name的表增加数据(插入所有字段) insert into name values(1,‘张三’,‘男’,20); 为名为name的表增加数据(插入部分字段) insert into name ...

  9. Random Target Moving~

    测试了一下用向量处理随机目标,还是挺有趣的,源码如下: PVector p1, p2; float gap = 10; void setup() { size(1920, 1080); backgro ...

  10. flutter踩坑小记:The number of method references in a .dex file cannot exceed 64K.

    The number of method references in a .dex file cannot exceed 64K. 这句话的意思翻译出来是:.dex文件中的方法引用数不能超过64K. ...