• 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 a Shell and Subshell on Oracle Linux 9.2

  • 01:10 cat /etc/os-release
  • 01:23 vim script1
  • 02:15 export name=linux
  • 02:30 chmod +x script1
  • 02:46 ll
  • 02:59 ./script1
  • 03:17 cat script1 >> script2
  • 03:35 ll
  • 03:45 vim script2
  • 04:17 chmod +x script2
  • 04:30 ll
  • 04:41 ./script2
{{postValue.id}}

To Create A Shell And Subshell On Oracle Linux 9.2

Introduction

What is Shell?

A shell is a special program that acts as an interpreter between the user and the operating system. Shell accepts human-readable commands from a user and converts them into Kernel-readable language. It is a command language interpreter that executes commands read from input devices such as keyboards or from files. The shell gets started when the user logs in or starts the terminal.

What is Subshell?

Subshell is an important concept in shell scripting that allows you to execute commands within a separate shell environment. They can be created using the parentheses operator or the bash command, and they provide a way to isolate the effects of specific commands or operations.

Creation Steps:

Step 1: First Check the OS version by using the Following commands

[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: Next create a one script file by using Vim command

[root@linuxhelp ~]# vim script1
#!/bin/bash   It is the first line should be present in every shell scripts. It’s called a shebang.
var=root
echo $var
echo $name

Step 3 : Using export command to assign the value for name variable.It is used to mark variables and functions to be passed to child processes.

[root@linuxhelp ~]# export name=linux

Step 4 : To execute the script first change the executable file permission by using the following command

[root@linuxhelp ~]# chmod +x script1

Step 5: To list the file by using the following commands

[root@linuxhelp ~]# ll
total 8
-rw-------. 1 root root 1062 Sep  4 17:37 anaconda-ks.cfg
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Desktop
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Documents
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Downloads
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Music
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Pictures
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Public
-rwxr-xr-x. 1 root root   45 Sep  6 20:23 script1
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Templates
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Videos

Step 6 : To execute the script by using the following command

[root@linuxhelp ~]# ./script1
root
linux

Step 7 :Next Copy the script1 file to script2 file by using the following command.

[root@linuxhelp ~]# cat script1 >> script2

Step 8: To list the file by using the following commands

[root@linuxhelp ~]# ll
total 12
-rw-------. 1 root root 1062 Sep  4 17:37 anaconda-ks.cfg
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Desktop
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Documents
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Downloads
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Music
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Pictures
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Public
-rwxr-xr-x. 1 root root   45 Sep  6 20:23 script1
-rw-r--r--. 1 root root   45 Sep  6 20:45 script2
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Templates
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Videos

Step 9 : Add some command in script 2 file by using Vim command

[root@linuxhelp ~]# vim script2
#!/bin/bash
var=root
echo $var
echo $name
pwd
ls

Step 10 : To execute the script first change the executable file permission by using the following command

[root@linuxhelp ~]# chmod +x script2

Step 11: To list the file by using the following commands

[root@linuxhelp ~]# ll
total 12
-rw-------. 1 root root 1062 Sep  4 17:37 anaconda-ks.cfg
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Desktop
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Documents
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Downloads
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Music
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Pictures
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Public
-rwxr-xr-x. 1 root root   45 Sep  6 20:23 script1
-rwxr-xr-x. 1 root root   61 Sep  6 20:46 script2
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Templates
drwxr-xr-x. 2 root root    6 Sep  6 20:10 Videos

Step 12: To execute the script by using the following command

[root@linuxhelp ~]# ./script2
root
linux
/root
anaconda-ks.cfg  Desktop  Documents  Downloads  Music  Pictures  Public  script1  script2  Templates  Videos

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to create user by using Shell Script on Oracle Linux 9.2. Your feedback is much welcome.

Tags:
jacob
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is Shell Scripting?

A

A shell is a special program that acts as an interpreter between the user and the operating system. Shell accepts human-readable commands from a user and converts them into Kernel-readable language. It is a command language interpreter that executes commands read from input devices such as keyboards or from files.

Q

What is the use of shell scripting?

A

It's called a shell script because it combines into a "script" in a single file a sequence of commands that would otherwise have to be presented to the system from a keyboard one at a time. The shell is the operating system's command interpreter and the set of commands you use to communicate with the system.

Q

What are the different types of shells?

A

C shell (csh)
TC shell (tcsh)
Korn shell (ksh)
Bourne Again SHell (bash)

Q

What is a shell in an operating system?

A

The shell is the outermost layer of the operating system. Shells incorporate a programming language to control processes and files and start and control other programs

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.

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 Gibbson ?
How do i run both nginx and apache in same instance on centos

Hi...,

my server is based centos operating system and my webserver is already running on Apache.... i need to run both apache and nginx on same instance ... please help me to implement this concept...

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.