Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose I have an alias in the bash shell. Is there a simple command to print out what command the alias will run?

share|improve this question
up vote 172 down vote accepted

The type builtin is useful for this. It will not only tell you about aliases, but also functions, builtins, keywords and external commands.

$ type ls
ls is aliased to `ls --color=auto'
$ type rm
rm is /bin/rm
$ type cd
cd is a shell builtin
$ type psgrep
psgrep is a function
psgrep () 
    ps -ef | { 
        read -r;
        echo "$REPLY";
        grep --color=auto "$@"
share|improve this answer
what to do when an alias contains MORE aliases? – user251046 Jul 26 '14 at 10:34
@user251046 keep using type until you hit something other than an alias ... – geirha Sep 3 '14 at 19:03
@user251046 you hold a mirror up to the webcam – abalter Mar 1 at 19:55

Just type alias while at the Shell prompt. It should output a list of all currently-active aliases.

Or, you can type alias [command] to see what a specific alias is aliased to, as an example, if you wanted to find out what the ls alias was aliased to, you could do alias ls.

share|improve this answer
Or type alias ls to find out what specifically ls is aliased to. – poolie Feb 7 '12 at 4:10
@poolie Indeed. I think the question was to see all the aliases, though, which is why i did not elaborate further on the alias command. – Thomas Ward Feb 7 '12 at 4:52

I really like Ctrl+Alt+E as I learned from this answer. It "expands" the currently typed command line, meaning it performs alias expansion (amongst other things).

What does that mean? It turns any alias, that might be currently written on the command line, into what the alias stands for.

For example, if I type:

$ ls

and then press Ctrl+Alt+E, it is turned into

$ ls --time-style=locale --color=auto
share|improve this answer
have this an equivalent on other distros? – sepehr Jul 3 '14 at 13:40
@sepehr Works on Debian, I assume it's a bash feature and should work on any distribution. – Oliver Salzburg Jul 3 '14 at 16:15
you're right, it works on bash but I have zsh and it doesn't work unfortunately. – sepehr Jul 4 '14 at 12:46
was really helpful. I had a different goal of expanding one of the previous bash commands logged in history with, i.e., !394, so that I could edit it first before executing – XXL Mar 23 at 12:42

You could use the which command.

If you set an alias for ls as ls -al and then type which ls, you will see:

ls: aliased to ls -al.

share|improve this answer
bash has no which command. – geirha Sep 11 '14 at 9:34
Not working for me.. – Chiel ten Brinke Mar 15 at 13:34
Its working for me. thanks – Avenger Jun 15 at 6:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.