Bash Cheat Sheet

Bash Cheat Sheet: Linux Commands and Scripting Guide

April 1st, 2026
1024
10:00 Minutes

Want to improve your Bash (Bourne Again SHell) and Bash Shell skills? This Bash Cheat sheet could be your handy shortcut. It is designed to help beginners quickly understand and recall the most important Bash concepts and commands.

It focuses on the important commands you will actually use while working with Linux systems, servers or development environments. Each section is written in simple language and structured for fast revision, which makes it useful for learning, interview preparation and daily terminal usage. Let’s begin!

What is Bash?

Bash is a command-line interpreter used to interact with Unix-based operating systems such as Linux and macOS. It allows users to execute commands, automate tasks using scripts, manage files, control processes and work efficiently without a graphical interface.

Bash is mostly used by developers, system administrators and DevOps engineers due to its powerful text processing, job control and scripting capabilities. It is also the default shell in most Linux distributions. This makes it essential to learn for anyone working with servers, cloud platforms or open-source systems.

In real-world environments, Bash is widely used to manage cloud servers, automate deployments and monitor application logs. System administrators often use Bash to troubleshoot production issues while DevOps engineers rely on Bash scripts inside CI/CD pipelines to automate repetitive infrastructure tasks.

Basic Bash Commands

Basic Bash commands are used for everyday tasks like navigating directories, managing files and viewing system information. These commands form the foundation of Bash usage and are usually the first things beginners learn.

Understanding them helps users move around the file system, create or delete files and check where they are working from within the terminal.

Common Bash Commands

  • pwd – Shows the current directory
  • ls – Lists files and folders
  • cd – Changes directory
  • clear – Clears the terminal screen

pwd
ls
cd Documents

File and Directory Management

File and directory management commands help users create, copy, move, rename and delete files or folders. These commands are critical when working on servers where graphical file managers are unavailable. Bash provides simple yet powerful tools to handle large directory structures efficiently.

Key Commands

  • mkdir – Create a directory
  • rmdir – Remove empty directory
  • touch – Create an empty file
  • cp – Copy files
  • mv – Move or rename files

mkdir projects
touch notes.txt
cp notes.txt backup.txt
mv backup.txt archive.txt

Note: Be careful while using delete commands such as rm, especially with options like -r or -rf, because they permanently remove files and directories. Always double-check the path before executing destructive commands.

Viewing and Reading Files

Bash provides multiple commands to view file contents without opening them in an editor. These commands allow quick inspection of logs, configuration files, and text data, which is especially useful for troubleshooting and monitoring systems.

Common Commands

  • cat – Displays full file content
  • less – Scroll through file content
  • more – Page-by-page view
  • head – Shows first lines of a file
  • tail – Shows last lines of a file

cat file.txt
head -5 file.txt
tail -10 file.txt

File Permissions and Ownership

File permissions control who can read, write or execute a file. Bash uses a permission model that enhances system security by restricting unauthorized access. Understanding permissions is essential when working with scripts, shared servers and production environments.

Important Commands

  • chmod – Change file permissions
  • chown – Change file owner
  • ls -l – View permissions

touch demo.txt
ls -l demo.txt
chmod 600 demo.txt
ls -l demo.txt

Searching and Text Processing

Bash offers powerful text-search and processing tools that allow users to filter, search and manipulate text files. These commands are heavily used in log analysis, data processing and automation tasks.

Common Commands

  • grep – Search text patterns
  • wc – Count lines, words, characters
  • sort – Sort lines
  • uniq – Remove duplicates

grep "error" log.txt
wc -l log.txt
sort names.txt | uniq

Variables in Bash

Variables in Bash store data such as strings or numbers that can be reused in scripts or commands. They make scripts dynamic and flexible, allowing users to pass values and control program behavior.

Rules

  • No spaces around =
  • Access variables using $

name="Sanjay"
echo $name

Read Also: Variables and Data Types in Go

Conditional Statements

Conditional statements allow Bash scripts to make decisions based on conditions. They are used to execute commands only when specific criteria are met such as checking file existence or comparing values.

Common Keywords

  • if
  • else
  • elif
  • fi

if [ -f file.txt ]
then
  echo "File exists"
else
  echo "File not found"
fi

Loops in Bash

