Linux: The Thing Every Dev Should Know - Part 04

April 5, 2026

cat command

cat stands for concatenate — used to display, combine, or create files.

cat file.txt
  • Prints file content to terminal

Common Uses

  1. View file:
cat file.txt
  1. Combine files
cat file1.txt file2.txt > total.txt
  1. Create file:
cat > file.txt

Pro tip :)

  • cat is great for quick reads, but for large files use less.

echo + > - Write to files instantly

Basic Usage

echo "Hello World" > file.txt
  • Creates file.txt and writes Hello World into it

What happens after running the above command

  • echo → prints text
  • ">" → redirects output to a file
  • If file exists → ❌ overwritten
  • If not → ✅ created

Append Instead of Overwrite

echo "Hello again" >> file.txt
  • Adds content without deleting existing data

Pro tip :)

  • > overwrites, >> appends — choose carefully.

Key takeway

  • Use echo + redirection to create and write files in one line.

man command

man stands for manual — it shows detailed documentation for Linux commands.

man ls
  • Opens the manual page for ls
  • Press q to quit or exit

Use

  • Scroll → ↑ / ↓ or j / k
  • Search → /keyword
  • Exit → q

Why use man command

  • Learn commands directly from the system
  • No need to Google basics
  • Always accurate and available offline

Pro tip :)

  • Great engineers read man pages — not just tutorials.
  • When in doubt, man it.

tunnel or pipe (|)

The pipe (|) takes the output of one command and feeds it as input to another.

Basic Usage

ls | grep ".js"
  • Lists only .js files
  1. Count files:
ls | wc -l
  1. Search inside files
cat file.txt | grep "error"

Benefits

  • Combine small commands into powerful workflows
  • Core of Unix philosophy
  • Makes data processing fast and flexible

Pro tip :)

  • Pipes turn simple commands into powerful pipelines.
  • Think in pipelines, not single commands.

tr command

tr stands for translate — it’s used to replace, delete, or transform characters from input.

Basic

echo "hello" | tr 'a-z' 'A-Z'
  • Converts lowercase → UPPERCASE

Use cases

  1. Replace characters:
echo "hello" | tr 'h' 'y'
  1. Delete characters:
echo "hello123" | tr -d '0-9'
  1. Remove duplicate spaces
echo "hello world" | tr -s ' '

Why

  • Fast text processing in pipelines
  • Useful in scripts & data cleaning

Pro tip :)

  • tr works best with pipes — it’s built for stream processing.
  • Use tr to quickly transform text on the fly.

line continuation ()

The backslash \ is used to split a long command into multiple lines for better readability.

Usage

echo "Hello" \ "World"
  • Treated as a single command

cp (copy) command

cp stands for copy — used to duplicate files and directories.

Usage

cp file.txt copy.txt
  • Copies file.txt → copy.txt

Most common usecases

  1. Copy to another folder:
cp file.txt /path/to/folder/
  1. Copy directories:
cp -r folder/ new-folder/
  1. Interactive (confirm overwrite):
cp -i file.txt copy.txt

Why you should use

  • Essential for file management
  • Used in scripts, backups, deployments

Pro tip :)

  • Always use -r for folders — without it, directories won’t copy.
  • Duplicate anything in seconds with cp.

mv command

  • mv stands for move — used to move files/folders or rename them.

Usage

mv file.txt new.txt
  • Renames file.txt -> new.txt

Common usecases

  1. Move file to another folder:
mv file.txt /path/to/folder/
  1. Rename directory:
mv old-folder new-folder
  1. Interactive (confirm overwrite):
mv -i file.txt new.txt

Why

  • Combines move + rename in one command
  • Essential for organizing files

Pro tip :)

  • mv doesn’t copy — it relocates instantly (no duplication).
  • Use mv to move smartly or rename instantly.

rm (remove) command

rm stands for remove — used to delete files and directories.

Usage

rm file.txt
  • Deletes a file

Common usecases

  1. Delete multiple files:
rm file1.txt file2.txt
  1. Delete directories:
rm -r folder/
  1. Force delete (no prompts):
rm -f file.txt

Careful

  • No recycle bin
  • Deletion is permanent

Pro tip :)

  • Use rm -i to avoid mistakes (asks before deleting)
  • With great power (rm) comes great responsibility.
GitHub
LinkedIn
X