50

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?

Jorge Castro
  • 71,754
ppp
  • 846

3 Answers3

72

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.

10

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.

Rinzwind
  • 299,756
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.

marc41
  • 46