{"id":8172,"date":"2018-12-11T18:45:39","date_gmt":"2018-12-11T15:45:39","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-type-command\/"},"modified":"2018-12-11T18:45:39","modified_gmt":"2018-12-11T15:45:39","slug":"%d8%a2%d9%85%d9%88%d8%b2%d8%b4-%d8%af%d8%b3%d8%aa%d9%88%d8%b1-type-%d8%af%d8%b1-shell","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/%d8%a2%d9%85%d9%88%d8%b2%d8%b4-%d8%af%d8%b3%d8%aa%d9%88%d8%b1-type-%d8%af%d8%b1-shell\/","title":{"rendered":"\u0622\u0645\u0648\u0632\u0634 \u062f\u0633\u062a\u0648\u0631 type \u062f\u0631 shell"},"content":{"rendered":"<p dir=\"ltr\" style=\"text-align: left;\">On the Linux command line, you&#8217;ll come across several types of utilities. Some are an alias, while others are built-in tools and even functions. So, how do you check these types? Well, there exists a command &#8216;<strong>type<\/strong>&#8216; that offers you this information. In this tutorial, we will discuss the &#8216;type&#8217; command using some easy to understand examples.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">But before we do that, it&#8217;s worth mentioning that all examples here have been tested on an Ubuntu 18.04 LTS machine.<\/p>\n<h2 id=\"linux-type-command\" dir=\"ltr\" style=\"text-align: left;\">Linux type command<\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">As already mentioned in the introduction above, the type command in Linux displays information about command type. Following is its syntax:<\/p>\n<pre dir=\"ltr\"><code spellcheck=\"false\">type [-afptP] name [name ...]<\/code><\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\">And here are some Q&amp;A-styled examples that should give you a better idea on how the type command works.<\/p>\n<h2 id=\"q-how-to-use-type-command\" dir=\"ltr\" style=\"text-align: left;\">Q1. How to use type command?<\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">It&#8217;s simple, just execute &#8216;type&#8217; with the command line tool name as input and -t as the command line option. For example,<\/p>\n<pre class=\"command\" dir=\"ltr\"><code spellcheck=\"false\">type -t cp<\/code><\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\">This command produced the following output:<\/p>\n<pre dir=\"ltr\"><code spellcheck=\"false\">file<\/code><\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\">Similarly, if the tool name is an alias, then the type command clearly tells that. For example, the following command:<\/p>\n<pre class=\"command\" dir=\"ltr\"><code spellcheck=\"false\">type -t ls<\/code><\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\">produced this output:<\/p>\n<pre dir=\"ltr\"><code spellcheck=\"false\">alias<\/code><\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\">Here&#8217;s how the tool&#8217;s man page explains the -t option:<\/p>\n<pre dir=\"ltr\">-t\toutput a single word which is one of `alias', `keyword',\n `function', `builtin', `file' or `', if NAME is an alias, shell\n reserved word, shell function, shell builtin, disk file, or not\n found, respectively<\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\">For this, execute the type command sans any option. Here&#8217;s an example:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"><a id=\"img-type-basic-usage\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/type-basic-usage.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/12\/linux-type-command-tutorial-for-beginners-with-examples.png\" alt=\"How to make type print location of tools\" width=\"258\" height=\"73\" title=\"\"><\/a><\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">Use the -a command line option for this. Here&#8217;s an example:<\/p>\n<pre class=\"command\" dir=\"ltr\"><code spellcheck=\"false\">type -a ls<\/code><\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\">This command produced the following output on my system:<\/p>\n<pre dir=\"ltr\"><code spellcheck=\"false\">ls is aliased to `ls --color=auto'\nls is \/bin\/ls<\/code><\/pre>\n<h2 id=\"q-how-to-make-type-search-even-if-input-is-an-alias\" dir=\"ltr\" style=\"text-align: left;\">Q4. How to make type search even if input is an alias?<\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">By default, if you input an alias (like &#8216;ls&#8217; on some systems), the type command doesn&#8217;t produce location in output. For example:<\/p>\n<pre class=\"command\" dir=\"ltr\"><code spellcheck=\"false\">type ls<\/code><\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\">Here&#8217;s the output:<\/p>\n<pre dir=\"ltr\"><code spellcheck=\"false\">ls is aliased to `ls --color=auto'<\/code><\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\">However, if you want, you can force &#8216;type&#8217; to search for location even if the input is an alias. This can be done using the -P command line option.<\/p>\n<pre dir=\"ltr\">-P force a PATH search for each NAME, even if it is an alias,\n builtin, or function, and returns the name of the disk file\n that would be executed<\/pre>\n<p dir=\"ltr\" style=\"text-align: left;\"><a id=\"img-type-P-option\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/type-P-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/12\/linux-type-command-tutorial-for-beginners-with-examples-2.png\" alt=\"How to make type search even if input is an alias\" width=\"309\" height=\"75\" title=\"\"><\/a><\/p>\n<h2 id=\"conclusion\" dir=\"ltr\" style=\"text-align: left;\">Conclusion<\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">The type command doesn&#8217;t have a steep learning curve. Many of the options it provides we&#8217;ve discussed in this tutorial. Once you&#8217;re done testing these, head to the &#8216;type&#8217; command\u00a0man page to learn more about it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On the Linux command line, you&#8217;ll come across several types of utilities. Some are an alias, while others are built-in tools and even functions. So, how do you check these types? Well, there exists a command &#8216;type&#8216; that offers you this information. In this tutorial, we will discuss the &#8216;type&#8217; command using some easy to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-8172","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/8172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=8172"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/8172\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=8172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=8172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=8172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}