Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

3 Answers

up vote 9 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
That is just awesome! – Casebash Feb 12 '12 at 10:36

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

share|improve this answer
3  
Or type alias ls to find out what specifically ls is aliased to. – poolie Feb 7 '12 at 4:10
1  
@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. – The Lord of Time 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

Your Answer

 
discard

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.