Ubuntu – How to find aliases

aliascommand lineshortcuts

Where can I find a list/file of all aliases created in Ubuntu 17.04?
I mean shortcuts for commands most frequently used and more.

Best Answer

List of defined aliases

Type alias, you'll get a list of all defined ones in your environment.

$ alias
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

List along the file they've been set in

To find the files that your aliases have been defined in, use this solution, with a little bit altering it:

$ PS4='+$BASH_SOURCE> ' BASH_XTRACEFD=7 bash -xl 7> /tmp/mylog
$ grep "alias " /tmp/mylog | grep -e /home -e /etc

Which gives you a list of files, stating what alias defined there, the output is similar to:

++/home/ravexina/.bashrc> alias 'la=ls -A'

Which states 'la=ls -A' has been set in my .bashrc.

Important files

There are many places that we can define our aliases, the most important ones might be:

  • Standard ones:
    • ~/.bashrc
    • ~/.bash_aliases
  • One of them in order:
    • ~/.bash_profile
    • ~/.bash_login
    • ~/.profile
  • Works but not a good place, unless you want it system wide:
    • /etc/bash.bashrc
    • /etc/profile

And any other place which get sourced while running a shell.

Related Question