• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to create and run Bash Script on Oracle Linux 9.2

  • 00:35 cat /etc/os-release
  • 00:58 touch test.sh
  • 01:10 chmod 755 test.sh
  • 01:20 ls -la
  • 01:32 vim test.sh
  • 03:10 sh test.sh
  • 03:58 touch variables.sh
  • 04:07 chmod 775 variables.sh
  • 04:24 vim variables.sh
  • 06:53 sh variables.sh
{{postValue.id}}

To Create And Run Bash Script On Oracle Linux 9.2

Introduction:

• A bash script is a collection of commands written in a file.

• The bash program reads and executes these commands.

• It executes these commands line by line.

• Using the command line, you can navigate to a particular path, create a folder, and spawn a process inside that folder

Procedure Steps:

Step 1: Check the OS Version by using the below command

[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.2"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.2"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:2:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.2
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.2

Step 2: Create a file named test.sh

[root@linuxhelp ~]# touch test.sh

Step 3: Grant Permission to test.sh file by using the below command

[root@linuxhelp ~]# chmod 755 test.sh

Step 4: Longlist the files by using the below command

[root@linuxhelp ~]# ls -la
total 40
dr-xr-x---. 14 root root 4096 Oct 16 05:10 .
dr-xr-xr-x. 18 root root  235 Oct 16 03:53 ..
-rw-------.  1 root root 1042 Oct 16 04:12 anaconda-ks.cfg
-rw-------.  1 root root   12 Oct 16 04:24 .bash_history
-rw-r--r--.  1 root root   18 Jan  8  2022 .bash_logout
-rw-r--r--.  1 root root  141 Jan  8  2022 .bash_profile
-rw-r--r--.  1 root root  429 Jan  8  2022 .bashrc
drwx------.  7 root root  103 Oct 16 04:15 .cache
drwx------.  7 root root 4096 Oct 16 04:15 .config
-rw-r--r--.  1 root root  100 Jan  8  2022 .cshrc
drwxr-xr-x.  2 root root    6 Oct 16 04:15 Desktop
drwxr-xr-x.  2 root root    6 Oct 16 04:15 Documents
drwxr-xr-x.  2 root root    6 Oct 16 04:15 Downloads
drwx------.  3 root root   19 Oct 16 04:15 .local
drwxr-xr-x.  2 root root    6 Oct 16 04:15 Music
drwxr-xr-x.  2 root root    6 Oct 16 04:15 Pictures
drwxr-xr-x.  2 root root    6 Oct 16 04:15 Public
drwx------.  2 root root    6 Oct 16 03:54 .ssh
-rw-r--r--.  1 root root  129 Jan  8  2022 .tcshrc
drwxr-xr-x.  2 root root    6 Oct 16 04:15 Templates
-rwxr-xr-x.  1 root root    0 Oct 16 05:10 test.sh
drwxr-xr-x.  2 root root    6 Oct 16 04:15 Videos
-rw-------.  1 root root   55 Oct 16 04:14 .Xauthority

Step 5: Edit the testscript.sh file by using the below command

[root@linuxhelp ~]# vim test.sh
# !/bin/bash
echo Bash Script is Started
ping -c 5 192.168.6.102
date
touch /root/file1
echo Bash Script is Completed

Step 6: Run the test.sh by using the below command

[root@linuxhelp ~]# sh test.sh
Bash Script is Started
PING 192.168.6.102 (192.168.6.102) 56(84) bytes of data.
64 bytes from 192.168.6.102: icmp_seq=1 ttl=128 time=0.598 ms
64 bytes from 192.168.6.102: icmp_seq=2 ttl=128 time=0.699 ms
64 bytes from 192.168.6.102: icmp_seq=3 ttl=128 time=0.464 ms
64 bytes from 192.168.6.102: icmp_seq=4 ttl=128 time=0.354 ms
64 bytes from 192.168.6.102: icmp_seq=5 ttl=128 time=0.510 ms

--- 192.168.6.102 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4135ms
rtt min/avg/max/mdev = 0.354/0.525/0.699/0.117 ms
Monday 16 October 2023 05:26:02 AM IST
Bash Script is Completed

Step 7: To Run Bash Script with variables and Create another file and grant permission by using the below command

[root@linuxhelp ~]# touch variables.sh
[root@linuxhelp ~]# chmod 775 variables.sh  

Step 8: Edit the variable.sh file by using the below command

[root@linuxhelp ~]# touch variables.sh
#! /bin/bash
 echo Enter your Name
 read Name
 echo Enter your Maid ID
 read Mail
 echo "Details you provided"
 echo Your Name is  $Name
 echo Your Mail ID is $Mail

Step 9: Run the variable.sh file by using the below command

[root@linuxhelp ~]# sh variables.sh 
Enter your Name
Linuxhelp
Enter your Maid ID
linuxhelp@gmail.com
Details you provided
Your Name is Linuxhelp
Your Mail ID is linuxhelp@gmail.com

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 Oracle Linux 9.2. Your feedback is much welcome.

Tags:
matthew
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is Shell Scripting?

A

A Shell Script is a text file that contains a sequence of commands for a UNIX-based operating system.

Q

Is Bourne Again a Linux shell?

A

Bash (Bourne Again Shell) is the free version of the Bourne shell distributed with Linux and the GNU operating system.

Q

What is variable shell scripting?

A

A variable is a character string to which we assign a value. The value assigned could be a number, text, filename, device, or any other type of data

Q

What is a shell script extension?

A

The shell script extension is .sh

Q

How does the Bash shell work?

A

Bash reads input from the terminal when interactive and from the script file specified as an argument otherwise.

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 Isaiah ?
What is the use of SUID & SGID commands

How to set the special permissions to the files and folders using SUID and SGID commands...

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.