How to list all aliases on Linux

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
How to list all aliases on Linux
How to list all aliases on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to list all aliases on Linux



Twitter icon Follow LinuxConfig.org on Twitter for the latest tips and tricks about 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.

All of the aliases configured on our system
All of the aliases configured on our system

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 ~/.bashrc file.

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 command.

$ compgen -a
Listing aliases with the compgen command
Listing aliases with the compgen command

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.



Comments and Discussions
Linux Forum