{"id":3289,"date":"2014-06-10T21:16:48","date_gmt":"2014-06-10T21:16:48","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2014\/06\/10\/head-command\/"},"modified":"2014-06-10T21:16:48","modified_gmt":"2014-06-10T21:16:48","slug":"head-command","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/","title":{"rendered":"head command"},"content":{"rendered":"<p>If you are working with large files and want to see the first few lines of it, you can use the <em>head<\/em> command. The base command will display the first ten lines of the file. The command can also take numeric options to adjust the numberof lines displayed.<\/p>\n<p><strong>Command: <\/strong>head<br \/> <strong>Synopsis: <\/strong>head [OPTION] [FILE] <\/p>\n<div class=\"alert\">Note that all mandatory arguments used by the long option command is also required by the short option.<\/div>\n<p> <strong>Options: <\/strong> <\/p>\n<table class=\"article_table\">\n<tr>\n<th>Option<\/th>\n<th>Long name<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>-c<\/td>\n<td>&#8211;bytes=[-]N<\/td>\n<td>This option displays N bytes of the file. Using -N will print all but the last N bytes of the file.<\/td>\n<\/tr>\n<tr>\n<td>-n<\/td>\n<td>&#8211;lines=[-]N<\/td>\n<td>This option displays N lines of the file. Using -N will print all but the last N lines of the file.<\/td>\n<\/tr>\n<tr>\n<td>-q<\/td>\n<td>&#8211;quiet &#8211;silent<\/td>\n<td>Does not print out headers giving file names.<\/td>\n<\/tr>\n<tr>\n<td>-v<\/td>\n<td>&#8211;verbose<\/td>\n<td>Always prints headers giving file names.<\/td>\n<\/tr>\n<\/table>\n<h2>Examples<\/h2>\n<p>Below are a few examples of using the <em>cd<\/em> command. You can confirm your loction after running your <em>cd<\/em> command by using the <em>pwd<\/em> command.<\/p>\n<p><strong>head -c N<\/strong> &#8211; This command displays the first N bytes of the file. N is the number of bytes you want to display. Below we display the first 100 bytes of a file named test.txt. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">head -c 100 test.txt<\/span> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla pellentesque mattis porta. Ut non qua <\/pre>\n<\/p>\n<p><strong>head -n N<\/strong> &#8211; This command and option will display the first N lines of the file. Replace N with the actual number of lines you want to view. This example shows how to display the first 3 lines of a file. Blank lines are included in the number displayed. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">head -n 3 test.txt<\/span> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla pellentesque mattis porta. Ut non quam lorem.   Donec bibendum dolor nec sodales molestie. Aenean ullamcorper iaculis enim eu feugiat. <\/pre>\n<\/p>\n<p><strong>head -q<\/strong> &#8211; This command option combination forces the file to not display the header information. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">head -q test.txt<\/span> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla pellentesque mattis porta. Ut non quam lorem. Donec bibendum dolor nec sodales molestie. Aenean ullamcorper iaculis enim eu feugiat. Integer tincidunt nunc sit amet nulla commodo, ut tristique ipsum aliquam. Curabitur malesuada massa in tristique eleifend. Nulla non purus fermentum urna ullamcorper tempor. Nulla quis luctus sapien, non congue enim. Vestibulum aliquam bibendum ipsum, a sollicitudin nisi lacinia in. Nulla sed neque varius velit rutrum dignissim at in purus. Mauris nec fermentum metus. Sed vitae porta urna. Duis eget enim et odio consequat egestas in et massa. Curabitur vel justo posuere, consectetur nisl vel, ultrices nunc. In eget lacinia mi.  Etiam libero purus, euismod eu est a, aliquet vestibulum risus. Proin tempor, lacus eu porttitor ornare, nunc massa posuere nisl, sit amet malesuada elit lacus quis justo. Morbi auctor eu odio quis porta. Morbi lacus lectus, volutpat non pellentesque eu, gravida sed tortor. <\/pre>\n<\/p>\n<p><strong>head -v<\/strong> &#8211; The opposite of the -q (quiet) option, the verbose option always forces the header information to display. <\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">head -v test.txt<\/span> ==&gt; test.txt &lt;== Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla pellentesque mattis porta. Ut non quam lorem. Donec bibendum dolor nec sodales molestie. Aenean ullamcorper iaculis enim eu feugiat. Integer tincidunt nunc sit amet nulla commodo, ut tristique ipsum aliquam. Curabitur malesuada massa in tristique eleifend. Nulla non purus fermentum urna ullamcorper tempor. Nulla quis luctus sapien, non congue enim. Vestibulum aliquam bibendum ipsum, a sollicitudin nisi lacinia in. Nulla sed neque varius velit rutrum dignissim at in purus. Mauris nec fermentum metus. Sed vitae porta urna. Duis eget enim et odio consequat egestas in et massa. Curabitur vel justo posuere, consectetur nisl vel, ultrices nunc. In eget lacinia mi.  Etiam libero purus, euismod eu est a, aliquet vestibulum risus. Proin tempor, lacus eu porttitor ornare, nunc massa posuere nisl, sit amet malesuada elit lacus quis justo. Morbi auctor eu odio quis porta. Morbi lacus lectus, volutpat non pellentesque eu, gravida sed tortor. <\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are working with large files and want to see the first few lines of it, you can use the head command. The base command will display the first ten lines of the file. The command can also take numeric options to adjust the numberof lines displayed. Command: head Synopsis: head [OPTION] [FILE] Note<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/\"> Read More ><\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4308],"tags":[],"class_list":["post-3289","post","type-post","status-publish","format-standard","hentry","category-linux"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>head command | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Learn how to use the Linux head command.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"head command | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the Linux head command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-06-10T21:16:48+00:00\" \/>\n<meta name=\"author\" content=\"Scott Mitchell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Scott Mitchell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/\"},\"author\":{\"name\":\"Scott Mitchell\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\"},\"headline\":\"head command\",\"datePublished\":\"2014-06-10T21:16:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/\"},\"wordCount\":295,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/\",\"name\":\"head command | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2014-06-10T21:16:48+00:00\",\"description\":\"Learn how to use the Linux head command.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"head command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\",\"name\":\"Scott Mitchell\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"head command | InMotion Hosting","description":"Learn how to use the Linux head command.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/","og_locale":"en_US","og_type":"article","og_title":"head command | InMotion Hosting","og_description":"Learn how to use the Linux head command.","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2014-06-10T21:16:48+00:00","author":"Scott Mitchell","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Scott Mitchell","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/"},"author":{"name":"Scott Mitchell","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed"},"headline":"head command","datePublished":"2014-06-10T21:16:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/"},"wordCount":295,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/","name":"head command | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2014-06-10T21:16:48+00:00","description":"Learn how to use the Linux head command.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"head command"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed","name":"Scott Mitchell","url":"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=3289"}],"version-history":[{"count":0,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3289\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=3289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=3289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=3289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}