Table of Contents
Top 25 Bash CommandsHow to create your own custom Bash commandsBash command reference tableHow to use this cheat sheet effectivelyLearn commands by categoryPractice commands in a real terminalUse man pages to explore advanced featuresCombine commands with pipes and redirectsSuggested filter tags for interactive search UIsBash scripting fundamentalsWorking with variablesCreating and accessing variablesOutputHow this worksPractical exampleWhat this script doesUsing conditionalsBasic conditional syntaxPractical example: Checking if a file existsWhat this script doesUsing loopsUsing a for loopSyntax examplePractical example: Loop through filesWhat this script doesUsing a while loopSyntax examplePractical example: Print numbersWhat this script doesUsing functionsDefining a functionPractical example: Greeting functionWhat this script doesWhy Bash scripting mattersMini real-world example: Log cleanup scriptWhat this script doesBash scripting fundamentalsWorking with variablesBasic syntaxWhat this doesPractical script exampleScript explanationUsing conditionalsBasic syntaxPractical script example: Check if a file existsScript explanationUsing loopsUsing a for loopBasic syntaxPractical script example: Loop through filesScript explanationUsing a while loopBasic syntaxPractical script example: Print numbersScript explanationUsing functionsBasic syntaxPractical script exampleScript explanationWhy Bash scripting mattersMini real-world example: Backup scriptScript explanationWhere to go from hereContinue learning about Linux, Bash, and command line
Bash cheat sheet: Top 25 commands and creating custom commands

Bash cheat sheet: Top 25 commands and creating custom commands

18 mins read
May 13, 2026
Share
editor-page-cover

Being well-versed in the Bourne Again SHell (Bash Shell) as a developer or Linux user can significantly boost productivity. The Bash Shell is a Swiss Army knife of great features with deceptively simple commands, and it can provide far more flexible options for organizing and streamlining your workflow.

The Bash Shell is the most widely used command-line interface (CLI) available. Bash is a Unix shell and command language that is the default login shell for the majority of Linux distributions. It provides users with a set of tools for managing tasks on a Linux system.

Linux is an open-source operating system that is widely used in the tech industry. One of the key advantages of Linux is its command-line interface, which provides users with direct access to the underlying system and allows them to execute commands and scripts using a shell such as Bash. Bash commands perform a wide range of tasks, such as:

  • Creating, moving, renaming, and deleting files and directories
  • Comparing and merging files
  • Editing and manipulating text within files
  • Compressing and decompressing files
  • Scheduling tasks to run automatically
  • Networking and remote access

The advantage of using Bash commands to navigate Linux lies in its flexibility and versatility. Linux is an open-source OS, and provides users with control over the underlying system. This allows the users to customize and configure it to their specific needs.

By allowing users to tailor their environment to their specific needs, Bash and Linux enable a high level of personalization and efficiency. Some examples of possible customizations and configurations include aliases (custom shortcuts for frequently used commands or groups of commands), custom shell scripts to automate repetitive tasks, and options to fine-tune your environment variables to control the behavior of various applications running on your system.

This adaptability extends to Bash commands, which can be customized using bash scripts and command-line utilities. Linux offers a steady environment for executing Bash commands, ensuring that they can be ran consistently. This is especially vital in production environments where seamless automation and repeatability are a must.

In the following sections, we’ll introduce the most popular Bash commands, what they do, and how to extend them with options. Later on in this article, you’ll learn how to create your own custom commands (aliases), allowing you to create shortcuts for a single command or a group of commands.

When it comes down to it, if you don’t know the command line, you’re not using your computer to its full potential.

Check out the rest of this bash cheat sheet to get even more familiar with the command line concepts!

Top 25 Bash Commands#

Quick note: Anything encased in [ ] means that it’s optional. Some commands can be used without options or specifying files.

ls — List directory contents

ls is probably the most common command. A lot of times, you’ll be working in a directory and you’ll need to know what files are located there. The ls command allows you to quickly view all files within the specified directory.

  • Syntax: ls [option(s)] [file(s)]

  • Common options: -a, -l


echo — Prints text to the terminal window

echo prints text to the terminal window and is typically used in shell scripts and batch files to output status text to the screen or a computer file. Echo is also particularly useful for showing the values of environmental variables, which tell the shell how to behave as a user works at the command line or in scripts.

  • Syntax: echo [option(s)] [string(s)]

  • Common options: -e, -n


touch — Creates a file

touch is going to be the easiest way to create new files, but it can also be used to change timestamps on files and/or directories. You can create as many files as you want in a single command without worrying about overwriting files with the same name.

  • Syntax: touch [option(s)] file_name(s)

  • Common options: -a, -m, -r, -d


mkdir — Create a directory

mkdir is a useful command you can use to create directories. Any number of directories can be created simultaneously which can greatly speed up the process.

  • Syntax: mkdir [option(s)] directory_name(s)

  • Common options: -m, -p, -v


grep — search

grep is used to search text for patterns specified by the user. It is one of the most useful and powerful commands. There are often scenarios where you’ll be tasked to find a particular string or pattern within a file, but you don’t know where to start looking, that is where grep is extremely useful.

  • Syntax: grep [option(s)] pattern [file(s)]

  • Common options: -i, -c, -n


man — Print manual or get help for a command

The man command is your manual and is very useful when you need to figure out what a command does. For example, if you didn’t know what the command rmdir does, you could use the man command to find that out.

  • Syntax: man [option(s)] keyword(s)

  • Common options: -w, -f, -b


pwd — Print working directory

pwd is used to print the current directory you’re in. As an example, if you have multiple terminals going and you need to remember the exact directory you’re working within, then pwd will tell you.

  • Syntax: pwd [option(s)]

  • Common options: options aren’t typically used with pwd


cd — Change directory

cd will change the directory you’re in so that you can get info, manipulate, read, etc. the different files and directories in your system.

  • Syntax: cd [option(s)] directory

  • Common options: options aren’t typically used with cd


mv — Move or rename directory

mv is used to move or rename directories. Without this command, you would have to individually rename each file which is tedious. mv allows you to do batch file renaming which can save you loads of time.

  • Syntax: mv [option(s)] argument(s)

  • Common options: -i, -b


rmdir — Remove directory

rmdir will remove empty directories. This can help clean up space on your computer and keep files and folders organized. It’s important to note that there are two ways to remove directories: rm and rmdir. The distinction between the two is that rmdir will only delete empty directories, whereas rm will remove directories and files regardless if they contain data or not.

  • Syntax: rmdir [option(s)] directory_names

  • Common options: -p


locate — Locate a specific file or directory

This is by far the simplest way to find a file or directory. You can keep your search broad if you don’t know what exactly it is you’re looking for, or you can narrow the scope by using wildcards or regular expressions.

  • Syntax: locate [option(s)] file_name(s)

  • Common options: -q, -n, -i

Enjoying the article? Scroll down to sign up for our free, bi-monthly newsletter .

less — view the contents of a text file

The less command allows you to view files without opening an editor. It’s faster to use, and there’s no chance of you inadvertently modifying the file.

  • Syntax: less file_name

  • Common options: -e, -f, -n


compgen — Shows all available commands, aliases, and functions

compgen is a handy command when you need to reference all available commands, aliases, and functions.

  • Syntax: compgen [option(s)]

  • Common options: -a, -c, -d


> — redirect stdout

The > character is the redirect operator. This takes the output from the preceding command that you’d normally see in the terminal and sends it to a file that you give it. As an example, take echo “contents of file1” > file1. Here it creates a file called file1 and puts the echoed string into it.

  • Syntax: >

  • Common options: n/a


cat — Read a file, create a file, and concatenate files

cat is one of the more versatile commands and serves three main functions: displaying them, combining copies of them, and creating new ones.

  • Syntax: cat [option(s)] [file_name(s)] [-] [file_name(s)]

  • Common options: -n


| — Pipe

A pipe takes the standard output of one command and passes it as the input to another.

  • Syntax: |

  • Common options: n/a


head — Read the start of a file

By default, the head command displays the first 10 lines of a file. There are times when you may need to quickly look at a few lines in a file and head allows you to do that. A typical example of when you’d want to use head is when you need to analyze logs or text files that change frequently.

  • Syntax: head [option(s)] file(s)

  • Common options: -n


tail — Read the end of a file

By default, the tail command displays the last 10 lines of a file. There are times when you may need to quickly look at a few lines in a file and tail allows you to do that. A typical example of when you’d want to use tail is when you need to analyze logs or text files that change frequently.

  • Syntax: tail [option(s)] file_names

  • Common options: -n


chmod — Sets the file permissions flag on a file or folder

There are situations that you’ll come across where you or a colleague will try to upload a file or modify a document and you receive an error because you don’t have access. The quick fix for this is to use chmod. Permissions can be set with either alphanumeric characters (u, g, o) and can be assigned their access with w, r, x. Conversely, you can also use octal numbers (0-7) to change the permissions. For example, chmod 777 my_file will give access to everyone.

  • Syntax: chmod [option(s)] permissions file_name

  • Common options: -f, -v


exit — Exit out of a home directory

The exit command will close a terminal window, end the execution of a shell script, or log you out of an SSH remote access session.

  • Syntax: exit

  • Common options: n/a

Master the Bash Shell

Cover
Master the Bash Shell

A course for anyone interested in understanding all aspects of the bash shell. Designed for use by beginners, it assumes as little knowledge as possible but teaches you all the intricacies of bash it took me decades to learn by trial and error. The interactive nature of the course instills the knowledge in a way you will not forget!

10hrs
Beginner
248 Exercises
18 Quizzes

history — list your most recent commands

An important command when you need to quickly identify past commands that you’ve used.

  • Syntax: history

  • Common options: -c, -d


clear — Clear your terminal window

This command is used to clear all previous commands and output from consoles and terminal windows. This keeps your terminal clean and removes the clutter so you can focus on subsequent commands and their output.

  • Syntax: clear

  • Common options: n/a


cp — copy files and directories

Use this command when you need to back up your files.

  • Syntax: cp [option(s)] current_name new_name

  • Common options: -r, -i, -b


kill — terminate stalled processes

The kill command allows you to terminate a process from the command line. You do this by providing the process ID (PID) of the process to kill. To find the PID, you can use the ps command accompanied by options -aux.

  • Syntax: kill [signal or option(s)] PID(s)

  • Common options: -p


sleep — delay a process for a specified amount of time

sleep is a common command for controlling jobs and is mainly used in shell scripts. You’ll notice in the syntax that there is a suffix; the suffix is used to specify the unit of time whether it be s (seconds), m (minutes), or d (days). The default unit of time is seconds unless specified.

  • Syntax: sleep number [suffix]

  • Common options: n/a

How to create your own custom Bash commands#

Custom commands in Bash are known as “aliases”. Aliases are essentially an abbreviation or mean to avoid typing a long command sequence. They can save a great deal of typing at the command line so you can avoid having to remember complex combinations of commands and options. There is one caveat to using aliases, and that is to be sure you don’t overwrite any keywords.

  • Syntax: alias alias_name = “command_to_run”

A very simple example would look like this:

alias c = “clear”

Now every time you want to clear the screen, instead of typing in clear, you can just type c and you’ll be good to go.

You can also get more complicated, such as if you wanted to set up a web server in a folder:

alias www = ‘python -m SimpleHTTPServer 8000’

Here’s an example of a useful alias for when you need to test a website in different web browsers:

alias ff4 = ‘/opt/firefox/firefox’

alias ff13 = ‘/opt/firefox13/firefox’

alias chrome = ‘/opt/google/chrome/chrome’

Apart from creating aliases that make use of one command, you can also use aliases to run multiple commands such as:

alias name_goes_here = ‘activator && clean && compile && run’

While you can use aliases to run multiple commands, it’s recommended that you use functions as they’re considerably more flexible and allow you to do more complex logic and are great for writing scripts.

Bash command reference table#

The following Bash command reference table is designed to help you quickly find and understand commonly used Linux and Bash shell commands. Instead of memorizing everything at once, use this as a practical lookup guide while working in a real terminal.

The commands below are grouped into categories like file management, navigation, text processing, permissions, and process management so you can learn related commands together more naturally.

Command

Purpose

Basic syntax

Example

Common options

Category

ls

List files and directories

ls [options] [path]

ls -la

-a

,

-l

,

-h

Navigation

cd

Change directory

cd [directory]

cd Documents

..

,

~

Navigation

pwd

Show current directory path

pwd

pwd

None

Navigation

mkdir

Create a new directory

mkdir [directory]

mkdir projects

-p

File management

touch

Create an empty file

touch [file]

touch notes.txt

None

File management

cp

Copy files or directories

cp [source] [destination]

cp file.txt backup.txt

-r

,

-i

File management

mv

Move or rename files

mv [source] [destination]

mv old.txt new.txt

-i

File management

rm

Remove files or directories

rm [file]

rm temp.txt

-r

,

-f

File management

grep

Search text patterns

grep [pattern] [file]

grep "error" log.txt

-i

,

-n

,

-r

Text processing

cat

Display file contents

cat [file]

cat notes.txt

-n

Text processing

less

View file contents page by page

less [file]

less largefile.txt

None

Text processing

head

Show first lines of a file

