0

How can i get an overview about env (environment) of all users on a system?

Status: i've got over 600 user in passwd, but each of them could have a env variable for a specifec project path (~10 posibilitys).

One way is to login with each account, type env and check it manually.

Is there a more comfortable way to check this via root at best with a result in one file?

System: HP-UX / dtterm

1
  • What are you trying to achieve? Each user could have modified their configuration in ways you did not foresee. So the assumption that their configuration matches one of 10 possibilities might not be valid. And it is not even a given that any heuristics you choose to detect their configuration will reveal that they changed the configuration. At best you can hope to correctly detect the configuration for those where you configured it in the first place and the user did not change it. If that's what you aim for, why not simply perform a grep on the file which differed between the original cfgs?
    – kasperd
    Commented Apr 14, 2016 at 6:00

2 Answers 2

1

On Linux: As root, iterate

su <username> -c 'echo $VARNAME' --login 

over all relevant usernames. Should work in a similar way on HP-UX, but please check man su.

It's important to use single quotes to prevent your local shell to expand the variable.

3
  • su project1 -c 'echo $TERM' >>> works well, as example. But su project1 -c 'echo $TXP_HOME' >>> gets TXP: Undefined variable. Has I comment the > _ < by another way?
    – JayPi
    Commented Apr 13, 2016 at 13:24
  • See my edit, I made a mistake.
    – Sven
    Commented Apr 13, 2016 at 14:42
  • It works with "su - <username> –c ‘echo $VARNAME‘"
    – JayPi
    Commented Apr 14, 2016 at 8:45
0

you can look in the dot files, environment variables are set in .files in the users /home directory (like .bashrc or .localrc etc)if you know the name of the variable you are looking for you can find the string with grep, in the example below it looks for 'set' or 'setenv'

cat /home/*/.* | grep 'setenv\|set'
1
  • It's easy to miss stuff with this approach. What if I have a line like source ~/dev/setvar.sh in my ~/.bashrc that sets this var?
    – Sven
    Commented Apr 13, 2016 at 12:17

You must log in to answer this question.