Tyler Wright
Tyler Wright

Reputation: 825

View the $PATH variable of other users

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

Answers (4)

dani herrera
dani herrera

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

twalberg
twalberg

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

Varun
Varun

Reputation: 691

Source their .profile followed by their shellrc (.bashrc, .cshrc, etc based on their shell) file.

Upvotes: 0

Grammin
Grammin

Reputation: 12205

Source their bashrc

source /home/$(USERNAME)/.bashrc

Upvotes: 0

Related Questions