CentOS下添加普通用户到sudo组 并且免密码登录

本文发布时间: 2019-Mar-22
1.1 sudoSudo是linux系统中,非root权限的用户提升自己权限来执行某些特性命令的方式,它使普通用户在不知道超级用户的密码的情况下,也可以暂时的获得root权限。一般,普通用户在执行特殊命令是,只需要在特殊命令(如 yum)前面加上sudo,并输入自己的用户密码就可以了,在之后的5分钟内,再次使用特殊命令时,就无需再次输入用户密码。同时,sudo提供了强大的日志管理,其中详细的记录了每个用户都干了什么。sudo用户的管理是在文件:/etc/sudoers中存放的。也就是说,如果想把某个用户加入到sudo用户群里面,就需要自行配置这个文件,在读写这个文件时,需要root的权限。1.2 将用户添加到sudo组在使用sudo的时候,如果出现"dba is not in the sudoers file. This incident will be reported.”说明当前用户名:dba是没有权限使用sudo的,这个时候我们就需要修改/etc/sudoers来为当前用户dba添加sudo权限。[dba@oracle ~]$ sudo yum -y updateWe 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 dba: dba is not in the sudoers file. This incident will be reported.[dba@oracle ~]$ 使用 “su –” 命令,进入root用户;为sudoers文件添加写入的权限:使用命令 “chmod u+w /etc/sudoers”执行visudo 命令,按“i”进入编辑模式后,找到“root ALL=(ALL) ALL ”,在后面添加:"dba ALL=(ALL) NOPASSWD: ALL",再按一下“Esc”键退出编辑,输入“wq”(write quit)后,退出sudoers。ss输入“chmod u-w /etc/sudoers”将文件的写入属性去掉通过“exit”切换回自己的用户,再使用sudo whoami命令时,如果返回root,就可以使用了


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:08pm
栏目列表