Skip to content
devcards.space
DevOpsTools

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.

6 minute read
Bash Basics infographic with sections on navigation, listing, file management, content viewing, search and useful commands across 10 panels

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.

bash
pwd               # print current directory
cd folder         # enter a sub-directory
cd ..             # go up one level
cd ~              # go to home
ls                # list files

Listing Files

Different ls flags give you different levels of detail.

bash
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:

bash
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 recursively

File Content

Commands for viewing what's inside files:

bash
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 log

Search & Filter

The two most powerful commands for searching inside files or the filesystem are grep and find:

bash
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 directories

Useful Commands

Small but constantly-used utilities:

bash
clear            # clear the screen
echo "hello"     # print to screen
man ls           # command manual
which node       # show command path
history          # previous commands

Tips

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:

bash
mkdir project
cd project
touch index.js
ls
# then:
git init
npm init -y

Summary

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.

Other infographics on connected topics.

Discover more developer infographics

Visit the homepage so you don't miss new content.

See all infographics