head [file]

head report.txt

-n

Text processing

tail

Show last lines of a file

tail [file]

tail log.txt

-f

,

-n

Text processing

chmod

Change file permissions

chmod [permissions] [file]

chmod 755 script.sh

+x

,

-R

Permissions

history

Show command history

history

history

!number

Shell utilities

clear

Clear terminal screen

clear

clear

None

Shell utilities

kill

Stop a running process

kill [PID]

kill 1234

-9

Process management

sleep

Pause execution temporarily

sleep [seconds]

sleep 5

None

Process management

echo

Print text or variables

echo [text]

echo "Hello"

-e

Shell utilities

locate

Find files quickly

locate [filename]

locate notes.txt

-i

File management

man

Open command manual pages

man [command]

man grep

None

Shell utilities

|

Pipe output between commands

command1 | command2

ls | grep txt

None

Redirection and piping

>

Redirect output to a file

command > file

echo "Hi" > notes.txt

>>

Redirection and piping


How to use this cheat sheet effectively#

A Bash cheat sheet becomes much more useful when you treat it as a hands-on learning tool instead of something to memorize passively.

Learn commands by category#

Start with foundational categories like:

  • Navigation

  • File management

  • Text processing

This helps you build practical workflows naturally.

For example:

  • Use cd, ls, and pwd together for navigation

  • Use cp, mv, and rm together for file operations

Practice commands in a real terminal#

The fastest way to learn Bash is through repetition. Open a terminal and experiment with commands directly:

  • Create test folders

  • Copy files

  • Search text

  • Redirect command output

Real usage builds muscle memory much faster than reading alone.

Use man pages to explore advanced features#

Most Linux commands support dozens of additional options. When you want deeper understanding, use:

man command_name

For example:

man grep

This opens the full documentation for the command.

Combine commands with pipes and redirects#

One of Bash’s biggest strengths is composability.

You can chain commands together using pipes:

ls -la | grep txt

Or redirect output into files:

echo "Backup completed" > log.txt

As you grow more comfortable with Bash, combining small commands into larger workflows becomes one of the most powerful productivity skills you can develop.


Suggested filter tags for interactive search UIs#

  • Beginner-friendly

  • Frequently used

  • File operations

  • Navigation

  • Text processing

  • Process management

  • Permissions

  • Shell scripting

  • Redirection

  • Piping

  • Linux basics

  • Terminal essentials

Bash scripting fundamentals#

Learning individual Bash commands is useful, but the real power of Bash comes from combining commands into reusable scripts. Bash scripting allows you to automate repetitive tasks, simplify development workflows, and manage Linux systems more efficiently.

Even simple scripts can save significant time in day-to-day development and system administration. Once you understand variables, conditionals, loops, and functions, you can start building practical automation tools for real-world workflows.


Working with variables#

Variables store values that your script can reuse later. In Bash, variables are commonly used for:

  • Usernames

  • File paths

  • Configuration values

  • Command outputs

Unlike some programming languages, Bash variables are created without specifying a data type.

Creating and accessing variables#

NAME="Alice"echo $NAME

Output#

Alice

How this works#

The variable:

NAME="Alice"

stores the string "Alice".

The $ symbol retrieves the variable’s value:

echo $NAME

This prints the stored value to the terminal.

Practical example#

#!/bin/bashPROJECT="bash-cheatsheet"echo "Deploying project: $PROJECT"

What this script does#

This script stores a project name in a variable and prints a deployment message.

Output:

Deploying project: bash-cheatsheet

Variables make scripts more reusable because you can update values in one place instead of changing them throughout the script.


Using conditionals#

Conditionals allow scripts to make decisions based on conditions. Bash commonly uses:

  • if

  • elif

  • else

These statements help automate logic like:

  • Checking if files exist

  • Verifying user input

  • Running commands only when conditions are met

Basic conditional syntax#

if [ condition ]; thencommandselif [ another_condition ]; thencommandselsecommandsfi

Practical example: Checking if a file exists#

#!/bin/bashFILE="notes.txt"if [ -f "$FILE" ]; thenecho "File exists."elseecho "File not found."fi

What this script does#

The script checks whether notes.txt exists in the current directory.

The condition:

[ -f "$FILE" ]

tests if the file exists.

Possible outputs:

File exists.

or

File not found.

Conditionals are extremely common in automation scripts because they allow scripts to react dynamically to system conditions.


Using loops#

Loops help automate repetitive tasks by running commands multiple times. Instead of repeating commands manually, a loop can process:

  • Files

  • Numbers

  • Directories

  • Lists of values

