Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I had a ton of aliases defined and I use them all the time. I have a terminal session open now in which all the aliases are valid and working. However, the .bash_aliases file in which they were defined has been deleted. How can I expand or recover my aliases from my terminal session?

share|improve this question
up vote 20 down vote accepted

Simply use the command alias which prints out all definitions in a format bash can read in again:

$ alias
alias second='again'
alias test='hello'

So to recover, simply use

$ alias > .bash_aliases
share|improve this answer
Will this escape everything correctly? – gerrit Mar 1 '13 at 20:59
Do you have something special in mind? For example no problem with alias weired='echo \\$hello'. – mpy Mar 1 '13 at 21:03

Your Answer


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.