39

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?

0
57

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.

2
  • Excellent :) I missed where TS said to know the alias name :) +1
    – Rinzwind
    Feb 13 '13 at 14:24
  • Remember to surround your alias name with quotes, otherwise it might not work.
    – Matan
    Aug 24 '18 at 17:55
9

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.

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

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