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.

There is a typo which causes an error message upon logon (someone typed lias instead of alias). I have checked /etc/bashrc as well as ~/.bashrc and /etc/profile as well as ~/.bash_profile for individual users, but none of these files contain the custom aliases for the system. What alternate files can contain system-wide aliases?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Glad you found it, but here's a way to see all login files figure in the general sense:

# run strace, see every syscall
strace -o /tmp/bash.out bash --login

(Exit from bash shell)

# filter out opens that returned a descriptor, then use sed to get the file
< /tmp/bash.out grep -o 'open("[^,]*,[^)]*)[ \t]=[ \t][0-9]' | sed -e 's/^[^"]*"//' -e  's/".*$//' | sort -u > /tmp/openedfiles.txt

# grep for the broken alias, or whatever
< /tmp/openedfiles.txt xargs grep '^[ \t]*lias'

strace is one of those commands that can be magic if you know how to use it.

share|improve this answer
    
thanks, very useful! –  Shouvik Sayef May 5 '13 at 16:44
    
@ShouvikSayef this "run something under strace, see all the open files" works in a tremendous number of contexts. It's not a bad tool to have around. I have the filter (grep/sed) as a shell script to make it easier to invoke this pattern. –  Rich Homolka May 6 '13 at 2:54

found it: /etc/profile.d/useralias.sh

share|improve this answer

And for the quick and dirty crowd, I would have...

grep ^lias ~/.* ; grep ^lias /etc/* /etc/*/*

and if that didn't point me the right way, I'd have resorted to...

grep alias ~/.* > /tmp/alias.txt ; grep alias /etc/* /etc/*/* >> /tmp/alias.txt ; less /tmp/alias.txt and proofread all alias lines.

share|improve this answer

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.