Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
Bash Script - Define Bash Variables and its types
Next article icon

Bash Scripting - Introduction to Bash and Bash Scripting

Last Updated : 28 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Bash is a command-line interpreter or Unix Shell and it is widely used in GNU/Linux Operating System. It is written by Brian Jhan Fox. It is used as a default login shell for most Linux distributions. Scripting is used to automate the execution of the tasks so that humans do not need to perform them individually. Bash scripting is a great way to automate different types of tasks in a system. Developers can avoid doing repetitive tasks using bash scripting. 

Bash is like a robot assistant for your computer. It lets you control your Linux/Unix system by typing commands (e.g., ls to list files). Instead of doing tasks manually, you can write a Bash script—a text file with commands—to automate things like organizing files, installing software, or backing up data.

How to Write Your First Bash Script

Let’s create a simple script that says "Hello, World!":

  • First, we will create a file with the .sh extension.
  • Next, we will write down the bash scripts within it
  • After that, we will provide execution permission to it.

1. Create a Script File:

Open a terminal and type:

gedit hello.sh       # Creates a file named "hello.sh"  

2. Add Code:

Type these lines into the file:

#!/bin/bash                # Tells the computer: "Use Bash to run this!"  
echo "Hello, World!" # Prints "Hello, World!" on the screen

3. Make It Executable:

Save the file, then type:

chmod +x hello.sh        # Gives permission to run the script   

4. Run It:

Use the below command to execute the script:

./hello.sh 

Here the script file name is gfg.sh.

Now we can also write more complicated commands using Bash Scripts. Here is an example below in which we are using a condition statement -

Example Script:

#!/bin/bash         
Age=17
if [ "$Age" -ge 18 ]; then
echo "You can vote"
else
echo "You cannot vote"
fi

Output:

You cannot vote

Here is the terminal shell pictorial depiction after executing the above script as follows:  

In the above way, we can execute multiple Bash commands all at once.

Key Concepts of Bash Scripting

Here are some key concept of bash scripti:

File Names and Permissions

In the above example, we have saved the file using gfg.sh name and also provided execute permission using chmod command. Now, let's understand why we have done that. 

While writing bash scripts we should save our file with the .sh extension, so that the Linux system can execute it. When we first create a file with the .sh extension, it doesn't have any execute permission and without the execute permission the script will not work. So, we should provide execute permission to it using the chmod command. 

The filename of a bash script can be anything but by convention, it is recommended to use snake case ( my_bash_script.sh ) or hyphens ( my-bash-script.sh ) for naming a script file.

Variables in bash

We can use variables in bash scripting. Below is a sample program to understand the usage of variables in Bash scripts.

Example Script:

Name="SATYAJIT GHOSH"
Age=20

echo "The name is $Name and Age is $Age"

Output of Variables:

The name is SATYAJIT GHOSH and Age is 20

So, here is have declared two variables Name and another one is Age. These variables are accessible using $Name and $Age. That means, we can declare a variable in a bash script using VariableName=Value and can access it using $VariableName. Here is the terminal shell pictorial depiction after executing the above script as follows:  

There are two types of variables present within Bash Scripting. Conventionally, If a variable, is declared inside a function then it is generally a local variable and if it is declared outside then it is a global variable. In the case of a bash script, this concept is a little bit different, here any variable whether it is written inside a function or outside a function by default is a global variable. If we want to make a local variable then we need to use the keyword "local".

Note: It is best practice to always use a local variable inside a function to avoid any unnecessary confusion.  

An example of the same is given below -

Example Script:

#!/bin/bash

var1="Apple" #global variable
myfun(){
local var2="Banana" #local variable
var3="Cherry" #global variable
echo "The name of first fruit is $var1"
echo "The name of second fruit is $var2"
}
myfun #calling function

echo "The name of first fruit is $var1"
#trying to access local variable
echo "The name of second fruit is $var2"
echo "The name of third fruit is $var3"

Output of local and global variables:

The name of first fruit is Apple
The name of second fruit is Banana
The name of first fruit is Apple
The name of second fruit is
The name of third fruit is Cherry

Here in this above example, var2 is a local variable, so when we are accessing it from the function it is doing fine but when we are trying to access it outside the function, it is giving us an empty result in the output.

On the other hand, unlike programming languages, even though var3 is defined inside a function still it is acting as a global variable and it can be accessed outside the function. Below is the terminal shell depiction after executing the script -

For more details refer Shell Scripting – Shell Variables

Input and Output in bash

Input & output are fundamental concepts for shell scripting. A script can take one or more inputs and can also produce zero or many outputs. It may even produce some errors.  Let's understand this with an example -

Example Script:

echo "Enter filename"
read filename

if [ -e $filename ]
then
echo "$filename is exits on the directory"
cat $filename

else
cat > $filename
echo "File created"
fi

Output of Input & Output:

First time:

Enter filename
geeks.txt
Hello Geek
File created

Second time:

Enter filename
geeks.txt
geeks.txt is exits on the directory
Hello Geek

So, in this above example the first time, the script could not find any file with that file name, and the else block gets executed. It created the file and put some data into that file. When we run it a second time with the same file name, then it finds the file. So, is the if block gets executed and that displays the contents of the file.  Reading the file contents is input and on the first time putting data into the file is considered to be output. Here we have used > for storing the content in a file.  The > notation is used to redirect stdout to a file. On the other hand, we can use  2> notation to redirect stderr, and &>  to redirect both stdout and stderr.

Below is the terminal shell pictorial depiction after executing the following script - 

For more details refer Shell Scripting – Standard Input, Output and Error

Functions used in bash

In programming, A function is a block of code that performs some tasks and it can be called multiple times for performing tasks. The simplest example of the use of function in Bash scripting can be given as -

Example:

#!/bin/bash
#It is a function
myFunction () {
echo Hello World from GeeksforGeeks
}

#function call
myFunction

Output of Functions:

Hello World from GeeksforGeeks

The above example shows a function that prints something when called.

So, the basic syntax for writing functions within a Bash Script will be -

Syntax of Functions:

#for defining
function_name(){
commands
.....
}

function_name # for calling

Besides this, we can also have functions with passing arguments and with return values.

For more details refer Bash Scripting – Functions

Decision Making in bash

In programming, Decision Making is one of the important concepts. The programmer provides one or more conditions for the execution of a block of code. If the conditions are satisfied then those block of codes only gets executed.

Two types of decision-making statements are used within shell scripting. They are -

1. If-else statement:

If else statement is a conditional statement. It can be used to execute two different codes based on whether the given condition is satisfied or not.

There are a couple of varieties present within the if-else statement. They are -

  • if-fi 
  • if-else-fi 
  • if-elif-else-fi 
  • nested if-else

The syntax for the simplest one will be -

Syntax of If-else statement:

if [ expression ]; then

statements

Example Script:

Name="Satyajit"
if [ "$Name" = "Satyajit" ]; then
echo "His name is Satyajit. It is true."

Output of if-else statement:

His name is Satyajit. It is true.

In the above example, during the condition checking the name matches and the condition becomes true. Hence, the block of code present within the if block gets executed. In case the name doesn't match then will not have an output. Below is the terminal shell pictorial depiction after executing the following script - 

2. case-sac statement:

case-sac is basically working the same as switch statement in programming. Sometimes if we have to check multiple conditions, then it may get complicated using if statements. At those moments we can use a case-sac statement. The syntax will be -

Syntax of case-sac statement:

case $var in
Pattern 1) Statement 1;;
Pattern n) Statement n;;
esac

Example Script:

Name="Satyajit"
case "$Name" in
#case 1
"Rajib") echo "Profession : Software Engineer" ;;

#case 2
"Vikas") echo "Profession : Web Developer" ;;

#case 3
"Satyajit") echo "Profession : Technical Content Writer" ;;
esac

Output of case-sac statement:

Profession : Technical Content Writer

In the above example, the case-sac statement executed the statement which is a part of the matched pattern here the 'Name'. Below is the terminal shell pictorial depiction after executing the following script - 

For more details refer Shell Scripting – Decision Making

String and Numeric Comparisons

The string comparison means in the shell scripting we can take decisions by doing comparisons within strings as well. Here is a descriptive table with all the operators -

OperatorDescription
==Returns true if the strings are equal
!= Returns true if the strings are not equal
-nReturns true if the string to be tested is not null
-zReturns true if the string to be tested is null

Arithmetic operators are used for checking the arithmetic-based conditions. Like less than, greater than, equals to, etc. Here is a descriptive table with all the operators -

OperatorDescription
-eqEqual
-geGreater Than or Equal
-gtGreater Than
-leLess Than or Equal
-ltLess Than
-neNot Equal

Below is a simple example of the same -

Example Script:

if [ 10 -eq 10 ];then
echo "Equal"
fi

