LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-18-2010, 02:37 PM   #1
saagar
Member
 
Registered: Jul 2008
Location: Chennai, India
Distribution: RHEL5, Ubuntu
Posts: 191

Rep: Reputation: 37
Usage of sudo command in Ubuntu and Red Hat


Friends,
In Red Hat, suppose if root user wishes to give a privilege to run the fdisk command to a user named sam. And he makes appropriate configuration changes in /etc/sudoers file.
Now when sam wishes to run the fdisk command, then he has to issue:

Code:
[sam@system43~]$sudo /sbin/fdisk -l
   Password: ***
But in ubuntu, after the same configuration being done, what sam needs to do is:
Code:
[sam@somesystem43~]$sudo fdisk -l
   Password: ***
That means, in ubuntu the user need not type the full path of the command.
I wish to know how can I make red hat system work like ubuntu as far as the sudo usage is concerned.
Thanks...

Last edited by saagar; 04-18-2010 at 02:43 PM.
 
Old 04-18-2010, 02:47 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,276

Rep: Reputation: 4441Reputation: 4441Reputation: 4441Reputation: 4441Reputation: 4441Reputation: 4441Reputation: 4441Reputation: 4441Reputation: 4441Reputation: 4441Reputation: 4441
Quote:
Originally Posted by saagar View Post
Friends,
In Red Hat, suppose if root user wishes to give a privilege to run the fdisk command to a user named sam. And he makes appropriate configuration changes in /etc/sudoers file.
Now when sam wishes to run the fdisk command, then he has to issue:

Code:
[sam@system43~]$sudo /sbin/fdisk -l
   Password: ***
But in ubuntu, after the same configuration being done, what sam needs to do is:
Code:
[sam@somesystem43~]$sudo fdisk -l
   Password: ***
That means, in ubuntu the user need not type the full path of the command.
I wish to know how can I make red hat system work like ubuntu as far as the sudo usage is concerned.
Thanks...
Has nothing to do with SUDO. You need to modify the PATH environment variable, to include whatever directories you want. So modify the root .bashrc/.profile file accordingly.
 
1 members found this post helpful.
Old 04-18-2010, 03:00 PM   #3
saagar
Member
 
Registered: Jul 2008
Location: Chennai, India
Distribution: RHEL5, Ubuntu
Posts: 191

Original Poster
Rep: Reputation: 37
Thanks TBone for the quick reply.
Now I got it.

In Ubuntu, any user will have /sbin, /usr/local/sbin, etc...directories in his path by default even if he is not a sudo user. So, once he is given a sudo privilege for a set of commands or a particular command, he only has to type sudo followed by the command(no need for the full path)
But in Red Hat, by default, the path for running those commands are not set for a normal user by default. So, the sudo user needs to type in the full path. To make this work, the appropriate paths need to be added in his .bashrc file.

Thanks.

Last edited by saagar; 04-18-2010 at 03:02 PM.
 
Old 04-18-2010, 07:49 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,412

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
The problem with that is he can run any cmd in that new dir (eg /sbin), which is not necessarily what you want. If you want specific cmds only, use sudo in the same way, it's the same on all Linux.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Red Hat: Can Apache be installed with sudo or.... tjamnz Linux - Newbie 3 09-07-2007 01:23 AM
sudo command usage??? pagadala_cs Linux - Software 1 12-24-2004 11:13 AM
question about rm command on Red Hat 9 rharvey@cox Red Hat 16 10-20-2003 09:21 AM
Red Hat 7.2 command j0ck Linux - General 2 11-21-2002 01:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration