定義某個用戶以另一個用戶的身份,在某個主機執行某個命令。受權一個用戶以管理員的權限執行某些命令。每個「visudo」定義行表示一個sudo條目(用戶定義)。經過別名指定一個用戶組的行爲規定。那麼定義格式就明顯了:python
user/alias host=(as a user) any-command
別名必須是英文大寫,別名有四類:User_Alias、Host_Alias、Runas_Alias、Cmnd_Alias。定義格式以下:bash
# User alias specification User_Alias WEBMASTERS = will, wendy, wim # Runas alias specification Runas_Alias DB = oracle, sybase # Host alias specification Host_Alias SPARC = bigtime, eclipse, moet, anchor :\ SGI = grolsch, dandelion, black :\ ALPHA = widget, thalamus, foobar :\ HPPA = boa, nag, python Host_Alias CUNETS = 128.138.0.0/255.255.0.0 Host_Alias CSNETS = 128.138.243.0, 128.138.204.0/24, 128.138.242.0 Host_Alias SERVERS = master, mail, www, ns # Cmnd alias specification Cmnd_Alias PRINTING = /usr/sbin/lpc, /usr/bin/lprm Cmnd_Alias SHELLS = /usr/bin/sh, /usr/bin/csh, /usr/bin/ksh,\ /usr/local/bin/zsh
命令選項
oracle
-l 當前主機當前用戶條目定義eclipse
[root@right ~]# sudo -l Matching Defaults entries for root on this host: requiretty, !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 root may run the following commands on this host: (ALL) ALL
追逐用戶操做ide
經過查看日誌查看各個用戶的操做的行爲。ui
# cat /var/log/secure # cat /var/log/message