March 26, 20266 min read

Terminal Commands Every Developer Should Know

Essential shell commands for navigation, file operations, text processing, process management, and networking — plus productivity tips for aliases and piping.

terminal shell linux command-line productivity
Ad 336x280

You can be a productive developer without mastering the terminal. But the developers who are fast — really fast — almost always have strong command-line skills. The terminal isn't about looking cool. It's about doing things in 3 seconds that take 30 seconds in a GUI.

Here are the commands worth knowing, grouped by what you're trying to do.

pwd                    # Print working directory — where am I?
ls                     # List files in current directory
ls -la                 # List ALL files (including hidden) with details
cd /path/to/dir        # Change directory
cd ..                  # Go up one level
cd ~                   # Go to home directory
cd -                   # Go back to previous directory (this one's great)
cd - is underrated. You're bouncing between two directories constantly — cd - toggles between them without typing the full path. ls -la shows permissions, file sizes, modification dates, and hidden files (files starting with .). You'll use this more than plain ls.

File Operations

touch file.txt         # Create an empty file (or update its timestamp)
mkdir -p src/utils     # Create directory and any missing parents
cp file.txt backup.txt # Copy a file
cp -r src/ src-backup/ # Copy a directory recursively
mv old.txt new.txt     # Rename/move a file
rm file.txt            # Delete a file (no recycle bin, it's gone)
rm -rf directory/      # Delete a directory and everything inside it
Be careful with rm -rf. There's no undo. Especially be careful with variables: rm -rf $DIR/ where $DIR is empty expands to rm -rf /, which tries to delete your entire filesystem. Always double-check.
ln -s /real/path link  # Create a symbolic link
find . -name "*.py"    # Find files by name, recursively
find . -name "*.log" -mtime +30 -delete  # Delete log files older than 30 days
find is incredibly powerful. Learn it well and you'll stop clicking through file explorers.

Reading and Processing Text

cat file.txt           # Print entire file contents
head -20 file.txt      # First 20 lines
tail -20 file.txt      # Last 20 lines
tail -f app.log        # Follow a log file in real-time (Ctrl+C to stop)
less file.txt          # Scrollable file viewer (q to quit)
wc -l file.txt         # Count lines in a file
wc -w file.txt         # Count words
tail -f is essential for watching log files during development. Pair it with grep to filter:
tail -f app.log | grep "ERROR"

grep: Search Like You Mean It

grep "TODO" *.py                    # Search for "TODO" in all Python files
grep -r "import requests" src/      # Recursive search in a directory
grep -rn "def process" src/         # Include line numbers
grep -ri "error" logs/              # Case-insensitive search
grep -rl "deprecated" src/          # Only show filenames, not matching lines
grep -v "debug" app.log             # Show lines that DON'T match
grep -rn is your fastest way to find where something is defined or used in a codebase. Faster than most IDE search tools for large projects.

For more complex patterns, use -E for extended regex:

grep -rE "v[0-9]+\.[0-9]+\.[0-9]+" .  # Find version strings like v2.1.0

Process Management

ps aux                 # List all running processes
ps aux | grep node     # Find Node.js processes
kill 12345             # Send SIGTERM to process 12345 (graceful shutdown)
kill -9 12345          # Send SIGKILL (force kill, use as last resort)
top                    # Real-time process viewer (q to quit)
htop                   # Better version of top (install it if you don't have it)
lsof -i :3000         # What process is using port 3000?

The port question comes up constantly in web development. "Port 3000 is already in use" — lsof -i :3000 tells you the PID, and kill frees the port.

Networking

curl https://api.example.com/data          # Make an HTTP GET request
curl -X POST -H "Content-Type: application/json" \
     -d '{"key": "value"}' https://api.example.com/data
curl -o output.zip https://example.com/file.zip  # Download a file
ping google.com                             # Test network connectivity
ssh user@server.com                         # Connect to remote server
scp file.txt user@server.com:/path/         # Copy file to remote server
curl is the universal API testing tool. Before you open Postman, try curl. It's faster for quick checks, and you can save the command in your notes for reuse.

Piping and Redirection

This is where the terminal gets powerful. Commands can be chained:

# Count how many JavaScript files exist in a project
find . -name "*.js" | wc -l

# Find the 10 largest files in a directory
du -sh * | sort -rh | head -10

# Get unique error types from a log file, sorted by frequency
grep "ERROR" app.log | awk '{print $4}' | sort | uniq -c | sort -rn

# Save command output to a file
ls -la > listing.txt        # Overwrite
echo "new line" >> file.txt # Append

The pipe (|) sends one command's output as input to the next. This composability is the whole point of Unix philosophy — small tools that do one thing, chained together to do complex things.

Productivity Tips

Aliases save keystrokes for commands you run constantly. Add these to your ~/.bashrc or ~/.zshrc:
alias gs="git status"
alias gd="git diff"
alias ll="ls -la"
alias ..="cd .."
alias ...="cd ../.."
History search: Press Ctrl+R and start typing to search your command history. You ran that complex docker command three days ago? Ctrl+R and type docker to find it. Tab completion: Press Tab to autocomplete file names and commands. Press Tab twice to see all options if the match is ambiguous. !! and !$: !! repeats the last command (useful as sudo !! when you forgot sudo). !$ is the last argument of the previous command.
mkdir /opt/myapp
cd !$             # Expands to: cd /opt/myapp

Building the Habit

Terminal proficiency isn't something you learn in a day. It builds over weeks of choosing the terminal over the GUI for small tasks. Every time you catch yourself clicking through a file browser, try the terminal equivalent instead.

The more you code, the more natural these commands become. If you're looking for a place to write code regularly and build these habits alongside your programming skills, CodeUp gives you a structured environment to practice — and you'll find the terminal skills carry over into everything else you do.

Ad 728x90