Bash Basics: Essential Terminal Commands Every Developer Should Know
Core Bash commands every developer uses daily on Linux/macOS — navigation, file management, search and example workflows.
Bash is the standard shell on Unix-based systems including Linux and macOS. As a developer, almost every daily task — file management, running builds, inspecting logs, deploying to the cloud — flows through the terminal. This guide walks through the 10 sections of the infographic, summarizing the most-used commands with examples; what matters is recognizing which command fits which situation, not memorizing them all.
What is Bash?
A shell that's both a command-line interface and a scripting language. It's how you talk to the operating system. It ships by default on Linux, macOS and WSL; you use it interactively for one-off commands and via .sh files for automation.
- Run commands
- Interact with the OS
- Common on Linux, macOS and WSL
Navigation
The three commands you'll move around the filesystem with: pwd, cd, ls.
pwd # print current directory
cd folder # enter a sub-directory
cd .. # go up one level
cd ~ # go to home
ls # list filesListing Files
Different ls flags give you different levels of detail.
ls # list
ls -l # long format (perms, size, date)
ls -a # include hidden files
ls -lh # human-readable sizes (KB, MB)File & Directory Management
Create, move, copy and delete operations:
mkdir folder # create folder
touch file.txt # create empty file
cp file.txt backup.txt # copy
mv file.txt new.txt # move / rename
rm file.txt # delete
rm -r folder # delete recursivelyFile Content
Commands for viewing what's inside files:
cat file.txt # print content
less file.txt # page through (q to quit)
head file.txt # first 10 lines
tail file.txt # last 10 lines
tail -f log.txt # live-tail a logSearch & Filter
The two most powerful commands for searching inside files or the filesystem are grep and find:
grep "error" log.txt # search in a file
grep -r "TODO" . # recursive search
find . -name "*.ts" # find ts files
find . -type d -name "dist" # find dist directoriesUseful Commands
Small but constantly-used utilities:
clear # clear the screen
echo "hello" # print to screen
man ls # command manual
which node # show command path
history # previous commandsTips
Shortcuts that multiply your productivity:
- Tab — auto-complete (file/command)
- ↑ ↓ — walk through history
- Ctrl+C — stop running command
- Ctrl+R — quick history search
- Ctrl+L — clear-screen shortcut
A Common Workflow
A chain of commands you'd run when starting a new project:
mkdir project
cd project
touch index.js
ls
# then:
git init
npm init -ySummary
Bash gives developers and DevOps full control of their system. It's faster than a GUI, scriptable, and works the same way on remote servers. Even just a couple of dozen commands will noticeably boost your daily productivity.
Frequently Asked Questions
Common questions about this topic.
How is Zsh different from Bash?
Zsh is largely Bash-compatible and adds extra features (oh-my-zsh, autocomplete plugins). It's been the macOS default since Catalina. Every command in this guide works the same in both.
Can I use Bash on Windows?
Yes. WSL (Windows Subsystem for Linux) gives you a real Linux shell. Git Bash is also a fine alternative for everyday commands.
Is rm -rf really dangerous?
Yes. rm -rf / can permanently wipe system files. Always verify the path with ls first, and consider trash or rm -i (interactive).
How do I write a Bash script?
Create a .sh file, add #!/bin/bash at the top and run chmod +x to make it executable. Variables, loops and functions make small automations easy.
What should I learn for productivity?
Tab autocomplete, aliases, pipes (|), redirects (>), && / ||, history (Ctrl+R) and grep/find combinations buy you the most time. Master these and you're set.
Related Posts
Other infographics on connected topics.
- ToolsDevOps
What is Concurrently? Run Multiple Commands at the Same Time
Run npm scripts in parallel with Concurrently. Colored logs, named labels, --kill-others and glob support — collapse your full-stack dev flow into a single terminal.
- ToolsFrontend
What is Vite? Next-Generation Frontend Tooling
Vite ships an ESM-native dev server that starts instantly and lightning-fast HMR. Walk through setup, the plugin system, production builds and a Webpack comparison.
- FrontendTools
What is Zod? Type-Safe Validation for Modern Apps
Generate runtime validation from TypeScript types with Zod. Schema definitions, parse, safeParse, type inference and React Hook Form integration.
Discover more developer infographics
Visit the homepage so you don't miss new content.
See all infographics