if [ 'Geeks' == 'Geeks' ];
then
echo "same" #output
else
echo "not same"
fi

Output of String and Numeric Comparisons:

Equal
same

In this example first one  (-eq )is a numeric comparison that checks for equality. The second one ( == ) is also check for equality but in strings.  Below is the terminal shell pictorial depiction after executing the following script - 

For more details refer Bash Scripting – String

Applications of Bash Scripts:

  • Automate Repetitive Work: Substitute scripts for manual labor in activities such as renaming files, organizing directories, or issuing alerts.
  • System Updates & Maintenance:  Schedule scripts to update software, remove temporary files, or monitor disk space.
  • Data Processing & Reporting: Scripts can install programs, configure servers, or roll out code to production.
  • Back Up Databases & Files: Schedule scripts to back up important data to cloud storage or external drives.
  • Monitor Systems & Networks: Test server health, monitor downtime, or notify you if a site crashes.
  • Make Custom Tools: Develop mini-apps for unique purposes (e.g., password generators, mass image converters).
  • Schedule Tasks using Cron: Run scripts every hour, day, or year with Bash and cron (Linux scheduler).
  • Manage Files & Permissions: Batch modify file permissions, search/delete big files, or clean cluttered folders.
  • Cross-Platform Scripting: Bash scripts are compatible with Linux, macOS, and Windows (through WSL or Git Bash).

Advantages of Bash Scripts:

  • Easy and Easy to Code: Bash scripts are coded in plain text with easy Linux commands. If you already know how to use the Linux terminal, you can easily write a bash script by putting those commands in a.sh file.
  • Saves Time and Effort: Rather than repeating the same command over and over, a bash script does it all for you at once. This is particularly useful for sysadmins and developers who have to work with multiple systems or environments and is also handy
  • Useful for Scheduling Jobs: You can automate your bash scripts to execute at a given time using tools such as cron—perfect for regular backups, log rotation, or software updates.
  • Running Multiple Commands: One bash script can execute multiple commands sequentially. This simplifies complex tasks such as installing a new server, deploying code, or configuring system parameters.

Disadvantages of Bash Scripts:

  • Errors Can Be Risky: If you make a small mistake in your script—like deleting the wrong folder or overwriting files—it can lead to serious problems. Bash doesn't have a "undo" button, so testing scripts carefully is verySlower Compared to Compiled Languages important.
  • Each Command Starts a New Process: Every shell command inside a bash script starts a new process. This uses more system resources and can slow things down, especially if the script runs hundreds of commands.
  • Slower Compared to Compiled Languages: Since bash is an interpreted language, scripts run slower than compiled programs (like those written in C or Java). For small tasks, it’s fine, but for performance-heavy tasks, it's not the best choice.
  • Compatibility Issues Across Systems: Scripts written on one Linux distribution (like Ubuntu) might not work the same way on another (like CentOS) due to different shell environments or command paths. You need to test your script on the target system to ensure smooth execution.

Also Read:

  • Bash Scripting – Working of Bash Scripting
  • Shell Script Examples
  • Bash Scripting – For Loop

Conclusion

In this article we discuss Bash scripting which plays a vital role in automating tasks within the Linux environment. As a command-line interpreter, Bash offers simplicity and ease of use for developers to create scripts that streamline routine operations, manipulate files, and execute complex tasks. While Bash scripts can enhance productivity by avoiding repetitive actions and executing sequences of commands efficiently, they also come with considerations such as managing permissions, handling variables, and implementing decision-making structures. By mastering Bash scripting, users can harness its power to optimize their workflow and enhance system administration tasks on Linux platforms.


Next Article
Bash Script - Define Bash Variables and its types

S

satyajit1910
Improve
Article Tags :
  • Linux-Unix
  • Bash-Script

