sudo

1 添加用户

#添加组和用户
# groupadd release  
# useradd  -g release release  

 

2 赋予release用户root的所有权限(使用的时候需要输入用户密码)

#vi /etc/sudoers 
## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
release ALL=(ALL)       ALL


#使用sudo需要先输入用户的密码
[root@zabbix home]# su - release
[release@zabbix ~]$ sudo ls -lrt /bin/
[sudo] password for release: 
总用量 7992
-rwxr-xr-x. 1 root root     576 4月  17 2008 redhat_lsb_init
-rwxr-xr-x. 1 root root   33488 12月  9 2009 gettext
-rwxr-xr-x. 2 root root   53400 3月   1 2010 red
-rwxr-xr-x. 2 root root   53400 3月   1 2010 ed
-rwxr-xr-x. 1 root root   23672 3月   3 2010 setserial
-rwxr-xr-x. 1 root root   57480 5月  25 2010 traceroute
-rwxr-xr-x. 1 root root  238976 6月  16 2010 find
-rwxr-xr-x. 1 root root     363 6月  24 2010 unicode_stop
-rwxr-xr-x. 1 root root    2555 6月  24 2010 unicode_start
-rwxr-xr-x. 1 root root   42384 6月  24 2010 setfont
-rwxr-xr-x. 1 root root  112208 6月  24 2010 loadkeys
-rwxr-xr-x. 1 root root   11296 6月  24 2010 kbd_mode
-rwxr-xr-x. 1 root root   81120 6月  24 2010 dumpkeys
-rwxr-xr-x. 1 root root  178928 8月  12 2010 nano
-rwxr-xr-x. 1 root root   25560 2月   4 2012 keyctl

 

3 赋予release用户root的所有权限(使用的时候不需要输入用户密码)

[root@zabbix profile.d]# vi /etc/sudoers

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
release ALL=(ALL)       NOPASSWD: ALL



#使用时候无需输入密码
[root@zabbix home]# su - release
[release@zabbix ~]$ sudo ls -lrt /
总用量 102
drwxr-xr-x.   2 root root  4096 6月  28 2011 srv
drwxr-xr-x.   2 root root  4096 6月  28 2011 mnt
drwxr-xr-x.   2 root root  4096 6月  28 2011 media
drwxr-xr-x.   2 root root  4096 10月 26 2013 cgroup
drwx------.   2 root root 16384 5月   3 07:45 lost+found
drwxr-xr-x.  13 root root  4096 5月   3 07:47 usr
drwxr-xr-x.  20 root root  4096 5月   3 07:53 var
drwxr-xr-x.   3 root root  4096 5月   3 07:53 opt
dr-xr-xr-x.   5 root root  1024 5月   3 08:04 boot
dr-xr-x---.   3 root root  4096 5月   5 02:54 root
dr-xr-xr-x.  11 root root  4096 5月   5 02:57 lib
dr-xr-xr-x.   9 root root 12288 5月   5 05:13 lib64
dr-xr-xr-x.   2 root root  4096 5月   5 05:13 bin
dr-xr-xr-x.   2 root root 12288 5月   5 05:14 sbin
drwxr-xr-x.   2 root root     0 5月   8 06:07 misc
drwxr-xr-x.   2 root root     0 5月   8 06:07 net
drwxr-xr-x.  17 root root  3620 5月   8 06:07 dev
drwxr-xr-x.   3 root root  4096 5月   8 07:16 home
drwxrwxrwt.   4 root root  4096 5月   8 07:34 tmp
drwxr-xr-x. 105 root root 12288 5月   8 07:38 etc
dr-xr-xr-x. 101 root root     0 5月   8 2017 proc
drwxr-xr-x.  13 root root     0 5月   8 2017 sys
drwxr-xr-x.   7 root root     0 5月   8 2017 selinux

 

posted @ 2017-05-08 15:48  圣光救赎者  阅读(80)  评论(0编辑  收藏  举报