大家好,欢迎来到IT知识分享网。
1. 不能使用sudo命令解决方法:
想查看这个用户可以使用哪些sudo命令,输入正确密码却不能查看,原因就是在/etc/sudoers中未添加该用户。
[xm@oracle ~]$ sudo -l
[sudo] password for xm:
Sorry, user xm may not run sudo on oracle.
2.解决方法(添加用户至sudoers文件):
(1) 切换root用户
[xm@oracle ~]$ su - root
Password:
[root@oracle ~]#
(2) 添加用户至 sudoers 文件(vim /etc/sudoers 或者 visudo)
[root@oracle ~]# visudo
## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.
## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhaps using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias FILESERVERS = fs1, fs2
# Host_Alias MAILSERVERS = smtp, smtp2
## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem
在93行的位置添加该用户,正常退出即可
90 ## Allow root to run any commands anywhere
91 root ALL=(ALL) ALL
92 xh ALL=(ALL) ALL
93 xm ALL=(ALL) ALL
94 ## Allows members of the 'sys' group to run networking, software,
95 ## service management apps and more.
96 # %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
(3) 正常使用sudo命令
[root@oracle ~]# su - xm
[xm@oracle ~]$ sudo -l
[sudo] password for xm:
Matching Defaults entries for xm on this host:
!visiblepw, always_set_home, env_reset, env_keep="COLORS DISPLAY HOSTNAME
HISTSIZE INPUTRC KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG
LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT
LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE",
env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY",
secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin
User xm may run the following commands on this host:
(ALL) ALL
由结果看出:可以执行的sudo命令为所有ALL
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/15649.html