User Tools

Site Tools


sudo:allow_user_to_run_root_privileged_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sudo:allow_user_to_run_root_privileged_commands [2017/04/03 15:31] – created petersudo:allow_user_to_run_root_privileged_commands [2019/12/04 21:40] (current) – removed peter
Line 1: Line 1:
-====== Sudo - Allow user to run root privileged commands ====== 
- 
-To allow a normal user to run root privileged commands, you have to use sudo.  Sudo allows a user to run commands as superuser or another user.  To set your user to be able to use sudo to act as superuser, a number of steps have to be done. 
- 
-Login as superuser(root). 
-Edit sudoers file using visudo. 
- 
-<code bash> 
-# visudo 
-</code> 
- 
-Uncomment the below line and save.  visudo uses vi as the text editor, so to save just press 'Esc' and then ':wq'. 
- 
-<code> 
-%wheel ALL=(ALL) ALL 
-</code> 
- 
-Add your user to the group wheel (You can use any name for the group as long as you add it to the sudoers file).  As example, we will use 'foo' as our username. 
- 
-<code bash> 
-usermod -G wheel foo 
-</code> 
- 
-To make all the superuser's environment variable available to the user, edit /home/foo/.bash_profile. 
- 
-<code bash> 
-vi /home/foo/.bash_profile 
-</code> 
- 
-Add the following lines, append if the line already exist. 
- 
-<file bash /home/foo/.bash_profile> 
-PATH=$PATH:/sbin:/usr/sbin 
-export PATH 
-</file> 
- 
-Save the file 
- 
-To activate the changes, run: 
- 
-<code bash> 
-. .bash_profile 
-</code> 
- 
-Now, you can use superuser environment variables, but without tab completion feature.  To enable tab completion edit /home/foo/.bashrc. 
- 
-<code bash> 
-vi /home/foo/.bashrc 
-</code> 
- 
-Add the following line 
- 
-<file bash /home/foo/.bashrc> 
-complete -cf sudo 
-</file> 
- 
-Save the file. 
- 
-To activate the changes, run: 
- 
-<code bash> 
-. .bashrc 
-</code> 
- 
-Logout and login back.  Now you can use sudo to execute root privileged commands, you inherited the root environment variables and you can use tab completion while using sudo. 
  
sudo/allow_user_to_run_root_privileged_commands.1491233507.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki