• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How To Create and Run Bash Script on Debian 11.3

  • 00:28 lsb_release -a
  • 00:40 sudo -s
  • 00:55 touch testscript.sh
  • 01:09 ls -la
  • 01:21 chmod 755 testscript.sh
  • 01:34 ls -la
  • 01:48 nano testscript.sh
  • 03:38 sh.testscript.sh
7064

To Create And Run Bash Script On Debian 11.3

Introduction

Bash is an acronym for “Bourne-Again Shell”. It is also used as a command-line interpreter for both UNIX and Linux. The BASH script also contains a series of commands that will later be executed while running the script. The bash script should also be commenced as #!/bin/bash.

Step 1 : Check whether the Debian OS version is installed by using the below command

linuxhelp@linuxhelp:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

Step 2: Log in as root user by using the below command

linuxhelp@linuxhelp:~$ sudo -s
[sudo] password for linuxhelp: 

Step 3: Create file named testscript.sh by using the below command

root@linuxhelp:~# touch testscript.sh

Step 4: Long listing the files by using the below command

root@linuxhelp:~# ls -la
total 32

drwx------  4 root root 4096 Sep 30 08:51 .
drwxr-xr-x 20 root root 4096 Sep  8 16:50 ..
-rw-------  1 root root 1991 Sep 30 08:47 .bash_history
-rw-r--r--  1 root root 3106 Aug 15  2019 .bashrc
drwx------  2 root root 4096 Apr 20 16:20 .cache
rw-r--r--  1 root root  161 Sep 16  2020 .profile
drwxr-xr-x  3 root root 4096 Sep  8 17:00 snap
-rwr-r--  1 root root    0 Sep 30 08:51 testscript.sh
-rw-r--r--  1 root root   17 Sep 27 12:51 .vimrc

Step 5: Assign Permission to test script.sh file by using the below command

root@linuxhelp:~# chmod 755 testscript.sh 

Step 6: Long listing the files by using the below command

root@linuxhelp:~# ls -la
total 32
drwx------  4 root root 4096 Sep 30 08:51 .
drwxr-xr-x 20 root root 4096 Sep  8 16:50 ..
-rw-------  1 root root 1991 Sep 30 08:47 .bash_history
-rw-r--r--  1 root root 3106 Aug 15  2019 .bashrc
drwx------  2 root root 4096 Apr 20 16:20 .cache
-rw-r--r--  1 root root  161 Sep 16  2020 .profile
drwxr-xr-x  3 root root 4096 Sep  8 17:00 snap
-rwxr-xr-x  1 root root    0 Sep 30 08:51 testscript.sh
-rw-r--r--  1 root root   17 Sep 27 12:51 .vimrc

Step 7: Editing the testscript.sh file by using the below command

root@linuxhelp:~# nano testscript.sh 
#! /bin/bash
echo “hello $LOGNAME
echo “welcome to the world of `hostname`
echo “the host name is `hostname`
echo “your present working directory is `pwd`
echo “thank you, $LOGNAME”

ping 127.0.0.1

Step 8: Run the testscript.sh by using the below command

root@linuxhelp:~#  sh.testscript.sh
Bash script is started
PING 192.168.7.150 (192.168.7.150) 56(84) bytes of data.
64 bytes from 192.168.7.150: icmp_seq=1 ttl=63 time=0.633 ms
64 bytes from 192.168.7.150: icmp_seq=2 ttl=63 time=0.723 ms
64 bytes from 192.168.7.150: icmp_seq=3 ttl=63 time=0.699 ms
64 bytes from 192.168.7.150: icmp_seq=4 ttl=63 time=0.961 ms
64 bytes from 192.168.7.150: icmp_seq=5 ttl=63 time=0.712 ms

--- 192.168.7.150 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4080ms
rtt min/avg/max/mdev = 0.633/0.745/0.961/0.112 ms
total 36

