• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

Type Command in Linux with Examples

Written by Admin, Updated On June 21, 2020
terminal, type
Linux Type Command

The type command is used to show information about the command type and how its argument would be interpreted if typed on the command line. It is also used to find out whether it is built-in or external binary file. In this article, we will explain how to use the Linux type command.

How to Use the type Command#

Below is the basic syntax for thetype command:

type [OPTIONS] FILE_NAME...

For example, to find the type of the cd command, you would type the following:

type cd

It will show output as following:

cd is a shell builtin

You can pass the multiple arguments to the type command by space separated:

type sleep cd
sleep is /bin/sleep
cd is a shell builtin

Command Options#

Use the option -t with type to find out whether it is an alias, keyword or a function, it can be one of the following single word output:

  • alias
  • function
  • builtin
  • file
  • keyword

Following are the examples:

1. Alias

type -t grep

Here ls is aliased to ls --color=auto:

alias

2. Function

type -t rvm

rvm is a tool (function) for installing, managing, and working with multiple Ruby environments:

function

3. Builtin

type -t cd

cd is a shell builtin in Bash and other shells like Zsh and Ksh:

builtin

4. File

type -t cut

cut is an executable file:

builtin

5. Keyword

type -t while

while is a reserved word in Bash:

keyword

Display all locations that contain the command#

Option -a is used to display all matches and the path of an executable, if available.

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

In above output showing that pwd is shell builtin and it is also available as a standalone /bin/pwd executable.

Other type command options#

Use the -p option with to force type command to print the path to the command if the command is an executable file on the disk:

For example, the following command will not display any output because the pwd command is a shell builtin.

type -p pwd

The uppercase -P option tells type to search the PATH for an executable file on the disk even if the command is not file.

type -P pwd
pwd is /bin/pwd

Type command will not look up for shell functions when the -f option is used.

Conclusion#

The type command will show you information about specific command type and how it will interpreted if used on the command line.

If you have any questions or feedback, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article Ls Command in Linux (List Files and Directories)
Next Article   How to Install TeamViewer on Debian 10

Related Posts

  • How to Install SSH Keys on Ubuntu 22.04

    How to Set up SSH Keys on Ubuntu 22.04

    January 7, 2023
  • How to Install Fail2ban on Ubuntu 22.04

    How to Install and Configure Fail2ban on Ubuntu 22.04

    December 5, 2022
  • How to Enable SSH on Ubuntu 22.04

    How to Enable SSH on Ubuntu 22.04

    December 1, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook