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

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

Related Post

WHAT IS CYBERSECURITY ?

Cybersecurity is the practice of protecting computer systems, networks, applications, and data from digital threats…

WHAT IS ENCRYPTION ?

Encryption is the process of converting readable data (called plaintext) into an unreadable format (called…

What is DNS?

DNS (Domain Name System) is like the phonebook of the internet. It translates domain names…