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
- 1
-
Also How you made permanent aliases (by editing which file) a couple of month ago? – Pandya Sep 11 '14 at 06:09
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/*
-
None of
.profile
,.bash_profile
or.bash_login
will be relevant here. Those are only read by login shells, not the normal interactive ones you run when using a terminal. – terdon Sep 13 '14 at 12:32
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

- 100,812
The file /etc/skel/.bashrc
contains the original .bashrc

- 2,598
-
How you will find location of permanent aliases by knowing this fact? – Radu Rădeanu Sep 11 '14 at 12:25
-
-
-
That file is only used when creating a new user to copy their default
.bashrc
file. It does not affect any running shells at all. – terdon Sep 13 '14 at 12:40