drwx------  4 root root 4096 Sep 30 08:53 .
drwxr-xr-x 20 root root 4096 Sep  8 16:50 ..
-rw-------  1 root root 1991 Sep 30 08:47 .bash_history
-rw-r--r--  1 root root 3106 Aug 15  2019 .bashrc
drwx------  2 root root 4096 Apr 20 16:20 .cache
-rw-r--r--  1 root root  161 Sep 16  2020 .profile
drwxr-xr-x  3 root root 4096 Sep  8 17:00 snap
-rwxr-xr-x  1 root root  108 Sep 30 08:53 testscript.sh
-rw-r--r--  1 root root   17 Sep 27 12:51 .vimrc
Bash script completed

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to Create and Run Bash Script on Debian 11.3. Your feedback is much welcome.

Tags:
muhammad
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

Is shell scripting and bash scripting the same?

A

Bash is the acronym for "Bourne Again Shell", which is also considered to be a subset of shell scripting.
Shell scripting is scripting in any shell and eases the interaction between the user and operating system, while bash scripting can be done only for the bash.

Q

Is bash a terminal or shell?

A

Image result for bash vs shell
The GUI window refers to the terminal and it can also be seen on the screen as it requires commands and shows the output.
The bash is particularly a shell and the primary example for it is sh(bourne shell), csh(c shell), and tcsh(turbo c shell).

Q

What is the difference between C shell and bash?

A

CSH is a C shell while BASH stands for Bourne Again shell. The two are both Unix and Linux shells. whereas the C-shell commands start with '#' and for bash it is ‘;’. The CSH also has its own set of features and the BASH unites the features of other shells.

Q

What language is the Linux terminal?

A

The language that is commonly used is a shell script that is sometimes referred to as “shebang”.
Shell scripts are usually implemented by interpreters present in the Linux kernel.

Q

Can Python replace bash?

A

The answer is yes as using python provides various benefits and it can be also installed by default on all the major Linux distributions.

Related Tutorials in How To Create and Run Bash Script on Debian 11.3

Related Tutorials in How To Create and Run Bash Script on Debian 11.3

How to install Gparted on Debian 9.0
How to install Gparted on Debian 9.0
Sep 13, 2017
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Sep 19, 2018
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
Oct 17, 2022
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How to install qBittorrent on Debian 9.0
How to install qBittorrent on Debian 9.0
Sep 8, 2017
How to Install FileZilla in Debian
How to Install FileZilla in Debian
Nov 29, 2016
How to Install and Configure Mega in Linux
How to Install and Configure Mega in Linux
Jul 19, 2016
How to install Nmap on Debian 9.0
How to install Nmap on Debian 9.0
Sep 9, 2017

Related Forums in How To Create and Run Bash Script on Debian 11.3

Related Forums in How To Create and Run Bash Script on Debian 11.3

Linux
jayce class=
shasum command not found
May 5, 2017
Linux
stephan class=
How to list all samba users
Jan 12, 2018
pv command
muhammad class=
pvcreate command not found error
May 9, 2017
Linux
henry class=
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
Apr 25, 2017
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Linux
baseer class=
single command to apply setfacl for multiple user at a time
Jan 23, 2018
Linux
beulah class=
What does mean by 0 0 value in fstab file
Jan 2, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018

Related News in How To Create and Run Bash Script on Debian 11.3

Related News in How To Create and Run Bash Script on Debian 11.3

Anbox, the Android-to-Linux tool the developers have been waiting for
Anbox, the Android-to-Linux tool the developers have been waiting for
Apr 17, 2017
Linus Torvalds stops signing Linux kernel RC tarballs
Linus Torvalds stops signing Linux kernel RC tarballs
May 17, 2017
Capsule8 Launches Linux-Based Container Security Platform
Capsule8 Launches Linux-Based Container Security Platform
Feb 14, 2017
Symantec updates Management console product
Symantec updates Management console product
Nov 22, 2017
Latest Linux driver release feature seven AMD Vega
Latest Linux driver release feature seven AMD Vega
Mar 23, 2017
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
Apr 9, 2019
Microsoft makes its Azure App service now available on Linux Systems
Microsoft makes its Azure App service now available on Linux Systems
Sep 7, 2017
Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ganesh Konka ?
Zentya 6.1 http proxy configuration

please send link for creating zentyal 6.1 for http proxy and firewall as gateway.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.