Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I recently installed an Arch-Linux System. If I type

echo $PATH

it points (among others) to a directory inside my /home/user/dir I can remember I set up somewhere. I have it as root user also, so it cannot be in ~/.bashrc and isn't as well in /root/.bashrc. I looked also inside /etc/profile and /etc/bash.bashrc but couldn't find it there, too.

Is there a way to find where it is set?

share|improve this question
    
How are you logging in as root to get the same PATH? Even if you log in from the console, inheriting nothing from another user session? –  Daniel Beck Jul 1 '12 at 20:12
    
yes, even if I log in via tty1 as root or at run-level 3. I guess theres no user-session inside run-level 3?! –  Rafael T Jul 1 '12 at 20:17

3 Answers 3

up vote 3 down vote accepted

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=" /
share|improve this answer

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

share|improve this answer
    
no, but did it now, and still no luck –  Rafael T Jul 1 '12 at 20:32

@Dennis points me to a nice idea! I searched inside my /etc and found it, but with another command, as his command is only searching for filenames (as far as I understand).

The one I used succesful was

find / -type f -exec grep -i /home/user/dir '{}' \; -print
share|improve this answer
1  
My command would have worked as well. The only difference is the -i switch, which should be unnecessary since the path is case sensitive. grep -r recursively searches the contents of all files in the specified folder. –  Dennis Jul 1 '12 at 23:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.