Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

Type Command in Linux with Examples - DesignLinux

Jun 21 2020
designlinux 0 Comments
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.

Related

Tags: terminal, type

How to Install TeamViewer on Debian 10

Prev Post

Find Large Files in Linux

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 75
  • 605,825

DesignLinux.com © All rights reserved

Go to mobile version