Reputation: 825
As a unix administrator, is there a way to view the $PATH variable of other users using bash in the system without having to switch to them?
Upvotes: 2
Views: 3532
Reputation: 51665
As root:
root@egg-v3:~# su - some_user_name -c env | grep PATH
Result:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Edited 10 years later
I don't know why I didn't just write:
su - some_user_name -c 'echo $PATH'
or
sudo -u some_user_name echo $PATH
Upvotes: 4
Reputation: 62389
Assuming you are on Linux, if you want to get the environment for any one specific process, and you have its PID, this will work:
xargs -n 1 -0 echo < /proc/<PID>/environ
Other *nixen may or may not have similar facilities. I remember that one of the ps
versions on Solaris had a way to get the environment variables for processes as well...
Upvotes: 0
Reputation: 691
Source their .profile
followed by their shellrc (.bashrc
, .cshrc
, etc based on their shell) file.
Upvotes: 0