0% found this document useful (0 votes)
14 views6 pages

SA Lab List of Experiments-1-1-1

Uploaded by

midhunkumaruv888
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

SA Lab List of Experiments-1-1-1

Uploaded by

midhunkumaruv888
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

S5 CT System Administration Lab

ROUGH RECORD
1. Linux OS File and Directory Organization: Illustrate the structure of Linux Operating
System, file and directory organization.
2. System Management Commands: Demonstrate the management of the system using Linux
commands - date, time, pwd, who, whoami, uptime, users, groups.
3. File & Directory Commands: Demonstrate the use of basic file and directory commands such
as ls, mkdir, rmdir, cd, mv, touch, cp, rm.
4. Input Output Redirection in Linux: Demonstrate the input-output redirections in Linux.
5. Pipes & Filters in Linux: Demonstrate the use of pipes and filters in Linux. (filters - sort,
more, diff, head, tail, grep).
6. Process Management Commands: Demonstrate the use of basic process management
commands such as ps, top, df, kill.
7. Welcome: Read your name from the keyboard and print a welcome message.
8. Sum of two numbers: Read two numbers from keyboard and print its sum.
9. Even or Odd Checking: Check whether a given number is even or odd.
10. Grade of a Student: Read the percentage from the keyboard and print its grade.
(S: percentage >= 90, A: percentage >= 80, B: percentage >= 70,
C: percentage >= 60, D: percentage >= 50, E: percentage >= 40, else F)
11. Print Numbers: Read a number N from the keyboard and print numbers from 0 to N.
12. Number Countdown: Write a shell script that accepts a numerical value N. Then display the
decrementing values of N till it reaches 0.
13. File Merging: Write a shell script which takes three command-line arguments. The first two
are the names of two text files. Their contents are to be merged and copied to a third file
specified by the third argument. Then print the contents of the third file.
14. Greeting the User: Write a shell script that accepts your name and print it with a proper
greeting such as Good Morning, Good Afternoon and Good Evening. (Eg: Good Morning
Hari). Hint: use the ‘date’ command with the proper option. Time 0:00-11:59 may use Good
Morning, 12:00-15:59 may use Good Afternoon and for the remaining time use Good Evening)
15. Sum of Digits of the Process-ID: Write a shell script to print its Process-ID. Then find the
sum of digits of that Process-ID.
16. Simple Calculator: Write a shell script to implement a simple calculator.
17. Sorting and Filtering of Text File Contents: Create a text file having the names of 8 fruits,
one in each line. Write a shell script to sort the list and print the fruit names from line 2 to line
5. Hint: use head and tail commands.

FAIR RECORD
1. Linux OS File and Directory Organization: Illustrate the structure of Linux Operating
System, file and directory organization.
2. System Management Commands: Demonstrate the management of the system using Linux
commands - date, time, pwd, who, whoami, uptime, users, groups.
3. File & Directory Commands: Demonstrate the use of basic file and directory commands such
as ls, mkdir, rmdir, cd, mv, touch, cp, rm.

SA Lab Rev21 - List of Experiments Page 1 of 6


4. Input Output Redirection in Linux: Demonstrate the input-output redirections in Linux.
5. Pipes & Filters in Linux: Demonstrate the use of pipes and filters in Linux. (filters - sort,
more, diff, head, tail, grep).
6. Process Management Commands: Demonstrate the use of basic process management
commands such as ps, top, df, kill.
7. Number Countdown: Write a shell script that accepts a numerical value N. Then display the
decrementing values of N till it reaches 0.
8. File Merging: Write a shell script which takes three command-line arguments. The first two
are the names of two text files. Their contents are to be merged and copied to a third file
specified by the third argument. Then print the contents of the third file.
9. Greeting the User: Write a shell script that accepts your name and print it with a proper
greeting such as Good Morning, Good Afternoon and Good Evening. (Eg: Good Morning
Hari). Hint: use the ‘date’ command with the proper option. Time 0:00-11:59 may use Good
Morning, 12:00-15:59 may use Good Afternoon and for the remaining time use Good Evening)
10. Sum of Digits of the Process-ID: Write a shell script to print its Process-ID. Then find the
sum of digits of that Process-ID.
11. Simple Calculator: Write a shell script to implement a simple calculator.
12. Sorting and Filtering of Text File Contents: Create a text file having the names of 8 fruits,
one in each line. Write a shell script to sort the list and print the fruit names from line 2 to line
5. Hint: use head and tail commands.

SHELL SCRIPTS
1. Welcome: Read your name from the keyboard and print a welcome message.
echo "Enter your name"
read NAME
echo "Hai $NAME, welcome"

2. Sum of two numbers: Read two numbers from keyboard and print its sum.
read A
read B
SUM = `expr $A + $B`
echo "Sum of $A and $B is $SUM"
3. Even or Odd Checking: Check whether a given number is even or odd.
echo "Enter the Number: "
read NUM

MOD=`expr $NUM % 2`

if [ $MOD -eq 0 ]
then
echo "The number is Even"
else
echo "The number is Odd"
fi

SA Lab Rev21 - List of Experiments Page 2 of 6


4. Grade of a Student: Read the percentage from the keyboard and print its grade.
(S: percentage >= 90, A: percentage >= 80, B: percentage >= 70,
C: percentage >= 60, D: percentage >= 50, E: percentage >= 40, else F)
echo "Enter the Percentage: "
read P

if [ $P -ge 90 ]
then
echo "Grade is S"
elif [ $P -ge 80 ]
then
echo "Grade is A"
elif [ $P -ge 70 ]
then
echo "Grade is B"
elif [ $P -ge 60 ]
then
echo "Grade is C"
elif [ $P -ge 50 ]
then
echo "Grade is D"
elif [ $P -ge 40 ]
then
echo "Grade is E"
else
echo "Grage is F, Failed"
fi

5. Print Numbers: Read a number N from the keyboard and print numbers from 0 to N.
echo "Enter the number: "
read N

echo "The numbers are"


I=0
while [ $I -le $N ]
do
echo "$I"
I=`expr $I + 1`
done

6. Number Countdown: Write a shell script that accepts a numerical value N. Then display the
decrementing values of N till it reaches 0.
echo "Enter the number"
read N

echo "The numbers are"


I=$N
while [ $I -ge 0 ]
do
echo "$I"
SA Lab Rev21 - List of Experiments Page 3 of 6
I=`expr $I - 1`
done

7. File Merging: Write a shell script which takes three command-line arguments. The first two
are the names of two text files. Their contents are to be merged and copied to a third file
specified by the third argument. Then print the contents of the third file.

Let the input files be file1.txt and file2.txt. Their contents be;
file1.txt
hi all…
welcome
file2.txt
have a good day
hope you enjoyed shell scripting

echo "Contents of $1"


T1=$(cat $1)
cat $1
echo "\n"

echo "Contents of $2"


T2=$(cat $2)
cat $2
echo "\n"

echo "Merged output in $3"


printf "$T1\n" > $3
printf "$T2\n" >> $3
cat $3

8. Greeting the User: Write a shell script that accepts your name and print it with a proper
greeting such as Good Morning, Good Afternoon and Good Evening. (Eg: Good Morning
Hari). Hint: use the ‘date’ command with the proper option. Time 0:00-11:59 may use Good
Morning, 12:00-15:59 may use Good Afternoon and for the remaining time use Good Evening)

echo "What is your name?"


read NAME

HR=$(date +%H)

if [ $HR -lt 12 ]
then
echo "Hi $NAME, Good Morning"
elif [ $HR -lt 16 ]
then
echo "Hi $NAME, Good Afternoon"
else
SA Lab Rev21 - List of Experiments Page 4 of 6
echo "Hi $NAME, Good Evening"
fi

9. Sum of Digits of the Process-ID: Write a shell script to print its Process-ID. Then find the
sum of digits of that Process-ID.
PID=$$
echo "Process-ID is $PID"

SUM=0

while [ $PID -gt 0 ]


do
REM=`expr $PID % 10`
SUM=`expr $SUM + $REM`
PID=`expr $PID / 10`
done

echo "Sum of digits is $SUM"

10. Simple Calculator: Write a shell script to implement a simple calculator.


echo "Enter number A"
read A

echo "Enter number B"


read B

echo "Options"
echo "1 for addition A+B"
echo "2 for subtraction A-B"
echo "3 for multiplication A*B"
echo "4 for integer division A/B"

echo "Enter your choice"


read OP

case "$OP" in
"1") C=`expr $A + $B`
echo "$A + $B = $C"
;;

"2") C=`expr $A - $B`


echo "$A - $B = $C"
;;

"3") C=`expr $A \* $B`


echo "$A * $B = $C"
;;
SA Lab Rev21 - List of Experiments Page 5 of 6
"4") C=`expr $A / $B`
echo "$A / $B = $C"
;;

*) echo "Invalid Option"


;;
esac

11. Sorting and Filtering of Text File Contents: Create a text file having the names of 8 fruits,
one in each line. Write a shell script to sort the list and print the fruit names from line 2 to line
5. Hint: use head and tail commands.
Let the file be “fruits.txt” containing the fruit names given below. Give the filename with the
program name as command line argument.
mango
papaya
banana
apple
orange
lemon
guava
jackfruit

Program:

#!/bin/sh

FILE=$(cat $1)

SORTED=$( cat $1 | sort )

RESULT=$(sort $1 | head -5 | tail -4 )

printf "Sorted List is \n$SORTED\n\n"

printf "Lines 2 to 5 are \n$RESULT\n”

SA Lab Rev21 - List of Experiments Page 6 of 6

You might also like