Tech
The Complete Beginner's Guide to Using the Command Line
Learn what the command line is, how to open it, and essential commands for navigation, file management, and combining commands with pipes and redirects—no prior experience needed.
June 2026 · 10 min read · 1 views · 0 hearts
Advertisement
The Complete Beginner's Guide to Using the Command Line
You’ve probably seen it in movies: a dark screen with green text, a hacker typing furiously, and—boom—the mainframe is hacked. In reality, the command line is less Hollywood and more superpower. Once you learn it, you’ll navigate your computer faster than any mouse-clicker, automate boring tasks, and finally understand what’s actually going on under the hood.
Let’s demystify it. No prior experience needed.
What Even Is the Command Line?
The command line (or terminal, or shell) is a text-based interface to your computer’s operating system. Instead of pointing and clicking, you type commands. The computer responds with text output. It’s faster, more precise, and gives you control that graphical interfaces hide.
- On macOS/Linux, it’s called Terminal (or bash/zsh).
- On Windows, it’s Command Prompt or PowerShell (but we’ll focus on the cross-platform approach).
Think of it as having a conversation with your machine. You talk, it listens.
Getting Started: Open the Thing
- Mac: Press
Cmd + Space, type “Terminal”, hit Enter. - Windows: Press
Win + R, typecmd, press Enter. Or install Git Bash for a Linux-like experience. - Linux:
Ctrl + Alt + Tusually opens it.
You’ll see something like:
username@computer:~$
That $ is your prompt—waiting for a command.
Your First Commands: Navigation
Where Are You? pwd
Type pwd (print working directory). It shows your current folder. You’re likely in your home directory (e.g., /Users/yourname).
What’s Here? ls
Type ls. It lists files and folders in your current location.
Want more detail? Try ls -l (long format) or ls -a (show hidden files).
Move Around: cd
cd means “change directory”.
- cd Desktop — go to Desktop.
- cd .. — go up one folder.
- cd ~ — back to home.
- cd / — root of the filesystem.
Pro tip: Use Tab to auto-complete folder names. It’s a time-saver.
Files: Create, Read, Delete
Make a File: touch
touch myfile.txt creates an empty file.
Make a Folder: mkdir
mkdir myfolder creates a directory.
See Inside a File: cat or less
cat myfile.txtprints the file to the terminal (good for short files).less myfile.txtlets you scroll with arrow keys (pressqto quit).
Remove Stuff: rm (be careful!)
rm myfile.txt— deletes a file.rm -r myfolder— deletes a folder and everything inside it.- There’s no trash bin. Once deleted, it’s gone. Use
rm -ito be prompted before each deletion.
Copy, Move, Rename
cp source destination— copy a file.cp -r sourcefolder destinationfolder— copy a folder.mv oldname newname— rename or move.
Example: mv report.txt archive/ moves the file into the archive folder.
Peeking into the System
date— current date and time.whoami— your username.uname -a— system info (kernel, OS, architecture).df -h— disk space usage (human-readable).free -h(Linux) — memory usage.
Getting Help: The Command Line’s Friend
man <command>— manual page. Example:man lstells you everything aboutls. Pressqto exit.--help— many commands accept this flag (e.g.,ls --help).
Power Moves: Combining Commands
This is where the command line gets magical.
Pipes (|)
Take the output of one command and feed it into another.
ls -l | grep "txt" — lists files, then filters for lines containing “txt”.
Redirect (> and >>)
ls > files.txt— saves the list into a file (overwrites it).echo "hello" >> greeting.txt— appends to a file (doesn’t overwrite).
History
Press the up arrow to bring back recent commands.
Type history to see everything.
A Real-World Example: Clean Up Your Downloads
Let’s say your Downloads folder is chaos. Here’s a one-liner to find all PDFs older than 30 days:
find ~/Downloads -name "*.pdf" -mtime +30
To delete them (after double-checking), add -delete:
find ~/Downloads -name "*.pdf" -mtime +30 -delete
Always double-check before deleting. The command line trusts you.
Keyboard Shortcuts to Live By
Ctrl + C— stop a running command.Ctrl + D— exit the terminal.Ctrl + A— go to beginning of line.Ctrl + E— go to end of line.Ctrl + U— erase the whole line.
Don’t Be Afraid to Break Things
The command line is robust. You won’t wreck your computer by ls-ing around. The only dangerous commands involve rm, dd, or sudo (which runs as admin). Use sudo only when you understand what it does.
Next Steps
You’ve got the foundation. From here, explore:
- Text editing: Use
nanoorvim. - Scripting: Write a
.shfile to automate tasks. - Package managers:
apt,brew,pipto install software. - Remote servers:
sshinto a cloud machine.
The command line rewards curiosity. Every command you learn saves you from clicking a hundred menus. Start small. Try one command a day. Soon, that black screen will feel like home.
Advertisement
Comments
Questions, corrections, and tips stay visible for everyone reading this page.
Join the discussion
No comments yet
Be the first to leave a note — it helps the next reader.