How to get root user PATH from normal user
Please help me to get root user PATH from normal user in linux.
ThanQ, Nagendra |
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 |
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. |
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.) |
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 |
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 |
Quote:
|
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. |
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 |
Is this homework? If not why do you want to do this? :confused:
jdk |
Quote:
Do it like this: Code:
$ sudo su |
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 |
All times are GMT -5. The time now is 07:09 PM. |