>_
EngineeringNotes
Back to Additional Modules

Linux Command Mastery

Essential commands, file usage, and editors.

Why Linux?

Linux is the operating system that powers the internet. From slight IoT devices to the largest supercomputers, Linux is everywhere.

Unlike Windows or macOS, Linux is open-source, meaning anyone can see, modify, and distribute the code. It is known for its stability, security, and flexibility.

Interesting Facts
  • Android uses the Linux kernel. If you have an Android phone, you use Linux daily.
  • Over 96% of the top 1 million web servers run on Linux.
  • Linux was created by Linus Torvalds in 1991 as a personal hobby project.
  • It powers 100% of the world's top 500 supercomputers.

Basic Commands

These are the commands you will use 90% of the time. Get comfortable with them!

Terminal
bash
pwd

Print Working Directory. Shows where you are.

Terminal
bash
ls

List files in the current directory. Use ls -a to see hidden files.

Terminal
bash
cd foldername

Change Directory. Go into a folder. Use cd .. to go back/up.

Terminal
bash
clear

Clears the terminal screen.

The "man" Command

Every Linux command has a manual. If you forget how to use a command, just ask Linux!

Terminal
bash
man ls

Press q to exit the manual.

File Operations

Creation & Deletion

Terminal
bash
touch filename.txt

Creates an empty file.

Terminal
bash
mkdir foldername

Make Directory (folder).

Terminal
bash
rm filename

Remove (delete) a file. Warning: No recycle bin!

Terminal
bash
rm -rf foldername

Delete a folder and everything inside it recursively. EXTREMELY DANGEROUS.

Copy & Move

Terminal
bash
# Copy a file
cp source.txt destination.txt

# Copy a folder
cp -r source_folder/ destination_folder/

# Move a file (also used to Rename)
mv oldname.txt newname.txt

Viewing & Redirecting Content

Terminal
bash
# View file content
cat filename.txt

# Overwrite file content (>)
echo "Hello World" > filename.txt

# Append to file content (>>)
echo "Another line" >> filename.txt

> replaces the entire file. >> adds to the end. Be careful! before using these commands

Terminal Editors

Nano

Beginner friendly. Usage instructions are always at the bottom of the screen.

Terminal
bash
nano filename.txt
  • Basics
  • Type normally to edit text.
  • Ctrl + O: Save (Write Out).
  • Ctrl + X: Exit.
  • Copy in Nano
  • Alt + A: Start Selection Mode.
  • Use Arrow keys to highlight text.
  • Alt + 6: Copy (Store in buffer).
  • Ctrl + K: Cut.
  • Ctrl + U: Paste (Uncut).
  • Navigation & Undo
  • Alt + U: Undo last action.
  • Ctrl + _: Go to Line Number.

Vim

Powerful and fast. Commands work in "Normal Mode" (Press Esc).

Terminal
bash
vim filename.txt
  • Modes
  • i: Insert mode (start typing).
  • Esc: Return to Normal Mode.
  • Save & Quit
  • :w: Save.
  • :q: Quit.
  • :wq: Save & Quit.
  • :q!: Force Quit.
  • Copy (Yank) & Paste
  • v: Visual Mode (Select text with arrows).
  • y: Yank (Copy selected text).
  • yy: Copy current line.
  • p: Paste after cursor.
  • ggVG: Select All.
  • Navigation & Undo
  • u: Undo.
  • Ctrl + r: Redo.
  • gg: Go to first line.
  • G: Go to last line.