Master the Command Line: Essential Commands Every Developer Must Know
The command line might seem intimidating at first, but it's one of the most powerful tools in a developer's arsenal. Whether you're working with Git, deploying applications, or navigating your file system, knowing these essential commands will dramatically speed up your workflow.
πΊοΈ Navigation & File System Commands
Master these basics to navigate your computer like a pro:
| Command | Description | Example |
|---|---|---|
cd |
Change directory | cd Documents |
cd .. |
Go up one directory | cd .. |
cd ~ |
Go to home directory | cd ~ |
pwd |
Print working directory (where am I?) | pwd |
ls |
List files and folders (Linux/Mac) | ls -la |
dir |
List files and folders (Windows) | dir |
mkdir |
Create new directory | mkdir my-project |
touch |
Create new file (Linux/Mac) | touch index.html |
echo > file |
Create new file (Windows) | echo. > index.html |
π File Operations
Essential commands for managing files:
| Command | Description | Example |
|---|---|---|
cp |
Copy files/folders (Linux/Mac) | cp file.txt backup.txt |
copy |
Copy files (Windows) | copy file.txt backup.txt |
mv |
Move or rename files (Linux/Mac) | mv old.txt new.txt |
move |
Move files (Windows) | move old.txt new.txt |
rm |
Remove/delete files (Linux/Mac) | rm file.txt |
del |
Delete files (Windows) | del file.txt |
rm -rf |
Remove directory and contents (Linux/Mac) | rm -rf folder/ |
cat |
Display file contents (Linux/Mac) | cat readme.txt |
type |
Display file contents (Windows) | type readme.txt |
rm -rf is extremely powerful and dangerous! It permanently deletes files without confirmation. Always double-check before using it.
πΏ Git Commands (Essential for Every Developer)
Version control commands you'll use daily:
| Command | Description |
|---|---|
git init |
Initialize a new Git repository |
git clone [url] |
Clone a repository from GitHub |
git status |
Check status of your files |
git add . |
Stage all changes for commit |
git add [file] |
Stage specific file |
git commit -m "message" |
Commit staged changes with message |
git push |
Push commits to remote repository |
git pull |
Pull latest changes from remote |
git branch |
List all branches |
git checkout -b [name] |
Create and switch to new branch |
git merge [branch] |
Merge branch into current branch |
git log |
View commit history |
My Daily Git Workflow:
# Start working on new feature
git checkout -b new-feature
# Make changes, then check status
git status
# Stage and commit changes
git add .
git commit -m "Add new feature"
# Push to GitHub
git push origin new-feature
π Search & Filter Commands
Find what you're looking for quickly:
| Command | Description | Example |
|---|---|---|
grep |
Search text in files (Linux/Mac) | grep "error" log.txt |
find |
Find files by name (Linux/Mac) | find . -name "*.js" |
findstr |
Search text in files (Windows) | findstr "error" log.txt |
where |
Find command location (Windows) | where python |
which |
Find command location (Linux/Mac) | which python |
β‘ Terminal Shortcuts & Productivity
Speed up your command line work with these shortcuts:
| Shortcut | Action |
|---|---|
β Arrow |
Previous command in history |
β Arrow |
Next command in history |
Tab |
Auto-complete file/folder names |
Ctrl + C |
Cancel current command |
Ctrl + L |
Clear screen (or type clear) |
Ctrl + A |
Move cursor to start of line |
Ctrl + E |
Move cursor to end of line |
Ctrl + U |
Delete from cursor to start of line |
Ctrl + K |
Delete from cursor to end of line |
Ctrl + R |
Search command history |
π Package Managers & Development
Essential commands for managing dependencies:
npm (Node.js):
npm install # Install dependencies
npm install [package] # Install specific package
npm start # Run start script
npm test # Run tests
npm run build # Build project
pip (Python):
pip install [package] # Install package
pip install -r requirements.txt # Install from file
pip list # List installed packages
pip freeze > requirements.txt # Save dependencies
π» System Information
Check your system details:
| Command | Description |
|---|---|
whoami |
Display current username |
hostname |
Display computer name |
date |
Display current date/time |
top / htop |
View running processes (Linux/Mac) |
tasklist |
View running processes (Windows) |
df -h |
Check disk space (Linux/Mac) |
ipconfig |
Network configuration (Windows) |
ifconfig |
Network configuration (Linux/Mac) |
π My Learning Journey
When I first saw the command line during my first year at university, I was terrified. The black screen with blinking cursor felt like hacking in movies. But once I understood its power, there was no going back.
Week 1: Basic Navigation
I started with simple commands: cd, ls, and pwd. I practiced navigating my project folders without touching the mouse.
Week 2: Git Basics
Learning Git through the command line was a game-changer. git add, git commit, git push β these became second nature.
Week 3: File Operations
Creating files, copying, moving β all through commands. I realized how much faster this was than clicking through folders.
Month 2+: Advanced Usage
Started using shortcuts like Ctrl + R for history search, piping commands together, and writing simple bash scripts.
π₯ Real-World Examples
Starting a New Project:
mkdir my-awesome-project
cd my-awesome-project
git init
npm init -y
touch index.js
code . # Opens VS Code
Deploying to GitHub:
git add .
git commit -m "Initial commit"
git remote add origin [your-repo-url]
git push -u origin main
Finding Large Files:
# Linux/Mac
find . -type f -size +10M
# Windows
forfiles /S /C "cmd /c if @fsize gtr 10485760 echo @path"
π― Your 30-Day Command Line Challenge
Week 1: Use only terminal for navigation (cd, ls, pwd)
Week 2: Add file operations (mkdir, touch, rm, cp)
Week 3: Master Git commands for your projects
Week 4: Learn terminal shortcuts and history search
- Try
tldr [command]for quick help - Use
man [command]for detailed documentation (Linux/Mac) - Install Git Bash on Windows for Unix-like commands
π‘ Final Thoughts
The command line is not just about being "cool" or "hacker-like" β it's about efficiency. Once you're comfortable with these commands, you'll wonder how you ever worked without them.
Start small, practice consistently, and don't be afraid to make mistakes. The command line is forgiving (except rm -rf β always be careful with that one!).
Remember: Every expert was once a beginner who kept practicing. Your future self will thank you for learning these commands now! π
What's your go-to terminal command? Share your favorite productivity tips in the comments!