Posted On September 16, 2025

LINUX COMMAND OF THE DAY

admin 0 comments
>> Cybersecurity Journey - Semester 1 >> LINUX COMMAND OF THE DAY

1. grep (Global Regular Expression Print):

Used to search text or patterns inside files.

Syntax:

grep [options] "pattern" filename

Common options:

  • -i → ignore case
  • -n → show line numbers
  • -r → search recursively in directories
  • -v → invert match (show lines that don’t match)
  • -c → count matching lines

Examples:

grep "hello" file.txt        # Find lines containing "hello"
grep -i "hello" file.txt     # Case-insensitive search
grep -n "main" program.c     # Show line numbers with matches
grep -r "error" /var/log/    # Search for "error" in all files recursively
grep -v "test" file.txt      # Show all lines except those with "test"

2. find

Used to search for files and directories in a directory hierarchy.

Syntax:

find [path] [options] [expression]

Common options:

  • -name → search by filename
  • -iname → case-insensitive name search
  • -type → search by type (f for file, d for directory)
  • -size → search by size
  • -mtime → search by modification time

Examples:

find /home -name "*.txt"      # Find all .txt files in /home
find . -iname "file.txt"      # Find file.txt (ignore case) in current dir
find / -type d -name "logs"   # Find directories named "logs"
find . -type f -size +10M     # Find files larger than 10 MB
find . -mtime -2              # Find files modified in the last 2 days

3. wc (Word Count)

Used to count lines, words, and characters in a file.

Syntax:

wc [options] filename

Common options:

  • -l → count lines
  • -w → count words
  • -c → count bytes (characters)
  • -m → count characters (multi-byte safe)

Examples:

wc file.txt           # Show lines, words, characters
wc -l file.txt        # Count only lines
wc -w file.txt        # Count only words
wc -c file.txt        # Count only bytes
wc -m file.txt        # Count only characters
cat file.txt | wc -l  # Count lines using pipe

Quick summary:

  • grep → Search inside file contents
  • find → Search for files/directories
  • wc → Count lines, words, characters

One thought on “LINUX COMMAND OF THE DAY”

Leave a Reply to Laksh Cancel reply

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

Related Post

ANTIVIRUS vs FIREWALL

1. What is a Firewall? A firewall acts as a barrier between your computer or…

DIFFERENCE BETWEEN PRIVATE IP ADDRESS AND PUBLIC IP ADDRESS

FeaturesPublic IP AddressPrivate IP AddressDefinitionAssigned by ISP, identifies your device/network on the internetUsed within a…

WEEKELY RECAP

🔹 Public vs. Private IP AddressesI learned how public IPs allow devices to connect to…