Find out where $PATH is defined

Solution 1:

Try searching for the directory in all files in /etc:

sudo grep -r "/home/user/dir" /etc

The -r switch makes grep search for /home/user/dir in the contents of all files in /etc and its subdirectories.

From grep(1) - Linux man page:

-d ACTION, --directories=ACTION

If an input file is a directory, use ACTION to process it. By default, ACTION is read, which means that directories are read just as if they were ordinary files. If ACTION is skip, directories are silently skipped. If ACTION is recurse, grep reads all files under each directory, recursively; this is equivalent to the -r option.

If that fails, you could simply extend the search to all files:

sudo grep -r "/home/user/dir" /

Or you could search for all files that modify the PATH variable:

sudo grep -r "PATH=" /

Solution 2:

It's usually a bad idea to put user directories in the global path as root ;) Did you check the /etc/environment file?