• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

type Command : Display Information About Command Type On Linux

April 4, 2014 by Sharad Chhetri Leave a Comment

In this post we are explaining about type command with examples. In Linux system, type command is used for displaying information about command types. It displays if command is an alias,shell function, shell builtin, disk file, or shell reserved word.

You can use type command with other command names also.

With the help of type command you can also identify about command if it is Internal or External command.

Note: The type command will show output only when the command/executable name is available or installed in Linux System.

SYNOPSIS

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

Try the type command without giving any argument and try to see the result. For example let’s try on cd command

user1@server01:~$ type cd
cd is a shell builtin
user1@server01:~$

As per the output in above section, it confirms the cd command is Internal command (or in other words, shell builtin command)

Description Of type Command

-t option :
It will show a single word or string.It tells a command or name is an alias, shell reserved word, function, builtin, or disk file(external command).
In case command is not found, nothing will be printed as output.When we check exit status of command, it will be false.

Example :

root@tuxworld:~# type -t ls
alias
root@tuxworld:~# 
root@tuxworld:~# type -t date
file
root@tuxworld:~# 
root@tuxworld:~# type -t declare
builtin
root@tuxworld:~# 
root@tuxworld:~# type -t rvm
function
root@tuxworld:~# 

-p option :
The command of the disk file that would be executed. In other words, absolute path of command.

Example:

root@tuxworld:~# type -p date
/bin/date
root@tuxworld:~# 

-P option :
Force a PATH search for each command/NAME, even if it is an alias,builtin, or function, and returns the name of the disk file that would be executed.
(We can get PATH environment value by using command echo $PATH)

NOTE: In below example, date command was searched in all directories listed in PATH(Environment set). And found the date command in /bin

root@tuxworld:~# type -P date
/bin/date
root@tuxworld:~# 
root@tuxworld:~# echo $PATH
/usr/local/rvm/gems/ruby-2.1.0/bin:/usr/local/rvm/gems/ruby-2.1.0@global/bin:/usr/local/rvm/rubies/ruby-2.1.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/rvm/bin
root@tuxworld:~# 

-a option :
It display all locations have command or NAME .
It includes aliases, builtins, and functions (only in case , if -p option is not used )

Example :

root@tuxworld:~# type -a echo
echo is a shell builtin
echo is /usr/sbin/echo
echo is /bin/echo
root@tuxworld:~#

-f option :
The -f option,suppress shell function lookup.

Example.

type -f rvm

Note: rvm command is a user defined function.(what is rvm? Read More) When we use type -a rvm,the output will show functions defined. In above example, -f option will suppress the function.

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. sed command to display text between two strings or keywords
  2. cat,sed and awk commands to display file contents
  3. In ESX , passwd: authentication information cannot be recovered
  4. This XML file does not appear to have any style information associated with it, RSS Feed problem(wordpress)
  5. How To Find Absolute Full Path Of Command On Linux / Unix : which command
  6. How to hide php version information in header
  7. error: Could not get shadow information for root
  8. Linux: Set user password by using encrypted password in command
  9. 6 important examples of cd command on Linux and Unix Systems
  10. Head command in Linux / Unix

Filed Under: Linux, Linux Commands Tagged With: linux command

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

Linux / Unix : whoami command use and advantage

Search keyword in all available man pages – man command

cat,sed and awk commands to display file contents

Install lxml by using pip command on Ubuntu 14.04 LTS

How to rename and move the directory and files in linux

Unix / Linux : How to print duplicate lines from file

How to install libxml2 and libxslt packages on CentOS 6.5

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

Install libjpegtran by using yum command in CentOS 6.x

How to put slider shortcode only in home page in WordPress

Keep logs of user after sudo su – : Secondary Logging

Print double hyphen sign simultaneously in post of Octopress

How to configure ethernet in CentOS 6 after installing in Virtual Box

master admin password openerp 7.x

How to convert float to integer number

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy