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

migrated from serverfault.com Apr 22 '16 at 18:45

This question came from our site for system and network administrators.

  • 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 Apr 14 '16 at 6:00
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.

  • 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 Apr 13 '16 at 13:24
  • See my edit, I made a mistake. – Sven Apr 13 '16 at 14:42
  • It works with "su - <username> –c ‘echo $VARNAME‘" – JayPi Apr 14 '16 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'
  • 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 Apr 13 '16 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy