1

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.

Dareleth
  • 29
  • 1

3 Answers3

1

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
1

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
terdon
  • 100,812
-3

The file /etc/skel/.bashrc contains the original .bashrc

Harris
  • 2,598