LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   root access (https://www.linuxquestions.org/questions/linux-newbie-8/root-access-4175441169/)

thomaj1 12-12-2012 12:19 PM

root access
 
How do I grant root access to a user without giving root/password?

TB0ne 12-12-2012 12:23 PM

Quote:

Originally Posted by thomaj1 (Post 4847889)
How do I grant root access to a user without giving root/password?

You use sudo. It can let an ordinary user run commands with elevated privileges, and you can restrict users to just running ONE command (or a set of commands), if you'd like, to really lock things down. It has lots of other features too, and is pretty much a 'standard' way of doing this.

http://linux.die.net/man/8/sudo

sharadchhetri 12-12-2012 02:01 PM

Quote:

Originally Posted by TB0ne (Post 4847890)
You use sudo. It can let an ordinary user run commands with elevated privileges, and you can restrict users to just running ONE command (or a set of commands), if you'd like, to really lock things down. It has lots of other features too, and is pretty much a 'standard' way of doing this.

http://linux.die.net/man/8/sudo


Add these below lines in /etc/sudoers file.

username ALL=(ALL) ALL

Note: Explore more for sudo configuration. http://www.sudo.ws/sudo/man/1.8.6/sudoers.man.html . (This is man sudoers of 1.8.6 version)

TobiSGD 12-12-2012 02:13 PM

Usually when this question is asked there is a lack of trust to the users that have to have administrative rights for their job. So giving them total root access with this line
Code:

username        ALL=(ALL) ALL
is not a good idea, because the user will basically be root with this line and can do anything on the system. In this case it would be much less hassle to just give the user the root password instead.

To really give you the best advice it is necessary for us to know what exactly you are planning to allow to the user in question. I have seen it many times that people recommend sudo for a purpose when the Unix/Linux file permissions are a much better way to do the job.
Please explain more specific what you plan to do.

sharadchhetri 12-12-2012 02:35 PM

Quote:

Originally Posted by TobiSGD (Post 4847969)
Usually when this question is asked there is a lack of trust to the users that have to have administrative rights for their job. So giving them total root access with this line
Code:

username        ALL=(ALL) ALL
is not a good idea, because the user will basically be root with this line and can do anything on the system. In this case it would be much less hassle to just give the user the root password instead.

To really give you the best advice it is necessary for us to know what exactly you are planning to allow to the user in question. I have seen it many times that people recommend sudo for a purpose when the Unix/Linux file permissions are a much better way to do the job.
Please explain more specific what you plan to do.

+1 Tobi,

Read the man page link which I pasted ,it is helpful and do the google search you will get many examples .
Another best practice is to create alias of commands and assign it to group or user in /etc/sudoers.

Below is the example,

Cmnd_Alias SHELLS=/usr/bin/sh, /usr/bin/ksh, /usr/bin/csh
Cmnd_Alias SU=/bin/su
%grouname ALL=ALL, !SHELLS, !SU
username ALL=ALL, !SHELLS, !SU

Just explore more, read more,execute and enjoy the power of sudo


All times are GMT -5. The time now is 10:07 AM.