Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have set some aliases in my .bashrc file and for some reason one of them does not behave as expected.

Since I don't remember the exact command assigned to that alias, I would like to see the command to find out what's wrong.

Except the obvious opening the .bashrc file to see it, is there a command that just echos the command assigned to that alias?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

Instead of using grep, you can just type alias aliasname to see what an alias is set to.

For example, alias ls will return ls='ls --color=auto'.

Also take a look at the type and whence commands, which return more detailed information about utilities, including executable files in your path, shell built-ins, aliases, and shell functions.

share|improve this answer
    
Excellent :) I missed where TS said to know the alias name :) +1 –  Rinzwind Feb 13 '13 at 14:24

It is as simple as typing

alias

on command line. This will list ALL aliases so if you know specifics you can grep that like so ..

alias|grep rm 

to find commands that use rm where you can substitute rm for anything alias would show you to find that specific alias.

share|improve this answer
which rm

may be the most useful. Normally, it just shows the full path of executable as found in your $PATH. If there are multiple executables of that name, it shows the first one found (the one that would be executed). If there is an alias, it shows the alias in addition to the path.

whereis rm

can also help figure out things like this. While which shows the first instance found in $PATH, whereis shows them all.

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.