• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
sharadchhetri.com

sharadchhetri.com

Linux,Cloud Computing And DevOps

  • Home
  • Linux
  • CloudComputing
    • Introduction Cloud Computing
    • Amazon AWS
  • Free E-Books
  • About Me

type command : display information about command type on Linux

April 4, 2014 by Sharad Chhetri Leave a Comment

In Linux system, type command is used for displaying information about command type. 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.

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 ...]

Description:

-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.

Do'nt be greedy, share the knowledge!

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)

Related

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

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

Help To Needy

If you like our posts and tutorials, please support/donate to ANY “Open Source Project” or do some Charity work. Hope this will make someone happy in this world. Drop me an email if you want to inspire others!

Thank You!

Follow Us

  • Facebook
  • Twitter
  • GitHub
  • YouTube

Subscribe to Blog via Email

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

Top Posts & Pages

  • How to delete mail queue in Postfix
  • How to start / stop / restart / reload iptables on CentOS 7 / RHEL 7
  • How to find absolute path of command on Linux / Unix : which command
  • How to fix read only USB pen drive in Ubuntu
  • How to set hostname and FQDN on CentOS 7 and RHEL 7
  • Install KVM on Ubuntu 14.04 LTS Desktop
  • How to zip the directory in linux with command line
  • 4 different commands to check the load average in linux
  • How to install XAMPP on CentOS/RHEL 6.5
  • CentOS 7 / RHEL 7 : change OpenSSH port number ( SELINUX enabled )

Recent Posts

  • Install and setup maven in Linux for Jenkins
  • How to setup Jenkins Credentials for Git repo access
  • How to manage Jenkins Credentials
  • Managing Jenkins plugins from command line and GUI
  • How to create Jenkins user by command line and GUI

Footer

Sharad Chhetri is an experienced Linux - Cloud Engineer & freelancer. Working on Open Source Technology since RHEL 4.0 (Red Hat Enterprise Linux). He loves sharing the knowledge which earned from real scenarios. Don't be surprised if you find him in technology seminars and meetup groups. You can contact him on email for freelance projects at admin@sharadchhetri.com. Read More…

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Our GitHub Repo

sharadchhetri @ GitHub
  • java-samples
    Java Sample Project For Tutorial
    December 25, 2018 - 2:29 pm UTC
  • misc
    OpenSSH rpm created from tar ball
    November 21, 2018 - 3:12 am UTC
  • scripts
    Cassandra Backup Script
    November 21, 2018 - 3:09 am UTC
  • packer
    Packer : Create server images in automated way
    November 21, 2018 - 3:08 am UTC
  • Nagios
    My Nagios custom plugins
    November 21, 2018 - 3:07 am UTC

Recent Comments

  • Sharad Chhetri on CentOS 7 / RHEL 7 : change OpenSSH port number ( SELINUX enabled )
  • Dave on CentOS 7 / RHEL 7 : change OpenSSH port number ( SELINUX enabled )
  • Prafulla S on Install Shotcut on Ubuntu 16.04 LTS desktop
  • Sujata on Install Telnet Server on CentOS 7 / RHEL 7
  • kishen sharma on How to install redis server on CentOS 7 / RHEL 7
  • Sharad Chhetri on Secondary Logging : save all users history command output as log
  • Anand on Secondary Logging : save all users history command output as log
  • Sharad Chhetri on Install redis 3.0 from source on Ubuntu 14.04 / CentOS 7 / RHEL 7

Copyright © 2009 - 2019 · All Rights Reserved sharadchhetri.com · · Privacy Policy ·
· sitemap.xml · ·The content is copyrighted to sharadchhetri.com and may not be reproduced on other websites without our permission. ·