Sudo

From ArchWiki

Jump to: navigation, search
i18n
English
Français
Italiano
Русский
简体中文

Contents

[edit] Installation

To install Sudo:

pacman -S sudo

[edit] Enabling sudo for Users

To add a user as a sudo user (a "sudoer"), type "visudo" as root. This will open the file /etc/sudoers in a special session of vi. (Do not edit /etc/sudoers directly with an editor). To give the user full root privileges when he/she precedes a command with "sudo", add the following line:

USER_NAME   ALL=(ALL) ALL

where USER_NAME is the username of the individual.


[edit] Enabling Tab-Completion for sudo Users

Tab-completion, by default, will not work when a user is initially added to the sudoers file. For example, normally johndoe only has to type:

fir<TAB>

and the shell will complete out the command for him as:

firefox


If, however, johndoe is added to the sudoers file and he types:

sudo fir<TAB>

the shell will do nothing.



If you use programmable completion for bash you should comment out the following lines in /etc/bash_completion:

# user commands see only users
complete -u su usermod userdel passwd chage write chfn groups slay w
# group commands see only groups
[ -n "$bash205" ] && complete -g groupmod groupdel newgrp 2>/dev/null


Otherwise add the following to your ~/.bashrc (only if you did not modify bash_completion as it overwrites the settings for sudo):

complete -cf sudo

[edit] Summary

To summarize, the following setup will satisfy most individuals, where USER_NAME is the individual's username:

1. pacman -S sudo
2. add "USER_NAME   ALL=(ALL) ALL" to /etc/sudoers
3. add "complete -cf sudo" to /home/USER_NAME/.bashrc

[edit] See also

[edit] External links

Setting up Sudo

Personal tools