A couple of months ago, I made a few permanent aliases for my bash shell on Ubuntu 14.04. They are actively making my life easier, and I would like to add a couple more to the list, but I cannot find them. My .bashrc file does not actually contain any aliases, just the lines about running ~/.bash_aliases if it exists. And my ~/.bash_aliases file is completely blank.
- 29
3 Answers
Run man bash to see what files bash may be looking at.
They include .bash_profile, .bash_login, .profile,
and, if you went privileged, /etc/bash.bashrc and /etc/profile.
Or you could pick a word or a sequence of words from one of your existing aliases
(for example, qwerty aardvark42), and do
grep "qwerty aardvark42" ~/.*
grep "qwerty aardvark42" /etc/*
Bash reads one of two sets of files depending on how it was invoked. In your case, since you are almost certainly running interactive, non login shells, the possible locations of your aliases are:
~/.bashrc
~/.bash_aliases
/etc/bash.bashrc
Your aliases should be in one of those files. For next time, you can add this function to your ~/.bashrc which lets you easily look through all the files where a variable or an alias or similar might be found. This will work for all types of (bash) shell:
grep_bash(){
grep -H "$@" ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases \
/etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null
}
You can then search all those files for any given string by running
grep_bash foo
- 104,119