Bash commonly uses:

  • for loops

  • while loops

Using a for loop#

A for loop iterates through a list of values.

Syntax example#

for item in listdocommandsdone

Practical example: Loop through files#

#!/bin/bashfor file in *.txtdoecho "Found file: $file"done

What this script does#

The loop searches for all .txt files in the current directory.

For every matching file, Bash:

  1. Stores the filename in the file variable

  2. Executes the echo command

Example output:

Found file: notes.txtFound file: report.txtFound file: tasks.txt

This is useful for batch processing tasks like:

  • Renaming files

  • Compressing logs

  • Running scripts on multiple files


Using a while loop#

A while loop runs as long as a condition remains true.

Syntax example#

while [ condition ]docommandsdone

Practical example: Print numbers#

#!/bin/bashCOUNT=1while [ $COUNT -le 5 ]doecho "Number: $COUNT"COUNT=$((COUNT + 1))done

What this script does#

The script:

  1. Starts with COUNT=1

  2. Prints the current number

  3. Increments the counter

  4. Repeats until the value reaches 5

Output:

Number: 1Number: 2Number: 3Number: 4Number: 5

while loops are useful when the number of iterations depends on runtime conditions.


Using functions#

Functions allow you to group reusable commands into a single block. Instead of duplicating logic throughout a script, you can define a function once and call it whenever needed.

Functions improve:

  • Readability

  • Reusability

  • Script organization

Defining a function#

function_name() {commands}

Practical example: Greeting function#

#!/bin/bashgreet() {echo "Hello $1"}greet "Alice"greet "Bob"

What this script does#

The function:

greet()

accepts an argument using $1.

When called:

greet "Alice"

the function prints:

Hello Alice

Output:

Hello AliceHello Bob

Functions are especially useful in larger scripts where the same logic appears multiple times.


Why Bash scripting matters#

Bash scripting is one of the most practical automation skills for developers and Linux users.

Even simple scripts can automate:

  • File backups

  • Log cleanup

  • Application deployment

  • Server monitoring

  • Batch processing tasks

Bash is heavily used in:

  • DevOps workflows

  • CI/CD pipelines

  • Cloud infrastructure automation

  • Linux system administration

  • Deployment scripting

Because Linux powers many servers and cloud environments, Bash scripting remains an important skill for careers in DevOps, cloud engineering, and systems administration.


Mini real-world example: Log cleanup script#

The following script deletes old log files automatically.

#!/bin/bashLOG_DIR="./logs"echo "Cleaning old log files..."find $LOG_DIR -name "*.log" -mtime +7 -deleteecho "Cleanup completed."

What this script does#

This script:

  1. Searches the logs directory

  2. Finds .log files older than 7 days

  3. Deletes them automatically

Output:

Cleaning old log files...Cleanup completed.

This type of automation is common in:

  • Server maintenance

  • CI/CD workflows

  • Scheduled cron jobs

  • Production infrastructure management

Even small Bash scripts like this can save hours of repetitive manual work over time.

Bash scripting fundamentals#

Learning individual Bash commands is a great starting point, but the real productivity boost comes from combining those commands into reusable scripts. Bash scripting allows you to automate repetitive tasks, simplify development workflows, and manage Linux systems more efficiently.

Even basic scripts can save hours of manual work over time. Once you understand variables, conditionals, loops, and functions, you can start building small automation tools that make command-line work faster and more reliable.


Working with variables#

Variables allow you to store and reuse values inside a script. In Bash, variables are commonly used for:

  • File paths

  • Usernames

  • Configuration values

  • Command output

  • Reusable text

Unlike some programming languages, Bash variables do not require a data type declaration.

Basic syntax#

NAME="Alice"echo $NAME

What this does#

The line:

NAME="Alice"

creates a variable named NAME.

The $ symbol retrieves the stored value:

echo $NAME

Output:

Alice

Practical script example#

#!/bin/bashPROJECT="inventory-app"echo "Starting deployment for $PROJECT"

Script explanation#

This script stores a project name in a variable and prints a deployment message.

Possible output:

Starting deployment for inventory-app

Variables make scripts easier to maintain because you can update values in one place instead of modifying multiple commands manually.


Using conditionals#

Conditionals allow Bash scripts to make decisions. They help scripts respond differently depending on:

  • File existence

  • User input

  • Command success or failure

  • System conditions

Bash commonly uses:

  • if

  • elif

  • else

Basic syntax#

