# quickest way to determine environment difference between two users

Is there a quick way to determine what is different between two users? Presently I am "sudo -u otheruser env >>out.txt" for each user to a file, and then diffing the two files.

Is there an easier way?

-

If you use bash, you can also do it in one line, avoiding the different temporary files.

diff <( sudo -u user1 env | sort ) <( sudo -u user2 env | sort )


You can also create a function, and put it in your .bashrc (.bash_profile)

function envdiff() {

if [ -z \${2} ] ; then echo "Usage: envdiff user1 user2" ; fi
diff <( sudo -u user1 env | sort ) <( sudo -u user2 env | sort )
}


This should work provided that you don't have to type the other user's passwords. If you do, then maybe it ask for them one after the other; I haven't tested it.

For convenience, you could also use tkdiff instead of diff.

-
note that as env prints the variables in the order they were set, you might want to add |sort after sudo -u user env. –  Dan D. Jan 26 '12 at 16:09
@DanD.: Good point! Thanks. I updated my answer. –  Karolos Jan 26 '12 at 16:28