Bash Basics — Complete Beginner's Guide to the Linux Command Line
Bash is the command-line interpreter on Linux, macOS, and WSL that lets you navigate files, run programs, and automate tasks by typing commands instead of clicking through folders.
What You’ll Learn
- Navigate the filesystem using
pwd,ls, andcd - Create, copy, move, and delete files and directories
- Use aliases to create shortcuts for frequent commands
- Get help with
man,--help, andapropos - Avoid common beginner mistakes that can lose data
Why Bash Basics Matters
Everything you do on a server — deploying apps, checking logs, configuring services — happens in the terminal. Without Bash basics, you’re locked out of your own machine’s power. Durga Antivirus Pro technicians use Bash daily to navigate log directories, inspect virus definition files, and run scan scripts. DodaZIP uses shell commands to batch-process compression jobs across thousands of files. Bash is the foundation beneath every tool.
Security note: Understanding Bash Basics helps build more secure applications — a core principle at DodaTech, where tools like Durga Antivirus Pro and Doda Browser rely on solid implementation practices.
Learning Path
flowchart LR
A[Bash Basics<br/>You are here] --> B[Pipes & Redirection]
B --> C[Shell Scripts]
C --> D[Permissions & Users]
D --> E[System Monitoring]
What Is Bash?
Think of Bash as a conversation between you and your computer. You type a sentence (a command), and the computer responds with output. The terminal is the window where this conversation happens; Bash is the interpreter that understands what you mean.
# Your first conversation
pwd
# /home/youYou asked “where am I?” and Bash answered. That’s it. Every command follows the same pattern: you speak, Bash listens, Bash acts, Bash replies.
Navigating the Filesystem
Your files live in a tree structure. Think of it like a set of nested drawers. The root drawer (/) contains everything. Inside it are folders like home (users), etc (configuration), and tmp (temporary files).
# Where am I right now?
pwd
# /home/you
# What's in this drawer?
ls
# Desktop Documents Downloads Music Pictures
# Let's see more detail
ls -l
# drwxr-xr-x 2 you you 4096 Jun 6 10:00 Documents
# Open the Documents drawer
cd Documents
# Go back up one drawer
cd ..
# Go straight home from anywhere
cd ~
# Go to the previous place you were
cd -Why this matters: Every command you run — grep, curl, git — operates on files. If you can’t find files, you can’t do anything.
File Operations Explained
Files are like pieces of paper. You can create them, read them, copy them, move them, and throw them away.
# Create an empty file (like taking a blank sheet)
touch notes.txt
# Write something into it
echo "Hello Bash!" > notes.txt
# Read what's inside
cat notes.txt
# Hello Bash!
# Make a copy (like a photocopier)
cp notes.txt backup-notes.txt
# Move it to a different folder (like filing it away)
mv notes.txt Documents/
# Rename (move within the same folder)
mv backup-notes.txt important-notes.txt
# Delete (permanent — no trash bin!)
rm important-notes.txtrm is permanent. Unlike dragging a file to the Trash, this command immediately destroys the file. There is no undo. Always double-check before pressing Enter.Directories (Folders)
# Make a new folder
mkdir projects
# Make an entire path at once
mkdir -p projects/website/images
# Remove an empty folder
rmdir projects/website/images
# Remove a folder and everything inside
rm -rf projects/The -p flag on mkdir is like mkdir with a “don’t stop if parents are missing” attitude. It creates whatever’s needed.
The -rf on rm means “recursive force” — it deletes the folder, all its contents, and doesn’t ask permission. Use with extreme care.
Aliases — Shortcuts for Speed
An alias is like a nickname for a longer command. Instead of typing ls -la every time, give it a shorter name.
# Create a temporary alias (lasts only this session)
alias ll='ls -la'
# Now you can use it
ll
# See all your current aliases
alias
# Make it permanent — add to your Bash config file
echo "alias ll='ls -la'" >> ~/.bashrc
# Reload the config so it takes effect now
source ~/.bashrcGetting Help
# Detailed manual
man ls
# Quick summary
ls --help
# One-line description
whatis ls
# Search for commands by description
apropos "list files"The man (manual) command is your best friend. Every command has a manual. Press q to quit the manual viewer.
Terminal Shortcuts
| Key | What It Does | Why You Care |
|---|---|---|
Tab | Auto-completes commands, files, paths | Stops typos, saves seconds every time |
↑ / ↓ | Scroll through command history | No need to retype |
Ctrl + C | Kill the current running command | Un-stick yourself from a hung process |
Ctrl + D | Exit the shell / end of file | Faster than typing exit |
Ctrl + L | Clear the screen | Like wiping a whiteboard clean |
Ctrl + R | Search command history | Find that command you ran yesterday |
The Shebang Explained
You’ll see #!/bin/bash at the top of script files. The #! (called “shebang”) tells the system: “use /bin/bash to run this file.” Without it, the system doesn’t know which interpreter to use, and the script won’t execute.
Common Mistakes
1. Spaces around = in assignments
name = "Alice" # WRONG — Bash thinks "name" is a command
name="Alice" # CORRECT — no spaces2. Forgetting to quote variables with spaces
file=My Document.txt
cat $file # Error: tries to cat "My" then "Document.txt"
cat "$file" # CORRECT: treats it as one filename3. Using rm -rf carelessly
rm -rf / destroys your entire system. A single typo (rm -rf / home instead of rm -rf /home) is a catastrophe. Always check the path twice.
4. Confusing > (overwrite) with >> (append)
echo "data" > file.txt # Creates brand new file, erases old content
echo "more" >> file.txt # Adds to end, keeps existing content5. Not using Tab completion
Typing every character is slow and error-prone. Press Tab — Bash finishes your command, filename, or path. It also shows options when multiple matches exist.
6. Running sudo when not needed
Only use sudo when you get a “Permission denied” error. Running everything as root can accidentally delete system files or misconfigure your system.
Practice Questions
What does
pwddo? Prints the current working directory — tells you where you are in the filesystem.How do you list all files including hidden ones?
ls -a. Files starting with.are hidden (like.bashrc).What’s the difference between
cp file.txt ~/backups/andmv file.txt ~/backups/?cpleaves the original in place and creates a copy in the destination.mvmoves the file — the original is gone.What does
mkdir -p a/b/cdo? Creates the entire directory path at once. Ifadoesn’t exist, it createsa, thenbinsidea, thencinsideb.How do you make an alias permanent? Add
alias shortcut='long-command'to~/.bashrc, then runsource ~/.bashrc.
Challenge: Create a directory structure project/src/css with a single command, then navigate into css, go back to project using a relative path, and finally remove the entire project directory. What commands did you use?
FAQ
Try It Yourself
Open your terminal and experiment:
- Run
pwdto see where you are - Run
ls -lato see every file in your home directory - Create a temporary directory with
mkdir -p /tmp/bash-practice/hello - Navigate into it with
cd /tmp/bash-practice/hello - Create a file with
echo "I learned Bash" > test.txt - Read it with
cat test.txt - Remove everything with
rm -rf /tmp/bash-practice
All these commands are safe — you’re working in /tmp, which is designed for temporary files that get cleaned on reboot.
What’s Next
| Tutorial | What You’ll Learn |
|---|---|
| Pipes & Redirection | Chain commands with pipes, redirect output, use grep and sed |
| Shell Scripts | Write reusable scripts with variables, loops, and functions |
| Linux System Administration | Manage services, users, and processes on a Linux server |
What’s Next
Congratulations on completing this Bash Basics tutorial! Here’s where to go from here:
- Practice daily — Consistency is more important than long study sessions
- Build a project — Apply what you learned by building something real
- Explore related topics — Check out other tutorials in the same category
- Join the community — Discuss with other learners and share your progress
Remember: every expert was once a beginner. Keep coding!
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro