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

02 7903 0216

     

Open Ticket

    

Client Area

FASTDOT Web Hosting Australia

FASTDOT Web Hosting Australia

Australian Cloud Hosting

  • Web Design
    • eCommerce Development
    • Branding
    • Web Design
  • Domains
    • Register
    • Domain FAQ
    • Domain Extensions
    • MyDNS Manager
    • Domain Transfer
  • Hosting
    • WordPress Hosting
    • Sydney cPanel Hosting
    • Magento Hosting – eCommerce Website
    • eCommerce Options
      • Managed Magento Hosting
      • PrestaShop Hosting
      • OpenCart Hosting
      • CS-Cart Hosting
    • Business Emails
  • Cloud Servers
    • VMware ESXi Hypervisor
    • Equinix – ISO Certified Data Centres
    • Cloud Hosting Info
    • Virtual Machines
  • Resources
    • Partner Program
    • Transferring Websites
    • WordPress Tips
    • Email Tutorials
    • Hosting in Australia
    • Apps Galore
    • Tutorials & News
      • SEO
      • VMware VPS Cloud
      • PHP and MySQL
      • Security
      • Linux Guides
      • Server Management
Order Now
VMware Cloud Hosting

Australian Cloud Hosting

Solid Cloud Hosting for your Websites

Compare

September 14, 2012 by Editor

How to use the tail command in Linux

This tutorials shows you how to use the tail command in Linux. ‘tail’ is a command that is used to display the last few of lines from a given input. By default, it will will display the last 10 lines. The ‘tail’ command is useful for reading files where the relevant content is always appended to the end of the file such as logs.

Examples of using ‘tail’

tail /file/name.txt
The above example would list the last 10 (default) lines of the file /file/name.txt

tail /file/name.txt -n 100
The above example would list the last 100 lines in the file /file/name.txt. Change 100 to 50 to display the last 50 lines of the file.

tail -f /file/name.txt
This example displays the last 10 lines and then updates the file as new lines are being added. This is a great command to use to watch log files or logs in real-time.

tail -f /tmp/debug.log –retry
Sometimes, the file intended to tail may not be available when you run the tail command and it may get created later or the files becomes inaccessible . You can use the –retry option to keep on trying to open the file as in the above example. If the file is not available at the time, the following warning will be issued but the tail command will still be trying to open the file:
tail: warning: –retry is useful mainly when following by name
tail: cannot open `/tmp/log’ for reading: No such file or directory

tail -f access.log | grep 49.125.12.68
If you’re trying to view a file such as the Apache access log file that is updated freguently, you can pipe its output through the grep command to filter out only the content you want. In the above example, the access.log file is being watched for any IP addresses of 49.125.12.68

tail -c 5 /file/name.txt
Tail can also display any number of bytes from the end of a file rather than a desired number of lines. The bytes selected will include newline characters and therefore can span multiple lines. This is accomplished using the -c option followed by the number of bytes desired. In the above example the final five bytes of the file /file/name.txt will be printed.

To find information on the ‘grep’ command, please go to
https://fastdot.com.au/linux-tutorials/grep-command-linux/

More great articles

Keeping your Linux server up to date
Clearing a Blocked IP Address In the Firewall of Your VPS or Dedicated server
Check If Your Linux Server Is Vulnerable to Shellshock
How to use Screen for Linux

Category iconLinux Tutorials

Primary Sidebar

Recent Posts

  • How to Upload Files Using the cPanel File Manager?
  • How To Increase the PHP Max Upload Size in cPanel®?
  • Choosing a hosting platform in 2021
  • VARCHAR vs. TEXT for MySQL Databases
  • What Are the Best Shopify® Alternatives in 2021?
Check If Your Linux Server Is Vulnerable to Shellshock
Clearing a Blocked IP Address In the Firewall of Your VPS or Dedicated server
Backing up and restoring a MySQL database via SSH
Retaining Directory Permissions While Using SCP

Categories

  • Application Hosting
  • Australian Cloud Hosting
  • cPanel Hosting
  • DNS and Domains
  • eCommerce Hosting
  • Email Tutorials
  • Legals
  • Linux Tutorials
  • Operating Systems
  • PHP and MySQL
  • Register a Domain Name
  • Search Engine Optimization
  • Security
  • Server Management
  • Tutorials
  • VMware Cloud Hosting
  • Web Hosting Tutorials
  • WordPress Tips & Tricks
Australian web hosting

Footer

Recent Posts

  • How to Upload Files Using the cPanel File Manager?
  • How To Increase the PHP Max Upload Size in cPanel®?
  • Choosing a hosting platform in 2021
  • VARCHAR vs. TEXT for MySQL Databases
  • What Are the Best Shopify® Alternatives in 2021?

Legals

  • Terms&Conditions
  • SLA
  • Acceptable Usage Policies
  • Privacy Policies
  • About FASTDOT
  • ISO Certified

Contact

Australia: +61 02 7903 0216
Submit a Support Ticket

Company

FASTDOT.COM.AU PTY/LTD
ACN 002 454 631
200 Bourke Rd, Alexandria NSW 2015 Australia
Processing by eWay, PayPal and Bitcoin

blankNSW Government Provider

Made with in Sydney/Australia

Copyright © 2022 FASTDOT.COM

All rights reserved. Return to top