Skip to Content

Linux Command Line for Beginners


Learn the fundamental Linux command line skills, including file viewing and editing, text processing with grep, awk, sed, and working with file permissions. Improve your understanding of soft vs. hard links, chmod, chown, and more for efficient Linux management. ​


Linux and Bash Scripting Roadmap 

The Linux command line for Beginners is the gateway to master file management, automation, and troubleshooting . So it's a must for every developer, sysadmin, DevOps engineer to understand the Linux command line .

Viewing and Editing Files in Linux : Mastering cat, less, more, nano, and vim


Linux file editing includes viewing, searching, and editing is at the very core of daily tasks for Linux users, system administrators, developers, and DevOps engineers. The essential Linux commands like cat, less, more with most popular Linux text editors like nano, vim is crucial for efficient file handling, troubleshooting, configuration, and automation. 


Why File Viewing and Editing Matters

Before diving into specific tools, it’s important to understand why these skills are vital :

  • Log analysis : Quickly parse large logs with pagers or editors.
  • Configuration : Edit and review system, application, and user files.
  • Scripting and development : Check code, batch update content, or write scripts.
  • Troubleshooting : Trace errors or changes across system files.


1. Viewing Files with cat, less, and more Command

Linux cat Command ā€“ Quick File Display

So we should know as How to Use Cat Command in Linux .

The cat command (ā€œconcatenateā€) is the simplest and fastest way to view the contents of a text file.

Basic Syntax of cat command :

cat filename.txt

  • Shows the entire file in your terminal.
  • Great for small files.
  • Combine files : cat file1.txt file2.txt > combined.txt
  • Create a New File : cat > newfile.txt
  • Copy File Contents : cat source.txt > destination.txt


Commonly Used cat Options

The cat command has several options (or flags) that modify its behavior. Here are some of the most common ones : 

  • -n: Numbers all output lines.
  • -b: Numbers only non-blank lines.
  • -s: Squeezes multiple adjacent blank lines into a single blank line.
  • -E: Displays a $ at the end of each line, useful for identifying line endings.
  • -T: Displays tab characters as ^I.
  • -v: Displays non-printing characters (except for tabs and end-of-line characters) using caret notation.


Limitations:

For large files, cat can overwhelm your screen—you can’t scroll easily.


Linux less Command ā€“ Interactive Pager for Large Files

less addresses the limitations of cat by allowing you to view files one page at a time, scroll up/down, and search within content.

Basic Syntax of less command :

less bigfile.log


Key features:

  • Use arrow keys, Page Up/Down, or /pattern to search.
  • Press q to quit.

Advantages:

  • Does not load the entire file into memory; works well with huge logs.
  • Can move both forward and backward through files.

Real-world use:

Analyze log files, search configuration files, or explore database dumps.


Linux more Command – Simpler Pager Utility

more is similar to less but more limited.

Basic Syntax of less command :

more filename.txt

  • Shows file page by page.
  • Press Space for next page, Enter for next line, q to quit.


Note:

  • Can only scroll forward.
  • Useful on minimal or resource-constrained systems.


Using cat with less and more Command


cat file.txt | less

  • This command displays the contents of file.txt one page at a time using the less pager.
  • It's useful when you're already working with a stream .
  • Useful when combining with filters (e.g., grep, sed) before viewing.
  • Slightly inefficient if you're just reading a file—less file.txt is better.


cat file.txt | more

  • Similar to less, but more is a simpler, older pager.
  • Shows output page by page; use space to go forward, q to quit.
  • āš ļø Can’t scroll backwards like less


2. Editing Files: nano and vim Editor

Nano Editor in Linux – Simple, Beginner-Friendly Editor

nano is the perfect editor for newcomers and for quick edits. It’s widely available on all major Linux distributions.

Open a file :

nano filename.txt

  • Navigate with arrow keys.
  • All commands are listed at the bottom of the editor (e.x - ^O Save, ^X Exit ).


Common controls:

  • Ctrl+O : Save file (ā€œWrite Outā€)
  • Ctrl+X : Exit editor
  • Ctrl+K : Cut the current line
  • Ctrl+U : Paste a cut line
  • Ctrl+W : Search in file

Use cases:

  • Editing configuration files (e.g., /etc/hosts)
  • Writing short scripts and batch files
  • Quickly correcting typos or updating notes

Advantages:

  • No steep learning curve.
  • Safe, with on-screen guidance for all controls.


Vim Editor in Linux – The Power Tool for Experts

For those who need powerful features, extensive plugins, and automation, vim (or its traditional version vi) is the preferred editor.

Open a file in vim :

vim filename.txt


Key concepts:

  • Works in modes: Normal (navigation), Insert (editing), and Command (operations).
    • Press i to enter insert mode and start editing.
    • Press Esc to return to normal mode.
    • Type :w (write/save), :q (quit), or :wq (save and quit).


Why to use vim editor ?

  • Lightning-fast navigation with keyboard shortcuts.
  • Flexible: Supports powerful text manipulation, multiple windows, macros, and syntax highlighting.
  • Ubiquitous: Found on nearly every Linux and Unix system.


Master Text Processing in Linux :  grep, sed, awk, sort, uniq, cut, tr, wc


  ​grep Command in Linux

The grep command is used to search for specific words or patterns in files or output. It’s a fast and easy way to find what we are looking for, especially when scanning logs or debugging issues. Once we learn grep, searching through large files becomes much more easier.  

​sed Comma​nd in Linux  

The sed command lets you find and replace text, edit files automatically, and process streams without opening a text editor. It’s useful for making quick changes to logs, scripts, or config files. Learning sed helps you handle repetitive editing tasks more efficiently right from the command line.  

awk Command in Linux  

awk is a versatile command-line tool that helps us to extract and analyze data from text files. It’s often used for working with logs, reports, and system outputs. awk command help us to deal with structured text often and reduce efforts in data processing .

​sort Command in Linux  

With the sort command, we can organize lines in a file or output alphabetically, numerically or by custom rules. Whether we are dealing with system logs or data files, sorting helps a lot. It’s a handy tool for organizing and preparing data for review.  

  uniq Command in Linux

The uniq command helps us to remove duplicate lines and count repeated entries in a sorted file or output. It’s useful when cleaning up logs, simplifying outputs, or summarizing data. Combined with other tools like sort, it becomes even more powerful in processing large sets of information.  

  cut Command in Linux

Use the cut command to pull out specific columns or fields from text data. It’s perfect for extracting IPs, usernames, or file sizes from command outputs or logs. If we have to often deal with structured output in scripts or pipelines, cut command makes the work faster and more precise.  

  wc Command in Linux

The wc (word count) command helps us to quickly count lines, words, characters and bytes in files or command outputs. It's especially helpful when analyzing logs, checking file sizes, or writing scripts. Knowing how to use wc command makes it easier to summarize and monitor text-based data efficiently.  


These commands are foundational tools for text processing in Linux. Whether you’re working with logs, data files, or scripts, learning these commands allows you to efficiently manipulate and analyze text with just a few keystrokes.