githubEdit

rectangle-terminaltail

πŸ¦’ tail Command in Linux

The tail command is used to display the end of a file. It's useful for monitoring logs and large files.


🧰 Common Options

Option
Description

-n [lines]

Show the last [lines] lines (default is 10)

-f

Follow the file as it grows (useful for logs)

-c [bytes]

Show the last [bytes] bytes

-q

Suppress headers when multiple files are being tailed

-v

Show the header when multiple files are being tailed


πŸ“‹ Basic Syntax

tail [options] [file]

πŸ“ Common Commands

Show the Last 10 Lines (Default)

tail /path/to/file

Show the Last N Lines

Follow a File for Real-Time Updates

  • This is commonly used for monitoring log files in real time.

Show the Last N Bytes

Show Multiple Files at Once


πŸ’‘ Additional Tips

  • Using tail -f with multiple files: The -f option allows you to view real-time updates, which is great for log files or watching a file being written to.

  • Combining with grep: You can pipe the output of tail to grep to filter the results.

  • Use Ctrl + C to stop following the file when using tail -f.


Last updated