An alias on Linux allows a user to reference one command (usually a longer or more cumbersome command) to another (usually a shorter version of the command which is easier to type). This saves users a few keystrokes on the command line, or can also compensate for common typos. In this tutorial, you will learn how to list all the aliases that have been configured on a Linux system.
In this tutorial you will learn:
- How to list all aliases on Linux
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to list all aliases on Linux
You can use the following command to list all aliases currently configured on your system:
$ alias -p
All of the aliases will be listed one per line, as you can see in the screenshot below.
The screenshot above shows the default aliases that were configured on a fresh Ubuntu install. Therefore it is worth noting that usually a Linux distro will come with a handful of aliases preconfigured. These can be viewed or edited in the user’s
You can get more help with creating aliases by reading our tutorial on the alias Linux command.
An alternative way to view all of the aliases on your system is with the
$ compgen -a
As you can see above, the output from
compgen is not as helpful, since it does not show what commands the aliases are configured to reference. Still, it could prove handy as an alternative method in some situations.