-----------------------------------------------------------------------
[anshu@Fedora7 ~]$ sudo ls /root/
anshu is not in the sudoers file. This incident will be reported.
[anshu@Fedora7 ~]$
-----------------------------------------------------------------------
So you see, running some commands which need root access CANNOT be run by normal user.
And you have option to go as su (super user. ie- root) to do all steps as root. but what about JUST single line commands. for that your username can have special access. This post will show how and what it is.
------------------------------------------------------------------------------
[root@Fedora7 ~]# whatis sudo
sudo (8) - execute a command as another user
sudo (rpm) - Allows restricted root access for specified users
sudo [sudoedit] (8) - execute a command as another user
------------------------------------------------------------------------------
I will show how to make your normal user turn into (sudo)root for single line commands .
Steps:-
1* su --login -c 'visudo' // - Press enter and give root's password.
2* add your username under root line.
-------------------------------------------------------------
root ALL=(ALL) ALL
anshu ALL=(ALL) ALL
-------------------------------------------------------------
HINT* press 'I' key to Insert and 'DEL' key to delete words.
3* uncomment ONE option from line 83 OR 86.
------------------------------------------------------------
82 ## Allows people in group wheel to run all commands
83 # %wheel ALL=(ALL) ALL
84
85 ## Same thing without a password
86 # %wheel ALL=(ALL) NOPASSWD: ALL
------------------------------------------------------------
4* :wq to SAVE and EXIT
5* RECOMMENDED , MODIFY following line in bash_profile to run all files in SuperBIN folder (i.e /sbin or /usr/sbin ):-
-----------------------------------------------------------
PATH=$PATH:/usr/sbin:/sbin:$HOME/bin
-----------------------------------------------------------
6* add user to WHEEL group by GUI or Command:-
------------------------------------------------------------------------------
su -c 'gpasswd -a anshu wheel' // << replace anshu with yourusername ( Duh! )
------------------------------------------------------------------------------
Try running commands like "ls /root/" and click some ads on this site as Thank You :).
Update:- Check this guide in video.