type command in Linux with Examples

The type command is used to describe how its argument would be translated if used as commands. It is also used to find out whether it is built-in or external binary file.

Syntax:

type [Options] command names

Example:



Options:

  • -a : This option is used to find out whether it is an alias, keyword or a function and it also displays the path of an executable, if available.

    Example:

    type -a pwd

  • -t : This option will display a single word as an output.
    • alias – if command is a shell alias
    • keyword – if command is a shell reserved word
    • builtin – if command is a shell builtin
    • function – if command is a shell function
    • file – if command is a disk file

    Example:

    type -t pwd
    type -t cp
    type -t ls
    type -t while
    

  • -p : This option displays the name of the disk file which would be executed by the shell. It will return nothing if the command is not a disk file.

    Example:

    type -p dash



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.