Skip to content
Bash Basics — Complete Beginner's Guide to the Linux Command Line

Bash Basics — Complete Beginner's Guide to the Linux Command Line

DodaTech Updated Jun 4, 2026 8 min read

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, and cd
  • Create, copy, move, and delete files and directories
  • Use aliases to create shortcuts for frequent commands
  • Get help with man, --help, and apropos
  • 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]
  
Prerequisites: No prior experience needed. You should have a terminal open (Linux, macOS, or WSL on Windows). Familiarity with HTML helps but isn’t required.

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/you

You 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.txt
rm 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 ~/.bashrc

Getting 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

KeyWhat It DoesWhy You Care
TabAuto-completes commands, files, pathsStops typos, saves seconds every time
/ Scroll through command historyNo need to retype
Ctrl + CKill the current running commandUn-stick yourself from a hung process
Ctrl + DExit the shell / end of fileFaster than typing exit
Ctrl + LClear the screenLike wiping a whiteboard clean
Ctrl + RSearch command historyFind 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 spaces

2. 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 filename

3. 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 content

5. 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

  1. What does pwd do? Prints the current working directory — tells you where you are in the filesystem.

  2. How do you list all files including hidden ones? ls -a. Files starting with . are hidden (like .bashrc).

  3. What’s the difference between cp file.txt ~/backups/ and mv file.txt ~/backups/? cp leaves the original in place and creates a copy in the destination. mv moves the file — the original is gone.

  4. What does mkdir -p a/b/c do? Creates the entire directory path at once. If a doesn’t exist, it creates a, then b inside a, then c inside b.

  5. How do you make an alias permanent? Add alias shortcut='long-command' to ~/.bashrc, then run source ~/.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

What is the difference between a shell and a terminal?
A shell (like Bash) is the program that interprets commands. A terminal is the window application that displays the shell. Think of the terminal as the phone and the shell as the person you’re talking to.
How do I see my command history?
Type history to see all previous commands numbered. Use !number to re-run a specific command by its number. Press Ctrl + R to search interactively.
What does ~ mean?
Shortcut for your home directory (e.g., /home/you). ~/Documents is the same as /home/you/Documents. The ~ is just less typing.
Why can’t I run my script with ./script.sh?
You need execute permission first. Run chmod +x script.sh to make it executable, then ./script.sh to run it.
How do I cancel a running command?
Press Ctrl + C. This sends the SIGINT signal that tells the current process to stop immediately.
What does echo do?
Prints text to the terminal. It’s like saying “repeat this back to me.” Used for displaying messages and writing to files.

Try It Yourself

Open your terminal and experiment:

  1. Run pwd to see where you are
  2. Run ls -la to see every file in your home directory
  3. Create a temporary directory with mkdir -p /tmp/bash-practice/hello
  4. Navigate into it with cd /tmp/bash-practice/hello
  5. Create a file with echo "I learned Bash" > test.txt
  6. Read it with cat test.txt
  7. 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

TutorialWhat You’ll Learn
Pipes & RedirectionChain commands with pipes, redirect output, use grep and sed
Shell ScriptsWrite reusable scripts with variables, loops, and functions
Linux System AdministrationManage 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