Terminal Commands Every Developer Should Know

The terminal is one of the most powerful tools in a developer's toolkit. It gives you precise control over your system, your code, and your environment. Whether you’re building apps, managing servers, or just trying to debug faster, mastering a handful of terminal commands can dramatically improve your workflow.
This article walks through essential terminal commands every developer should know, regardless of whether you're on macOS, Linux, or even Windows using WSL or Git Bash.
Basic Navigation Commands
pwd
Prints the current directory you're in.
pwd
Output might look like:
/Users/yourname/projects/my-app
ls
Lists the contents of a directory.
ls
With flags:
ls -l # Long format
ls -a # Show hidden files
ls -lah # Combined and human-readable
cd
Changes the current directory.
cd projects
cd ..
cd ~/Desktop
Working with Files and Directories
touch
Creates a new empty file.
touch index.html
mkdir
Creates a new directory.
mkdir assets
mkdir -p src/components
rm
Removes files or directories. Be cautious — this is irreversible.
rm file.txt
rm -rf node_modules
cp
Copies files or directories.
cp file1.txt file2.txt
cp -r src/ backup/
mv
Moves or renames files and folders.
mv old.txt new.txt
mv file.txt ../
Viewing and Editing Content
cat
Outputs the contents of a file.
cat README.md
less
Scroll through the contents of a file page by page.
less largefile.log
Use q
to quit.
nano / vim / code
Edit files directly from the terminal using editors like nano
, vim
, or VS Code CLI:
nano app.js
vim index.html
code .
Process Management
top or htop
Displays real-time CPU and memory usage. htop
is more advanced but may require installation.
ps
Lists running processes.
ps aux | grep node
kill
Kills a process by PID.
kill 1234
kill -9 5678
Ctrl + C
Interrupts a running command or process in the terminal. Especially useful for stopping servers or CLI tools.
Searching and Filtering
grep
Searches for text in files or output.
grep "hello" file.txt
ps aux | grep chrome
find
Finds files by name or pattern.
find . -name "*.js"
find / -type f -name "config.json"
which
Shows the full path of an installed command.
which node
which git
history
Displays previously used commands.
history | grep npm
Package Managers
npm / yarn
Used for JavaScript/Node.js projects.
npm install axios
yarn add lodash
brew
macOS package manager for installing tools.
brew install git
brew upgrade node
apt / apt-get
Used on Debian/Ubuntu systems for package management.
sudo apt update
sudo apt install curl
Version Control Commands (Git)
git status
Shows which files are staged, modified, or untracked.
git status
git add
Stages files for commit.
git add index.js
git add .
git commit
Commits changes with a message.
git commit -m "Add login feature"
git log
Shows commit history.
git log --oneline
git diff
Shows changes between commits or staging area and working directory.
git diff
git diff HEAD~1
Networking Commands
curl
Sends HTTP requests from the terminal.
curl https://api.github.com/users/octocat
ping
Tests connectivity to a host.
ping google.com
traceroute
Shows the route packets take to a destination.
traceroute github.com
ssh
Connects securely to a remote machine.
ssh user@yourserver.com
Other Useful Shortcuts
!!
→ Repeats the last command!n
→ Runs the command at linen
in historyCtrl + L
→ Clears the terminalCtrl + R
→ Search command history interactivelyTab
→ Autocomplete file or command
Combining Commands
Pipes
Send the output of one command into another.
ls -l | grep ".js"
Redirect Output
echo "Hello" > file.txt # Write to file
echo "Another line" >> file.txt # Append to file
Chaining Commands
npm run build && npm start
This runs the second command only if the first one succeeds.
Checking Disk and System Info
df -h
Shows available disk space in human-readable format.
du -sh *
Shows folder sizes in current directory.
uname -a
Displays system info like kernel version, OS type, etc.
whoami
Displays the current logged-in user.