0% found this document useful (0 votes)
147 views

Exp2

The document outlines an experiment for writing shell scripts to perform basic arithmetic operations, display top processes, and show system information. It explains the purpose of shell scripts as a means to automate command sequences in a Linux environment, highlighting their efficiency, flexibility, ease of learning, and portability. Additionally, it provides a brief overview of different types of shells and their usage.

Uploaded by

Jagruti Chavan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views

Exp2

The document outlines an experiment for writing shell scripts to perform basic arithmetic operations, display top processes, and show system information. It explains the purpose of shell scripts as a means to automate command sequences in a Linux environment, highlighting their efficiency, flexibility, ease of learning, and portability. Additionally, it provides a brief overview of different types of shells and their usage.

Uploaded by

Jagruti Chavan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Vidyavardhini’s College of Engineering & Technology

Department of Computer Engineering

Experiment No.2
Write shell scripts programming.
Date of Performance:
Date of Submission:
Aim: Write Shell Scripts to do the following:
1. Perform the basic arithmetic operations
2. Display top 10 processes in Ascending order.
3. Display processes with highest memory usage.
4. Display current logged in user and log name.
5. Display current shell, home directory, kernel version.
Objective: The shell is the operating system's command-line interface (CLI) and interpreter for the set
of commands that are used to communicate with the system. A shell script is usually created for
command sequences in which a user has a need to use repeatedly in order to save time.

Theory:
Shell is a user program or its environment is provided for user interaction. It is a command prompt
within Linux where you can type commands. It is a program that takes your commands from the
keyboard and gives them to the OS to perform. Shell is not part of system KERNAL but it uses system
KERNAL to execute programs, create files,etc. A Shell Script is a text file that contains a sequence of
commands for a UNIX based OS. It is 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. A Shell Script is usually created for command sequences for which a user has
a repeated need. You initiate the sequence of commands in Shell Script by simply entering the name of
the Shell Script on a command line.
Types of Shell Script :-
1. sh - Simple Shell
2. bash - Bourne Again Shell
3. ksh - Korne Shell
4. csh - C Shell
5. ssh - Secure Shell
To use a particular Shell type the Shell name at the command prompt. Eg:- $csh - It will switch the
current Shell to C Shell. To view the current Shell that is being used, type echo $ SHELL at the
command prompt.

Code and Output:

1)Perform the basic arithmetic operations


2)Display top 10 processes in Ascending order.
3) Display processes with highest memory usage.

4) Display current logged in user and log name.


5)Display current shell, home directory, kernel version.
Conclusion: Comment on the advantages of using shell scripting in Linux.
• Efficiency: Execute multiple commands in sequence, streamlining complex operations and
improving workflow efficiency.
• Flexibility: Leverage the power of the Linux command line and numerous utilities to perform a
wide range of tasks.
• Easy to Learn: Shell scripting has a relatively simple syntax and is easier to learn than many
programming languages.
• Portability: Shell scripts are generally portable across different Linux distributions, making them
reusable in various systems.

You might also like