if [ condition ]; thencommandselif [ another_condition ]; thencommandselsecommandsfi

Practical script example: Check if a file exists#

#!/bin/bashFILE="

Script explanation#

The condition:

[ -f "$FILE" ]

checks whether the file exists.

If the file is present, the script prints:

Backup file found.

Otherwise, it prints:

Backup file missing.

Conditionals are essential in automation because they allow scripts to handle different situations intelligently.


Using loops#

Loops automate repetitive tasks by running commands multiple times. Instead of manually repeating commands, a loop can process:

  • Files

  • Numbers

  • Directories

  • Lists of items

Bash commonly uses:

  • for loops

  • while loops

Using a for loop#

A for loop iterates through a list of values.

Basic syntax#

for item in listdocommandsdone

Practical script example: Loop through files#

#!/bin/bashfor file in *.txtdoecho "Processing file: $file"done

Script explanation#

This script searches for all .txt files in the current directory.

For each matching file, Bash:

  1. Stores the filename in the file variable

  2. Runs the echo command

Possible output:

Processing file: notes.txtProcessing file: report.txtProcessing file: tasks.txt

This type of loop is useful for:

  • Batch file processing

  • File renaming

  • Automated backups

  • Running repetitive commands


Using a while loop#

A while loop continues running as long as a condition remains true.

Basic syntax#

while [ condition ]docommandsdone

Practical script example: Print numbers#

#!/bin/bashCOUNT=1while [ $COUNT -le 5 ]doecho "Current number: $COUNT"COUNT=$((COUNT + 1))done

Script explanation#

This script:

  1. Starts with COUNT=1

  2. Prints the current value

  3. Increments the counter

  4. Repeats until the value becomes greater than 5

Output:

Current number: 1Current number: 2Current number: 3Current number: 4Current number: 5

while loops are especially useful when the number of repetitions depends on runtime conditions.


Using functions#

Functions help organize reusable logic inside a script. Instead of writing the same commands repeatedly, you can define them once and call them whenever needed.

Functions improve:

  • Readability

  • Maintainability

  • Reusability

Basic syntax#

function_name() {commands}

Practical script example#

#!/bin/bashgreet() {echo "Hello $1"}greet "Alice"greet "Bob"

Script explanation#

The function:

greet()

accepts an argument using $1.

When the function is called:

greet "Alice"

the value "Alice" replaces $1.

Output:

Hello AliceHello Bob

Functions become extremely useful in larger scripts where the same logic appears multiple times.


Why Bash scripting matters#

Bash scripting is one of the most practical automation skills for developers and Linux users.

Even small scripts can automate:

  • File management

  • Backups

  • Deployment workflows

  • Log cleanup

  • Server monitoring

  • Repetitive terminal tasks

Bash scripting is widely used in:

  • DevOps workflows

  • CI/CD pipelines

  • Linux administration

  • Cloud infrastructure automation

  • Deployment engineering

Because Linux powers many servers and cloud environments, Bash scripting is also a valuable skill for careers in DevOps, cloud engineering, and systems administration.

Mini real-world example: Backup script#

The following script creates a backup of a project directory automatically.

#!/bin/bashSOURCE_DIR="project"BACKUP_FILE="project-backup.tar.gz"echo "Creating backup..."tar -czf $BACKUP_FILE $SOURCE_DIRecho "Backup completed: $BACKUP_FILE"

Script explanation#

This script:

  1. Defines the source directory

  2. Creates a compressed backup archive

  3. Saves the archive as project-backup.tar.gz

Possible output:

Creating backup...Backup completed: project-backup.tar.gz

Scripts like this are commonly used for:

  • Automated backups

  • Deployment workflows

  • Scheduled maintenance tasks

  • CI/CD automation

Even simple Bash scripts can dramatically improve productivity by reducing repetitive manual work.

Where to go from here#

Now that you’re armed with the top commands and how to customize them from this command line cheat sheet, you can put them into practice.

Master the Bash Shell will give you an understanding of all the core concepts you need to gain complete control over your system. Ian Miell, the author of Learn Bash the Hard Way, created this course to teach you all the intricacies of Bash and Linux that took him decades to learn by trial and error.

Happy learning!

Frequently Asked Questions

What are the basic Bash commands?

Here are some basic Bash commands:

  • ls: Lists directory contents
  • cd: Changes the current directory
  • pwd: Prints the current working directory
  • mkdir: Creates a new directory
  • rm: Removes files or directories

Written By:
Cameron Wilson