{"id":3305,"date":"2014-06-12T18:23:41","date_gmt":"2014-06-12T18:23:41","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2014\/06\/12\/tail-command\/"},"modified":"2022-03-31T19:31:09","modified_gmt":"2022-03-31T23:31:09","slug":"tail-command","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/","title":{"rendered":"tail command"},"content":{"rendered":"<p>Much like the <a href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/head-command\/\"><em>head<\/em> command<\/a>, the <em>tail<\/em> command comes in handy when working with larger files. Instead of pulling the first 10 lines of a file, <em>tail<\/em> pulls the last 10 lines of a file when using the base command. It also takes numeric options to allow you to tailor the number of lines displayed.<\/p>\n<p><strong>Command: <\/strong>tail<br \/>\n<strong>Synopsis: <\/strong>tail [OPTION]&#8230; [FILE]&#8230;<\/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<tbody>\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 the last N bytes of the file.<\/td>\n<\/tr>\n<tr>\n<td>-f<\/td>\n<td>&#8211;follow[={name|descriptor}]<\/td>\n<td>Output appended data as the file grows; -f, &#8211;follow, and &#8211;follow=descriptor are equivalent. This means when running the command you will get the initial 10 lines and then the additional lines will appear as they are added to the file. This is particularly useful when following an active log file.<\/td>\n<\/tr>\n<tr>\n<td>-F<\/td>\n<td><\/td>\n<td>This is the same as using &#8211;follow=name &#8211;retry together.<\/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 starting at the end of the file.<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>&#8211;max-unchanged-stats=N<\/td>\n<td>With &#8211;follow=name, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files)<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>&#8211;pid=PID<\/td>\n<td>This option is used aling with -f. It terminates after process ID, PID dies.<\/td>\n<\/tr>\n<tr>\n<td>-q<\/td>\n<td>&#8211;quiet &#8211;silent<\/td>\n<td>Never output headers giving file names.<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>&#8211;retry<\/td>\n<td>Keeps trying to open a file even if it is inaccessible when tail starts or if it becomes inaccessible later; useful when following by name, i.e., with  &#8211;follow=name.<\/td>\n<\/tr>\n<tr>\n<td>-s<\/td>\n<td>&#8211;sleep-interval=S<\/td>\n<td>This option is used with -f. It sleeps for approximately S seconds (default 1.0) between iterations.<\/td>\n<\/tr>\n<tr>\n<td>-v<\/td>\n<td>&#8211;verbose<\/td>\n<td>Always output headers giving file names.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Examples<\/h2>\n<p><strong>tail<\/strong> &#8211; This example is the base command used on a file named text.txt.<\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">tail test.txt<\/span> 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. Donec commodo imperdiet porttitor. Vestibulum volutpat augue et odio rutrum, at fermentum ante aliquam. Quisque eleifend adipiscing est nec tincidunt.<\/pre>\n<p><strong>tail -c 300<\/strong> &#8211; In this example, we are listing the last 300 bytes of the test.txt file.<\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">tail -c 300 test.txt<\/span> sit amet malesuada elit lacus quis justo. Morbi auctor eu odio quis porta. Morbi lacus lectus, volutpat non pellentesque eu, gravida sed tortor. Donec commodo imperdiet porttitor. Vestibulum volutpat augue et odio rutrum, at fermentum ante aliquam.<\/pre>\n<p><strong>tail -n<\/strong> &#8211; Using the <em>-n<\/em> option allows you to specify how many lines you want to display. This example looks to display the last 3 lines from two different files (test.txt and test2.txt). Note that in this example a header is added before the outpur for each file.<\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">tail -n 3 test.txt test2.txt<\/span> ==&gt; test.txt &lt;== Donec commodo imperdiet porttitor. Vestibulum volutpat augue et odio rutrum, at fermentum ante aliquam. Quisque eleifend adipiscing est nec tincidunt. ==&gt; test2.txt &lt;== Donec commodo imperdiet porttitor. Vestibulum volutpat augue et odio rutrum, at fermentum ante aliquam. Quisque eleifend adipiscing est nec tincidunt.<\/pre>\n<p><strong>tail -q<\/strong> &#8211; The &#8216;quiet&#8217;, or <em>-q<\/em> option removes the header information that is displayed before the output of a file. Using the previous example where we printed out the last 3 lines of two files, we alter the command slightly by adding the &#8216;quiet&#8217; option.<\/p>\n<pre class=\"cli\"> # <span style=\"color:red\">tail -qn 3 test.txt test2.txt<\/span> Donec commodo imperdiet porttitor. Vestibulum volutpat augue et odio rutrum, at fermentum ante aliquam. Quisque eleifend adipiscing est nec tincidunt. Donec commodo imperdiet porttitor. Vestibulum volutpat augue et odio rutrum, at fermentum ante aliquam. Quisque eleifend adipiscing est nec tincidunt.r<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Much like the head command, the tail command comes in handy when working with larger files. Instead of pulling the first 10 lines of a file, tail pulls the last 10 lines of a file when using the base command. It also takes numeric options to allow you to tailor the number of lines displayed.<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-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-3305","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>tail command | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Learn how to use the Linux tail 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\/tail-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"tail command | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the Linux tail command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-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-12T18:23:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-31T23:31:09+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\/tail-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/\"},\"author\":{\"name\":\"Scott Mitchell\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\"},\"headline\":\"tail command\",\"datePublished\":\"2014-06-12T18:23:41+00:00\",\"dateModified\":\"2022-03-31T23:31:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/\"},\"wordCount\":425,\"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\/tail-command\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/\",\"name\":\"tail command | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2014-06-12T18:23:41+00:00\",\"dateModified\":\"2022-03-31T23:31:09+00:00\",\"description\":\"Learn how to use the Linux tail command.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"tail 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":"tail command | InMotion Hosting","description":"Learn how to use the Linux tail 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\/tail-command\/","og_locale":"en_US","og_type":"article","og_title":"tail command | InMotion Hosting","og_description":"Learn how to use the Linux tail command.","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2014-06-12T18:23:41+00:00","article_modified_time":"2022-03-31T23:31:09+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\/tail-command\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/"},"author":{"name":"Scott Mitchell","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed"},"headline":"tail command","datePublished":"2014-06-12T18:23:41+00:00","dateModified":"2022-03-31T23:31:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/"},"wordCount":425,"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\/tail-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/","name":"tail command | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2014-06-12T18:23:41+00:00","dateModified":"2022-03-31T23:31:09+00:00","description":"Learn how to use the Linux tail command.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/tail-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"tail 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\/3305","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=3305"}],"version-history":[{"count":1,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3305\/revisions"}],"predecessor-version":[{"id":95557,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3305\/revisions\/95557"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=3305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=3305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=3305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}