Loops enable repeated execution of commands. They are useful for automating repetitive tasks such as processing multiple files or running checks at intervals.

Types of Loops

  • for
  • while
  • until

for i in 1 2 3
do
  echo $i
done

Bash Scripts

A Bash script is a file containing multiple Bash commands executed sequentially. Scripts help automate tasks, reduce manual work and ensure consistency in system operations.

Basic Script Structure

  • Starts with shebang #!/bin/bash
  • Contains executable commands

#!/bin/bash
echo "Hello, Bash!"

Useful Bash Shortcuts

Keyboard shortcuts improve productivity by reducing typing and speeding up command execution.

Common Shortcuts

  • Ctrl + C – Stop running command
  • Ctrl + Z – Pause command
  • Ctrl + L – Clear screen
  • Tab – Auto-complete

Read Also: Excel Keywords Shortcuts

Advanced Yet Useful Bash Commands

These advanced commands are commonly used for file searching, recursive log scanning, structured text extraction and bulk text replacement. They are especially helpful when working with large datasets, server logs or automation tasks.

find . -name "*.txt"
grep -r "error" .
awk '{print $1}' file.txt
sed 's/old/new/g' file.txt

Where Bash Is Used in Industry?

Bash is widely used in Linux-based servers, cloud platforms and DevOps environments. It is commonly used to automate deployments, manage Docker containers, configure servers and process log files. Many CI/CD tools execute Bash scripts during build and deployment stages. Because of this, Bash remains an essential skill for developers, system administrators and DevOps professionals.

Wrapping Up

Bash is a foundational skill for anyone working with Linux, cloud platforms or DevOps tools. Once you understand basic commands, file handling, permissions and scripting concepts, working in the terminal becomes much faster and more efficient.

This Bash cheat sheet covered the most commonly used features to help you build confidence without unnecessary complexity. Regular practice and small scripting exercises will strengthen your command over Bash and prepare you for real-world tasks as well as technical interviews.

FAQs on Bash Cheat Sheet

Q1. Is Bash the same as Linux?

Bash is not Linux itself. Linux is an operating system and Bash is a shell that runs on Linux and allows users to interact with the system using commands. Bash acts as a bridge between the user and the operating system.

Q2. Do I need Bash if I use a GUI?

Learning Bash is useful even if you use a graphical interface. Many advanced tasks, server environments and automation workflows rely heavily on command-line operations where Bash is essential.

Q3. Is Bash scripting hard for beginners?

Bash scripting is beginner-friendly when learned step by step. Starting with basic commands, variables and conditions makes it easy to understand. Complexity increases only when you begin writing advanced automation scripts.

Q4. Where is Bash commonly used?

Bash is widely used in Linux systems, cloud servers, DevOps pipelines, system administration and automation scripts. It is also commonly used in CI/CD workflows and server maintenance tasks.

Q5. How long does it take to learn Bash basics?

Most beginners can learn Bash basics within a few days of regular practice. Mastering scripting and advanced usage may take a few weeks depending on hands-on experience.

Q6. Is it possible to damage the system using Bash commands?

Yes, certain commands like file deletion or permission changes can cause issues if used incorrectly. However, understanding commands before running them and avoiding system-level directories reduces risks significantly.

About Author

Sanjay Prajapat - Technical Content Strategist

Connect on LinkedIn

This Article is written by Sanjay Prajapat, a professional Technical Content Strategist and Writer, known for delivering expert-level content across technology, software development, AI, digital transformation, and business intelligence.

His content is driven by deep research, real user intent, and insights gathered with the support of experienced professionals, ensuring every article delivers clarity, credibility, and long-term value.


Explore Our Trending Articles-

Course Schedule

Course NameBatch TypeDetails
Bash Scripting Training
Every WeekdayView Details
Bash Scripting Training
Every WeekendView Details
About the Author
Sanjay Prajapat
About the Author

Sanjay Prajapat is a Data Engineer and technology writer with expertise in Python, SQL, data visualization, and machine learning. He simplifies complex concepts into engaging content, helping beginners and professionals learn effectively while exploring emerging fields like AI, ML, and cybersecurity in today’s evolving tech landscape.

Drop Us a Query
Fields marked * are mandatory
×

Your Shopping Cart


Your shopping cart is empty.