logo

Linux Bash Scripting: Commands, Installation, and Outputs

This coursework requires the development of a Linux System Change Logger Script and assesses the understanding, application, and evaluation of computer systems and networks knowledge.

13 Pages2206 Words488 Views
   

Added on  2022-11-17

About This Document

This report discusses Linux Bash Scripting, its commands, installation process, and outputs generated. It covers the use of ps, echo, lsusb, df, nmcli, and cat commands. The report also provides a detailed explanation of the commands used in the script named as “mySysMonitor.sh” and the output generated.

Linux Bash Scripting: Commands, Installation, and Outputs

This coursework requires the development of a Linux System Change Logger Script and assesses the understanding, application, and evaluation of computer systems and networks knowledge.

   Added on 2022-11-17

ShareRelated Documents
Running Head: LINUX BASH SCRIPTING
LINUX BASH SCRIPTING
Name of the Student:
Name of the University:
Author Note:
Linux Bash Scripting: Commands, Installation, and Outputs_1
LINUX BASH SCRIPTING1
Table of Contents
Introduction......................................................................................................................................2
Discussion........................................................................................................................................2
Installation of the script...............................................................................................................2
Commands used in the script.......................................................................................................3
Outputs generated........................................................................................................................5
The command that should be used to execute the bash script.....................................................9
mySysMonitor.sh file..................................................................................................................9
Conclusion.....................................................................................................................................10
Bibliography..................................................................................................................................12
Linux Bash Scripting: Commands, Installation, and Outputs_2
LINUX BASH SCRIPTING2
Introduction
Bash is another name for the Unix shell. To interact with the operating system or in short
the OS, bash uses a command line interface (CLI). The advantage of using bash script is that the
commands that are used in the command line can be used as a series of commands that execute
all at the same time. Bash scripts helps in executing a series of command. Mac OS and Linux
operating system offers bash by default. Steve Bourne wrote the bash or the Bourne Again Shell.
Bash was first seen in the Seventh Edition Bell Labs Research version of Unix. In this report,
some bash commands are discussed which are used under the shell script named as
“mySysMonitor.sh” and, the explanation for those commands are also provided. In addition, the
output in the log file is also provided in this report.
Discussion
Installation of the script
Firstly, the bash directory is determined for the system in which the script will be written
and executed. In this case, the path is #!/usr/bin/bash. Checking the bash directory before starting
the script is always recommended. By using the command ‘which bash’ in the terminal, the
directory of the bash can be determined. The symbol before the staring of any bash directory #!
is known as Shebang. The function of the Shebang is to direct the script in the location of the
interpreter. The directory that is used after the Shebang is the location to the interpreter, the
location of the interpreter in this case is /usr/bin/bash.
Now, in order to write the script any text editor can be used in the Linux system but, vi
editor is the most basic one. In the beginning of the script, the location of the interpreter is used,
which will be like, #!/usr/bin/bash. The next step is to write the commands that will be used in
Linux Bash Scripting: Commands, Installation, and Outputs_3
LINUX BASH SCRIPTING3
the bash script. The file should be saved with the extension of .sh which is the most common file
extension that is used to denote a bash script. The file name that is to be executed is named as
“filename.sh”, the name of the file in this case is “mySysMonitor.sh”.
The next step is the execution of the script. Bash terminal should be used to make the
script executable. In the terminal, ‘chmod +x <filename>’ command is used. In this case, it will
be ‘chmod +x mySysMonitor.sh’. The chmod or “change mode” is a system level command,
which allows a user to manually change the permission for any file. The basic syntax for the
chmod command is: chmod [reference] [operator] [mode] file. For the [reference], four options
are available: u- which is the owner class, g- denotes the group class, o- denotes the others class
and lastly, a- all classes. Three options are available in the [operator]: +, - and =. In order to add
the specified mode to the specified class the ‘+’ operator is used, the ‘–‘ operator is used to
remove the modes, and to specify the exact mode for a specified class the ‘=’ operator is used.
There are three permissions available: r- read the file permission, w- write permission, x- is used
to execute a file or search in the directory.
Once the file is executable the command “./<filename>” is used to run the script. The
command is “./mySysMonitor.sh”, for this case.
Commands used in the script
ps- The common use of ps command is to display all the currently running processes of a system.
Full form of ps is ‘process status’. ps command can also displays the PID (process identification
number).
The ps command is very easy to remember and is a very basic command, which is the
reason behind using this command for this bash script to display the currently running processes.
Linux Bash Scripting: Commands, Installation, and Outputs_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Linux System Change Logger Script
|12
|2750
|201

Computer Systems and Networks
|33
|1506
|167

Network Administration and Monitoring
|13
|2170
|493

Automated Account Management, Designing and Implementing File Systems in Linux
|11
|647
|305

Network and System Monitoring Report 2022
|16
|2229
|46

Linux File System Management with Scripts
|16
|1536
|421