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

[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. 《少年先疯队》第八次团队作业:Alpha冲刺第一天

    前言   第一天冲刺会议   时间:2019.6.14   地点:9C406 1.1 今日完成任务情况以及遇到的问题.   1.1.1今日完成任务情况 姚玉婷:管理员登录功能的实现,用户登录功能的实现 ...

  2. 《你说对就队》第八次团队作业:Alpha冲刺 第二天

    <你说对就队>第八次团队作业:Alpha冲刺 项目 内容 这个作业属于哪个课程 [教师博客主页链接] 这个作业的要求在哪里 [作业链接地址] 团队名称 <你说对就队> 作业学习 ...

  3. C# 6.0 中的新增功能(.NET Framework 4.6 与 Visual Studio 2015 )

    C#6.0 在 2015 年7月随着.NET Framework 4.6 一同发布,后期发布了.NET Framework 4.6.1,4.6.2. 一.自动属性初始化(Auto-property i ...

  4. MySQL常用五大引擎的区别

    MyISAM: 如果你有一个 MyISAM 数据表包含着 FULLTEXT 或 SPATIAL 索引,你将不能把它转换为使用 另一种引擎,因为只有 MyISAM 支持这两种索引. BLOB: 如果你有 ...

  5. LOJ P10065 北极通讯网络 题解

    每日一题 day39 打卡 Analysis 1.当正向思考受阻时,逆向思维可能有奇效. 2.问题转化为:找到最小的d,使去掉所有权值>d的边之后,连通支的个数<k; 3.定理:如果去掉所 ...

  6. Session的应用——三天免登录

    1.使用Cookie实现的登录的不足: protected void doGet(HttpServletRequest request, HttpServletResponse response) t ...

  7. RookeyFrame 模块 线上创建的模块 迁移到 线下来

    1. 把线上创建的model,写在项目的model层里面. 把文件 Rookey.Frame.Web\Config\TempModel\Order_File.code 复制到model层, 用文本编辑 ...

  8. 发现Mathematica中求逆出错

    发现Mathematica中应用Inverse求逆时出错.

  9. Pycharm使用技巧:Split Vertically/Horizontally(垂直/水平拆分窗口)

    Split Vertically或者Split Horizontally可以把当前编辑窗口垂直或者水平拆分成两个. 使用: 在编辑窗口中打开你要展示的两个文件(如图中的  "郭靖" ...

  10. Deepin-TIM或Deepin-QQ调整界面DPI字体大小的方法

    Deepin-TIM或Deepin-QQ调整界面DPI字体大小的方法 env WINEPREFIX="/home/landv/.deepinwine/Deepin-QQ" deep ...