Find out if shell command is aliased or not

by nixcraft on May 1, 2006 · 0 comments

Q. Sometime I get confuges whether command is an alias or it is real command. How do I find out if shell command is aliased?

A: You need to use type command. It rells whether command is an alias, function, buitin command or executable command file.

For example:

$ type --all ls

Output:

ls is aliased to `ls --color=auto'
ls is /bin/ls

OR

$ type alias

alias is a shell builtin

So for each command, it indicate how it would be interpreted if used as a command name. You can also try out following options:

  • If the -t option is used, `type' outputs a single word which is one of alias, keyword, function, builtin, file etc
  • If the -p flag is used, `type' either returns the name of the disk file that would be executed, or nothing if `type -t NAME' would not return `file'.
  • If the -a flag is used, `type' displays all of the places that contain an executable named `file'. This includes aliases, builtins, and functions, if and only if the -p flag is not also used.
  • The -f flag suppresses shell function lookup.
  • The -P flag forces a PATH search for each NAME, even if it is an alias, builtin, or function, and returns the name of the disk file that that would be executed.

See also:

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 11 + 8 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.



Previous post:

Next post: