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 08-23-2011, 04:36 AM   #1
nagendrar
Member
 
Registered: Apr 2008
Location: HYD, INDIA.
Posts: 146

Rep: Reputation: 15
How to get root user PATH from normal user


Please help me to get root user PATH from normal user in linux.

ThanQ,
Nagendra
 
Old 08-23-2011, 05:03 AM   #2
0men
Member
 
Registered: Mar 2011
Location: Gold Coast, Australia
Distribution: saline, centos, freeBSD, slackware
Posts: 180

Rep: Reputation: 22
Well you could use sudo
or if you know about sudo and it's still not working. Try this

For example let's say you want to shut down your machine.

If you use ubuntu or mint etc you would use
sudo shutdown now -h

However if you try that command and you grt an error message such as "command not found"
you'll have to specify where shutdown is. (it's in Sbin )

So you would use instead
sudo /sbin/shutdown now -h

I'm guessing your using debian or slack though

I hope this helps :S

Kind regards
 
Old 08-23-2011, 05:14 AM   #3
nagendrar
Member
 
Registered: Apr 2008
Location: HYD, INDIA.
Posts: 146

Original Poster
Rep: Reputation: 15
I did like below. But I got same as non-root user. So I think, it is difficult to get PATH of root user from non-root user using 'sudo'.

[nag@nag collector]$ echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/nag/bin
[nag@nag collector]$ sudo echo $PATH
Password:
/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/nag/bin
[nag@nag collector]$

Please help me to solve this.
 
Old 08-23-2011, 05:19 AM   #4
kostya
Member
 
Registered: Mar 2010
Location: Moscow, Russia
Distribution: Ubuntu Studio, antix(mepis), Fedora, FreeBSD
Posts: 172
Blog Entries: 5

Rep: Reputation: 17
Deleted as soon as I noticed my misunderstanding of the question.

The command `sudo su` must log you in as root, then do `echo $PATH` to see the root's path.
That would mean your sudo policy allows you to have root access to your machine, in which case I don't see why you can't just login as root and see the path.

(On the other hand, if you arent' given such access to the machine, then why should anyone help you to violate the machine owner's policy? That's about the size of it.)

Last edited by kostya; 08-23-2011 at 05:31 AM.
 
Old 08-23-2011, 05:24 AM   #5
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 651

Rep: Reputation: 269Reputation: 269Reputation: 269
Hi, $PATH is the environment variable -- each terminal can have its own. You can have multiple terminals open and have different $PATH in each of them. If you want to know root's default path, you need to login as root:
$ su -
if you are not root, you can grep /etc/profile.d for PATH and /root/.bash_profile and /root/.bashrc, but you won't probably have permission to read them
 
Old 08-23-2011, 05:37 AM   #6
nagendrar
Member
 
Registered: Apr 2008
Location: HYD, INDIA.
Posts: 146

Original Poster
Rep: Reputation: 15
We able to get PATH env from /root/.bash_profile using sudo as below. But we won't get total extendable PATH like PATH=/usr/bin:/usr/sbin:/sbin/:.....

[nag@nag ~]$ sudo grep PATH= /root/.bash_profile
PATH=$PATH:$HOME/bin

Please help me solve this.

Regards,
Nagendra
 
Old 08-23-2011, 05:43 AM   #7
kostya
Member
 
Registered: Mar 2010
Location: Moscow, Russia
Distribution: Ubuntu Studio, antix(mepis), Fedora, FreeBSD
Posts: 172
Blog Entries: 5

Rep: Reputation: 17
Quote:
Originally Posted by kostya View Post
...
The command `sudo su` must log you in as root, then do `echo $PATH` to see the root's path.
What, the above didn't work for you?
 
Old 08-23-2011, 05:45 AM   #8
scottro11
Member
 
Registered: Jun 2009
Location: NYC
Posts: 257

Rep: Reputation: 58
Note that you should mention what distribution you're using.

I suspect you're using a RedHat based one. I have a page on this, as the question used to always come up on Fedora forums at

http://home.roadrunner.com/~computer...su/rhpath.html

I think the instructions there should help.
 
Old 08-23-2011, 05:53 AM   #9
nagendrar
Member
 
Registered: Apr 2008
Location: HYD, INDIA.
Posts: 146

Original Poster
Rep: Reputation: 15
i did like below. But i did not get anything out put because terminal changed.

[nag@nag Downloads]$ sudo su;echo $PATH
[root@nag Downloads]#


Here i need to do without login as root. Please help me solve this.

Regards.
Nagendra

---------- Post added 08-23-11 at 03:24 PM ----------

I am using CentOS 5

ThanQ,
Nagendra
 
Old 08-23-2011, 05:57 AM   #10
jdkaye
Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,024

Rep: Reputation: Disabled
Is this homework? If not why do you want to do this?
jdk
 
Old 08-23-2011, 06:01 PM   #11
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714
Quote:
[nag@nag Downloads]$ sudo su;echo $PATH
[root@nag Downloads]#
That's wrong. You're running "sudo su", then once you exit the shell created by "su", the command "echo $PATH" will be run in your original shell.

Do it like this:

Code:
$ sudo su
# echo $PATH
 
Old 08-23-2011, 09:40 PM   #12
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
When you use su, you must specify '-' to get root user's env, otherwise you are logged in as root, but with you orig env.
http://linux.die.net/man/1/su

What you get via sudo depends on the content of the sudoers file http://linux.die.net/man/5/sudoers
 
  


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
How to run daemon process being a normal user [not root user]. narendra1310 Linux - Software 1 10-26-2009 10:48 AM
add path to normal user acbenny Linux - General 6 08-07-2004 11:24 PM
Root? normal user? what does it all mean? Zieroth Linux - Newbie 5 07-16-2004 05:06 PM
Games runs slow as normal user, but fast as root user mcore Linux - Software 2 06-08-2004 12:11 AM
Setting java path for normal user bruce64 Linux - Software 2 07-08-2003 05:07 PM


All times are GMT -5. The time now is 04:41 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration