Shell Scripting-1

Shell Scripting-1

·

2 min read

Table of contents

No heading

No headings in the article.

what is a shell?

Shell is a program. It will take the commands that the user is typing and it will give them to the OS to execute

  • shell is an interpreter user and the OS

  • The default shell is bash in advance Linux system

What are the shell types?

Sh, bash, ksh, zsh, csh. In etc/shells we can see shells

-->To view it we use cat etc/shells

  • cat etc/shells _ to know what the shells are available in that particular Linux server

  • /bin/shell name _ to switch to that particular shell

  • echo SHELL - whatever you give with the echo cmd display as it is like "SHELL"

    -here shell is a variable

  • if you want that variable value then give " $ " before the variable

what is the shell scripting?

  • It is a file. It contains a list or series of commands. The shell reads the file and carries out the commands as though they have been entered directly into the command line.
  • all the shell scripts file extension is ' .sh '

why we need shell scripts?

  • to automate the regular backups

  • taking database backups

  • monitor the several server resources like CPU utilization and memory utilization

  • portable (it can be executed in any UNIX-like operating system without modifications)

prerequisites

  • Linux/Unix/AIX server

  • knowledge of Linux commands with various options

  • basic programming knowledge

The first shell scripting program on ECHO(hello.sh)

eix --> shebang line #!

To execute the shell file we have to ./hello.sh. hello.sh sh hello.sh, bash hello. sh

First see where the shell scripts are there

  • Don’t forget to change the mode of files and folder before doing it

How to run the shell script in debug mode sh -x sample.sh

in a script, we have to put it -x example