Skip to content
Linuxinfra.com
Menu
  • Home
  • Linux Security
  • Linux Administration
    • Linux History
    • Why Linux is Better?
    • What Are Linux Distributions?
    • Linux kernel and shell
    • Processes in Linux/Unix
    • Linux Basic Commands
  • Cyber Security
    • PCI DSS
      • Module 1: Introduction to PCI DSS
      • Module 2: PCI DSS Requirements Overview
      • Module 3: Scope of PCI DSS Compliance
      • Module 4: Risk Management and Vulnerability Assessments
      • Module 5: Implementing and Maintaining PCI DSS
      • Module 6: Compliance Validation and Reporting
      • Module 7: Best Practices and Case Studies for PCI DSS
      • Module 8: Updates and Future of PCI DSS
Menu
head command

Understanding the head Command: Viewing the Start of Files in Linux

Posted on August 26, 2024

The head command in Linux is used to display the beginning of a file, typically the first 10 lines. It is especially useful for quickly viewing the contents of large files without opening the entire file. By default, head shows the first 10 lines, but this can be adjusted using various options.

Basic Syntax:

head [OPTION]… [FILE]…

Common Options:

  1. -n NUMBER or --lines=NUMBER: Display the first NUMBER lines instead of the default 10.
  2. -c NUMBER or --bytes=NUMBER: Display the first NUMBER bytes.
  3. -q or --quiet: Never print headers giving file names.
  4. -v or --verbose: Always print headers giving file names.
  5. -z or --zero-terminated: Line delimiter is NUL, not newline.

Examples:

  1. Display the first 10 lines of a file (default behavior)

2. Display the first 50 bytes of a file:

3. Display the first lines of multiple files:

Practical Uses:

  • Quickly peek at the beginning of large files
  • View file headers or initial content
  • Limit output of other commands when piped
  • Check the structure or format of data files

The head command is particularly useful when you need to quickly inspect the beginning of files or limit the amount of output from other commands. It’s often used in scripts and in combination with other commands to process or analyze data.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

cloud infrastructure community support customizability data protection developer tools free software hardware support lightweight Linux Linux applications Linux command line Linux Community Linux community support Linux development Linux Distributions Linux for old hardware Linux for servers Linux graphical interface Linux installation Linux Kernel Linux package manager Linux performance Linux rolling release linux security Linux security tools Linux server Linux software Linux support Linux terminal Linux updates multitasking multiuser networking no bloatware open-source performance privacy privacy control programming scalability secure OS security software repository stability system resources

  • January 2025
  • November 2024
  • September 2024
  • August 2024
  • March 2024
  • January 2024
  • December 2023
©2025 Linuxinfra.com | Design: Newspaperly WordPress Theme