Facebook Twitter Instagram
    Facebook Twitter Instagram
    Techtown
    • General
    • Linux
      • Linux Commands
      • Debian
      • Ubuntu
      • Linux Mint
      • Centos
      • OpenSUSE
      • Fedora
    • Text Editors
      • Notepad++
      • Sublime Text
    • Resources
      • Books
    • Write for Us
    Techtown
    Home » How to use type command (display information about command) in Linux
    Linux

    How to use type command (display information about command) in Linux

    By SandiSeptember 20, 2021Updated:September 20, 2021No Comments3 Mins Read
    Share
    Facebook Twitter LinkedIn Pinterest Email

    TYPE is a Linux command which helps to identify the type of the input command if it is an alias, built-in, function, or keyword. You can also pass multiple commands as the input parameters.

    All the arguments to this command are optional.

    The basic syntax is shown below.

     type [-afptP] name [name ...]

    Here,

    [afptP] 

    -a - display all locations containing an executable named NAME; includes aliases, builtins, and functions, if and only if the '-p' option is not also used
    -f - suppress shell function lookup
    -P - force a PATH search for each NAME, even if it is an alias, builtin, or function, and returns the name of the disk file that would be executed
    -p - returns either the name of the disk file that would be executed or nothing if `type -t NAME' would not return `file'.
    -t - output a single word which is one of `alias', `keyword', `function', `builtin', `file' or `', if NAME is an alias, shell reserved word, shell function, shell builtin, disk file, or not found, respectively
    
    

    Name – Command name to be interpreted.

    Exit Status – Returns success if all of the NAMEs are found; fails if any are not found.

    How to Use Type Command

    In Linux, Unix, and Unix-alike system command may an alias, shell built-in, file, function, or keyword. So how to find the type of command you are running on the shell.

    Consider pwd command, is it shell built-in or function?

    The shell provides a unique command type to find out this. Open the Linux terminal and run the command as shown below.

    $ type -a pwd
    pwd is a shell builtin

    The output tells us that pwd is shell built-in.

    What about the ls command?

    type ls
    ls is aliased to `ls --color=auto'

    ls is an alias.

    The type itself is a shell built-in. You can find this by running on itself.

    $ type type
    type is a shell builtin

    Type Command Examples

    Now, here we will cover all options along with Examples,

    1. -a option displays all locations containing an executable named NAME along with its type.

    $ type -a pwd
    pwd is a shell builtin
    pwd is /bin/pwd

    You can also pass multiple names of the command as input to this command.

    $ type -a pwd wc
    pwd is a shell builtin
    pwd is /bin/pwd
    wc is /usr/bin/wc
    wc is /usr/bin/wc

    2. -f  option suppresses the shell function lookup.

    $ type -f pwd
    pwd is a shell builtin

    3. -p returns the name of the disk file that would be executed along with the complete path for alias, built-in, or function.

    $ type -p wc
    /usr/bin/wc

    4. -t option simply returns type like builtin, function, alias, etc

    $ type -t pwd
    builtin

    Summary

    So, we covered the basic working of the Linux Type command with examples. At any point of time, if you want help, just run man or help type on the terminal.

    Refer to this online manual for the command.

    linux commands unix commands
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleLinux Sleep Command – delay for a specified amount of time
    Next Article How to Install VLC in Ubuntu 18.04 Bionic Beaver [All Methods Covered]
    Sandi
    • Website
    • Twitter

    I am Oracle Certified Associate(OCA) working in Oracle Domain since last 15 Years. Started this blog to share knowledge about different Technologies mostly focussing on Oracle.

    Related Posts

    How to Set the Time zone in Debian 11

    May 25, 2022

    How to Open a Terminal in Linux Mint

    May 24, 2022

    How to Restart Ubuntu From the Terminal

    May 23, 2022
    Add A Comment

    Comments are closed.

    Recent Posts
    • How to Set the Time zone in Debian 11
    • How to Open a Terminal in Linux Mint
    • How to Restart Ubuntu From the Terminal
    • How to Install Zoom on openSUSE
    • How to Install xArchiver on Debian 11
    Affiliate Disclosure
    This website contains Affiliate Links. We get small commission for purchases made through affiliate links (at no extra cost to you)
    Facebook Twitter Instagram Pinterest
    • Debian
    • Ubuntu
    • Mint
    • Fedora
    • CentOS
    • openSUSE
    • Chrome
    • XAMPP
    • Forums
    • Notepad++
    • Privacy Policy
    • About Me
    © 2022 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.