How to find aliases?
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.
Solution 1:
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.
Solution 2:
Aliases are defined on a per-user, per-shell basis. You can see what aliases are defined for your current shells via
alias
Read more about aliases in man bash
.
Solution 3:
I might also throw in that the .bashrc
for new users (not existing) is populated from /etc/skel/.bashrc
, inside which you'll find aliases for things like ll
, la
, l
, etc. So if you want every new user to have more/less/different aliases that's the place to modify them