Linux Command to Display All Aliases | LFCS Exam Simulation

Displaying All Aliases in the Current Shell

Question

SIMULATION -

What command displays all aliases defined in the current shell? (Specify the command without any path information)

Explanations

alias -or- alias -p

The command to display all aliases defined in the current shell is:

bash
alias

This command without any arguments will list all the aliases defined in the current shell session. An alias is a shortcut for a command or a set of commands. When an alias is defined, you can use the alias instead of typing the full command. For example, you can define an alias for the ls command to always include the -l option:

bash
alias ll='ls -l'

Now, you can use the ll alias instead of typing ls -l every time:

diff
$ ll total 0 -rw-r--r-- 1 user user 0 Mar 13 20:49 file1 -rw-r--r-- 1 user user 0 Mar 13 20:49 file2

Note that aliases are only defined for the current shell session. If you open a new terminal window, you will need to redefine the aliases. Also, aliases are not available in shell scripts, so you will need to use the full command in a script.