Similar Reads

    Linux/Unix Tutorial
    Linux is one of the most widely used open-source operating systems. It's fast, secure, stable, and powers everything from smartphones and servers to cloud platforms and IoT devices. Linux is especially popular among developers, system administrators, and DevOps professionals.Linux is:A Unix-like OS
    10 min read

    Getting Started with Linux

    What is Linux Operating System
    The Linux Operating System is a type of operating system that is similar to Unix, and it is built upon the Linux Kernel. The Linux Kernel is like the brain of the operating system because it manages how the computer interacts with its hardware and resources. It makes sure everything works smoothly a
    13 min read
    LINUX Full Form - Lovable Intellect Not Using XP
    LINUX stands for Lovable Intellect Not Using XP. Linux was developed by Linus Torvalds and named after him. Linux is an open-source and community-developed operating system for computers, servers, mainframes, mobile devices, and embedded devices. Linux receives requests from system programs and it r
    2 min read
    Difference between Linux and Windows
    Linux: Linux could be a free and open supply OS supported operating system standards. It provides programming interface still as programme compatible with operating system primarily based systems and provides giant selection applications. A UNIX operating system additionally contains several several
    7 min read
    What are Linux Distributions ?
    A Linux distribution, often shortened to “distro,” is a packaged version of Linux that comes with the Linux kernel plus a collection of software and utilities that make the OS functional and user-friendly. Some distros are optimized for business environments, offering tools for productivity and ente
    8 min read
    Difference between Unix and Linux
    Unix was created in the 1970s by Ken Thompson and Dennis Ritchie at Bell Labs. Dennis Ritchie was also the creator of the C programming language. Originally a command-line operating system, Unix has evolved to support graphical interfaces (GUI) as well. It became popular in universities, enterprises
    5 min read

    Installation with Linux

    How to Install Arch Linux in VirtualBox?
    Installing Arch Linux on a virtual machine is an excellent way to experience this powerful and flexible Linux distribution without affecting your main system. If you're looking to install Arch Linux in VirtualBox, this guide will take you through the process step-by-step. Arch Linux is known for its
    7 min read
    Fedora Linux Operating System
    Fedora Linux is a free and open-source operating system based on the Linux kernel and was developed by the community-supported Fedora Project. It is known for its fast release cycle, which keeps the operating system up to date with the latest software and technologies.What is the Fedora Linux Operat
    12 min read
    How to install Ubuntu on VirtualBox?
    Installing Ubuntu on VirtualBox is a great way to experience the powerful features of this popular Linux distribution without altering your main operating system. Whether you’re a developer, a student, or simply curious about Linux, setting up Ubuntu on VirtualBox allows you to test and explore in a
    6 min read
    How to Install Linux Mint?
    Linux Mint is the second-largest Linux-based distro used in the world. Linux Mint is a community-driven Linux distribution based on Ubuntu which itself is based on Debian and bundled with a variety of free and open-source applications. So here we discuss the installation of Linux mint. Installation
    3 min read
    How to Install Kali Linux on Windows?
    Kali Linux is an open-source Linux distribution based on Debian, designed for sophisticated penetration testing and security auditing. Kali Linux includes hundreds of tools for diverse information security activities such as penetration testing, security research, computer forensics, and reverse eng
    2 min read
    How to Install Linux on Windows PowerShell Subsystem?
    There are several ways to Install a Linux subsystem on your Windows PC Powershell Environment. It is good for learners, but it is recommended using original Linux OS if you are a developer as the Subsystem lacks the pre-installed Linux tools. Before we begin installing a Linux subsystem, we need to
    2 min read
    How to Find openSUSE Linux Version?
    openSUSE is well known for its GNU/Linux-based operating systems, mainly Tumbleweed, a tested rolling release, and Leap, a distribution with Long-Term-Support(LTS). MicroOS and Kubic are new transactional, self-contained distributions for use as desktop or container runtime. Here we figure out which
    2 min read
    How to Install CentOS
    CentOS is a popular open-source Linux distribution aimed at servers and provides compatibility with Red Hat's RPM package manager. It is built with the goal of providing a stable operating system that provided great compatibility with the upstream RHEL (Red hat enterprise Linux) CentOS is therefore
    2 min read

    Linux Commands

    Linux Commands
    Linux commands are essential for controlling and managing the system through the terminal. This terminal is similar to the command prompt in Windows. It’s important to note that Linux/Unix commands are case-sensitive. These commands are used for tasks like file handling, process management, user adm
    15+ min read
    Essential Unix Commands
    Unix commands are a set of commands that are used to interact with the Unix operating system. Unix is a powerful, multi-user, multi-tasking operating system that was developed in the 1960s by Bell Labs. Unix commands are entered at the command prompt in a terminal window, and they allow users to per
    7 min read
    How to Find a File in Linux | Find Command
    The find command in Linux is used to search for files and directories based on name, type, size, date, or other conditions. It scans the specified directory and its sub directories to locate files matching the given criteria.find command uses are:Search based on modification time (e.g., files edited
    9 min read

    Linux File System

    Linux File System
    A file system is a structured method of storing and managing data—including files, directories, and metadata—on your machine. Think of it like a library. If thousands of books were scattered around, finding one would be hard. But in an organized structure, like labeled shelves, locating a book becom
    12 min read
    Linux File Hierarchy Structure
    The Linux File Hierarchy Structure or the Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Unix-like operating systems. It is maintained by the Linux Foundation. In the FHS, all files and directories appear under the root directory /, even if they are sto
    6 min read
    Linux Directory Structure
    In Linux, everything is treated as a file even if it is a normal file, a directory, or even a device such as a printer or keyboard. All the directories and files are stored under one root directory which is represented by a forward slash /. The Linux directory layout follows the Filesystem Hierarchy
    6 min read

    Linux Kernel

    Linux Kernel
    Linux Kernel is the heart of Linux operating systems. It is an open-source (source code that can be used by anyone freely) software that is most popular and widely used in the industry as well as on a personal use basis. Who created Linux and why? Linux was created by Linus Torvalds in 1991 as a hob
    4 min read
    Kernel in Operating System
    A kernel is the core part of an operating system. It acts as a bridge between software applications and the hardware of a computer. The kernel manages system resources, such as the CPU, memory, and devices, ensuring everything works together smoothly and efficiently. It handles tasks like running pr
    10 min read
    How Linux Kernel Boots?
    Many processes are running in the background when we press the system's power button. It is very important to learn the Linux boot process to understand the workings of any operating system. Knowing how the kernel boots is a must to solve the booting error. It is a very interesting topic to learn, l
    11 min read
    Difference between Operating System and Kernel
    In the world of computing, two terms that are frequently mentioned are Operating System (OS) and Kernel. In this article, we will explore the key differences between the OS and the Kernel, their functions, and how they work together to manage hardware and software.What is an Operating System?An Oper
    3 min read
    Linux Kernel Module Programming: Hello World Program
    Kernel modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system. Custom codes can be added to Linux kernels via two methods. The basic way is to add the code to the kernel source tree and
    7 min read
    Linux Loadable Kernel Module
    If you want to add code to a Linux kit, the basic way to do that is to add source files to the kernel source tree and assemble the kernel. In fact, the process of setting up the kernel consists mainly of selecting which files to upload to the kernel will be merged. But you can also add code to the L
    7 min read
    Loadable Kernel Module - Linux Device Driver Development
    For Linux device drivers, we can use only two languages: Assembler and C. Assembler implements the main parts of the Linux kernel, while C implements the architecture-dependent parts. Uploaded kernel modules are often referred to as kernel modules or modules, but those are misleading names because t
    4 min read

    Linux Networking Tools

    Network configuration and troubleshooting commands in Linux
    Computers are often connected to each other on a network. They send requests to each other in the form of packets that travel from the host to the destination. Linux provides various commands from network configuration and troubleshooting.  Network Configuration and Troubleshooting Commands in Linux
    5 min read
    How to configure network interfaces in CentOS?
    A network interface is a link between a computer and another network(Private or Public). The network interface is basically a card which is known as NIC or Network Interface Card, this does not necessarily have to be in a physical form instead, it can be inbuilt into the software. If we take the exa
    5 min read
    Command-Line Tools and Utilities For Network Management in Linux
    If you are thinking of becoming a system administrator, or you are already a system admin, then this article is for you.As a system admin, your daily routine will include configuring, maintaining, troubleshooting, monitoring, securing networks, and managing servers within data centers. Network confi
    8 min read
    Linux - Network Monitoring Tools
    Network monitoring is using a system (hardware or software) that continuously observes your network and the data flows through it, depending on how the monitoring solution actually functions and informs the network administrator. We can keep a check on all the activities of our network easily. While
    4 min read

    Linux Process

    Processes in Linux/Unix
    A program/command when executed, a special instance is provided by the system to the process. This instance consists of all the services/resources that may be utilized by the process under execution. Whenever a command is issued in Unix/Linux, it creates/starts a new process. For example, pwd when i
    6 min read
    Process Management in Linux
    A process means program in execution. It generally takes an input, processes it and gives us the appropriate output. Check Introduction to Process Management for more details about a process. There are basically 2 types of processes. Foreground processes: Such kind of processes are also known as int
    3 min read
    Getting System and Process Information Using C Programming and Shell in Linux
    Whenever you start a new process in Linux it creates a file in /proc/ folder with the same name as that of the process id of the process. In that folder, there is a file named "status" which has all the details of the process. We can get those Process Information Through shell as follows: cat /proc/
    2 min read
    Process states and Transitions in a UNIX Process
    Process is an instance of a program in execution. A set of processes combined together make a complete program. There are two categories of processes in Unix, namely User processes : They are operated in user mode. Kernel processes : They are operated in kernel mode. Process States The lifetime of a
    4 min read

    Linux Firewall

    LINUX Firewall
    Linux OS, we must know that it is a system based on Unix-like. Systems that are called Unix-like or Unix-based are designed to behave and function similarly to the Unix OS. Linux OS comes under the open-source family (code designed to be publicly accessible) and is based on the Linux kernel. It was
    7 min read
    iptables command in Linux with Examples
    The iptables command in Linux is a powerful tool that is used for managing the firewall rules and network traffic. It facilitates allowing the administrators to configure rules that help how packets are filtered, translated, or forwarded. On using this iptables, you can set up security policies to c
    7 min read
    How to Configure your Linux Firewall - 3 Methods
    A Linux firewall is essential for protecting your system from unauthorized access and attacks. By configuring firewall rules, you can control the flow of traffic into and out of your system. Linux offers multiple firewall management tools, including iptables and firewalld, both of which can be used
    12 min read

    Shell Scripting & Bash Scripting

    Introduction to Linux Shell and Shell Scripting
    If we are using any major operating system, we are indirectly interacting with the shell. While running Ubuntu, Linux Mint, or any other Linux distribution, we are interacting with the shell by using the terminal. In this article we will discuss Linux shells and shell scripting so before understandi
    8 min read
    What is Terminal, Console, Shell and Kernel?
    Understanding the terms terminal, console, shell, and kernel is crucial for anyone working with computers or learning about operating systems. These concepts are key components of how we interact with our devices and software. The terminal is a text-based interface used to interact with the computer
    5 min read
    How to Create a Shell Script in linux
    Shell is an interface of the operating system. It accepts commands from users and interprets them to the operating system. If you want to run a bunch of commands together, you can do so by creating a shell script. Shell scripts are very useful if you need to do a task routinely, like taking a backup
    7 min read
    Shell Scripting - Different types of Variables
    The shell is a command-line interpreter for Linux and Unix systems. It provides an interface between the user and the kernel and executes commands. A sequence of commands can be written in a file for execution in the shell. It is called shell scripting. It helps to automate tasks in Linux. Scripting
    4 min read
    Bash Scripting - Introduction to Bash and Bash Scripting
    Bash is a command-line interpreter or Unix Shell and it is widely used in GNU/Linux Operating System. It is written by Brian Jhan Fox. It is used as a default login shell for most Linux distributions. Scripting is used to automate the execution of the tasks so that humans do not need to perform them
    12 min read
    Bash Script - Define Bash Variables and its types
    Variables are an important aspect of any programming language. Without variables, you will not be able to store any required data. With the help of variables, data is stored at a particular memory address and then it can be accessed as well as modified when required. In other words, variables let yo
    12 min read
    Shell Scripting - Shell Variables
    A shell variable is a character string in a shell that stores some value. It could be an integer, filename, string, or some shell command itself. Basically, it is a pointer to the actual data stored in memory. We have a few rules that have to be followed while writing variables in the script (which
    6 min read
    Bash Script - Difference between Bash Script and Shell Script
    In computer programming, a script is defined as a sequence of instructions that is executed by another program. A shell is a command-line interpreter of Linux which provides an interface between the user and the kernel system and executes a sequence of instructions called commands. A shell is capabl
    4 min read
    Shell Scripting - Difference between Korn Shell and Bash shell
    Korn Shell: Korn Shell or KSH was developed by a person named David Korn, which attempts to integrate the features of other shells like C shell, Bourne Shell, etc. Korn Shell allows developers to generate and create new shell commands whenever it is required. Korn shell was developed a long year bac
    3 min read
    Shell Scripting - Interactive and Non-Interactive Shell
    A shell gives us an interface to the Unix system. While using an operating system, we indirectly interact with the shell. On Linux distribution systems, each time we use a terminal, we interact with the shell. The job of the shell is to interpret or analyze the Unix commands given by users. A shell
    3 min read
    Shell Script to Show the Difference Between echo “$SHELL” and echo ‘$SHELL’
    In shell scripting and Linux, the echo command is used to display text on the terminal or console. When used with the $SHELL variable, which contains the path of the current user's shell program, the output of the echo command can be different depending on whether the variable is enclosed in single
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences