You are on page 1of 19

Sub: Operating System (3330701) SEM: III

Enrollment No: 206450307057


Name: SHINDE KRISHNA KETANBAI
Div: 1
NAME= SHINDE KRISHNA KETANBHAI
SUB= OS
1. Explain the following command.
a. Date Clear cd ls Exit echo who

b. Who am i rmdir calculator uname password

c. tty sty cat cp rm mv cut paste

d. more cmp comm diff chmod chown


e. chgrp file finger sleep kill users ps Ln

f. head tail sort find unique tr history

g. write wall grep pwd wc man

h. I ( pipeline command)

i. Explain the basic system administration commands of unix.

i. Su command ii. Date setting the system

iii. Cal Wall iv. Ulimit

v. Passwd

vi. SUID vii. SGID viii.

Du

ANS
A
a. Date : Used To Show the current date and

b. Clear : Used To Clear Term


c. cd : Used To Change Directory
d. ls : Used To List Out Directory on current
Folder/Directory

e. Exit : Used To logout the current session


f. echo : This command writes its arguments to
standard output

g. who : Display who is on line B:


a. Who am i : To see Who you are logged
in as
b. Rmdir : Delete Directory Dir
c. calculator : To use calculator using
command line

d :uname : show kernel information

d. password : used to change the user


account password

C:

a. tty : prints the file name of the terminal connected to standard input

b. sty : used to change and print terminal line settings

c. cat :Used to create single or multiple files, view contain of file, concatenate
files and redirect output in terminal or files

d. cp : used to copy files or group of files or directory.

e. rm : used to remove objects such as files, directories, symbolic links and so


on from the file system like UNIX

f. mv : used to move one or more files or directories from one place to Aunothe
place

g. cut : used to cut out the sections from each line of files and writing the result to
standard output

h. paste : used to join files horizontally by outputting lines consisting of lines from
each file specified, separated by tab as delimiter, to the standard output.
D:

a. more : used to view the text files in the command prompt, displaying one screen at a
time in case the file is large

b. cmp : used to compare the two files byte by byte and helps you to find out whether the
two files are identical or not.

c. Comm: compare two sorted files line by line and write to standard output; the lines

d. diff : used to display the differences in the files by comparing the files line by line

e. chmod: used to change the access mode of a file


f. chown: To change both the owner and the group of a file
E:
NAME= SHINDE KRISHNA KETANBHAI
SUB= OS
a. chgrp : used to change the group ownership of a file or directory.
b. file : used to determine the type of a file.
c. finger : it gives details of all the users logged in
d. sleep : used to delay for a fixed amount of time during the execution of any script
e. kill : used to terminate processes manually
f. users : used to show the user names of users currently logged in to the current host
g. ps : viewing information related with the processes on a system which stands as
abbreviation for “Process Status”

h. Ln : viewing information related with the processes on a system which stands as


abbreviation for “Process Status” F:

a. head : for outputting the first part of files given to it via standard input.

b. Tail : for outputting the last part of files given to it via standard input.
c. sort : sorts the contents of a text file, line by line

d. find : allows the user to find files located in the file system via criteria
such as the file name

e. unique : reports or filters out the repeated lines in a file

f. tr : for translating or deleting characters


g. history : show you all of the last commands that have been recently used

G:

a. write : used to send a message to another user

b. wall : used to write a message to all users


c. grep : used to search for a string of characters in a specified file

d. pwd : for printing the current working directory

e. wc : used to find out number of lines, word count, byte and characters
count in the files specified in the file arguments.
f. man : used to display the user manual of any command that we can run on
the terminal H:

a. PIPELINE COMMAND: The Pipe is a command in Linux that lets you use two or
more commands such that output of one command serves as input to the
next.
In short, the output of each process directly as input to the next one like a
pipeline.

I:

a. Su command : to execute commands with the privileges of another


user account

b. Date setting the system : used to set the date


c. Cal : used to see the calendar of a specific month or a whole year
d. Wall : used to write a message to all users
e. Ulimit : change the maximum amount of open files
f. Passwd: used to change the user account passwords.
g. SUID : enables other users to run the file with effective permissions of
the file owner

h. SGID : enables other users to inherit the effective GID of file group
owner

i. Du : used to estimate file space usage

1. Write a shell script to check whether given


number is positive or negative.

Practical:- echo "Enter a Number" read num


if [ $num -lt 0 ] then
echo
NAME= SHINDE KRISHNA KETANBHAI
SUB= OS
"Negative" elif [
$num -gt 0 ] then
echo
"Positive"
else echo "Neither
Positive Nor Negative" fi

Output:-
Enter a Number

10

Positive

Enter a Number

-2

Negative

Enter a Number

Neither Positive Nor Negative

2. Write a shell script to check whether given number is

even or odd. Practical:- read -p "Enter a number: " number


if [ $((number%2)) -eq 0 ] then

echo "Number is even." else

echo "Number is odd."

fi

Output:-
Enter a number: 88

Number is even. Enter a number:


45

Number is odd.

3. Write a shell script to find the largest number from


given three numbers.

Practical:- echo
"Enter Num1" read num1
echo "Enter
Num2" read num2 echo
"Enter Num3" read num3

if [ $num1 -gt $num2 ] && [ $num1 -gt $num3 ] then


echo $num1
elif [ $num2 -gt $num1 ] && [ $num2 -gt $num3 ] then
echo $num2
else echo
$num3 fi
Output:-
Enter Num1

Enter Num2

34
NAME= SHINDE KRISHNA KETANBHAI
SUB= OS
Enter Num3

34

4. Write a shell script to check whether given number is


digit or alphanumeric or special character.
Practical:<?php function

charCheck($input_char)

if (($input_char >= 65 && $input_char <= 90) ||

($input_char >= 97 && $input_char <= 122)) echo

" Alphabet ";

else if ($input_char >= 48 &&

$input_char <= 57) echo

" Digit "; else echo " Special

Character ";

$input_char = '$'; charCheck($input_char);

?>

Output:-
Input:8
Output: Digit

Input: E

Output: Alphabet

5. Write a shell script to check given number is Prime or not.

Practical:- echo "Enter a number: "


read num i=2 f=0 while [

$i -le `expr

$num / 2` ] do if [ `expr $num

% $i` -eq 0 ] then f=1

fi

i=`expr $i + 1` done if [

$f -eq 1 ] then echo "The number is

composite" else echo "The number

is Prime"

fi

Output:-
Enter a number: 5

The number is Prime

8.Write a shell script for a factorial of numbers.

Practical:- echo
"Enter a number"

read num
NAME= SHINDE KRISHNA KETANBHAI
SUB= OS
fact=1

for((i=2;i<=num;i++))

{ fact=$((fact * i)) #fact = fact *

echo $fact

Output:-
Enter a number

Enter a number

24

Enter a number

120
9. Write a shell script for a fibrotic series of given number.

Practical:-
# Static input fo N
N=6

# First Number of the

# Fibonacci Series a=0

# Second Number of the #

Fibonacci Series b=1 echo

"The Fibonacci series is : "

for (( i=0; i<N; i++ ))

do echo -n "$a " fn=$

((a + b)) a=$b b=$fn

done

# End of for loop

Output:-
Fibonacci Series is :
0

2
5

10. Write a shell script for a sum, average and product of given

number. Practical:- echo "Please enter your first number: " read a echo "Second

number: " read b echo "Third number: " read c echo "Fourth number: " read d echo

"Fifth number: " read e

sum=$(($a + $b + $c + $d + $e)) avg=$(echo

$sum / 5 | bc -l ) prod=$(($a

* $b * $c * $d * $e))

echo "The sum of these numbers is: " $sum echo

"The average of these numbers is: " $avg echo

"The product of these numbers is: " $prod

Output:-
Please enter your first number:
2

Second number:

Third number:
2
Fourth number:

Fifth number:

2
The sum of these numbers is: 11

The average of these numbers is: 2.20000000000000000000


The product of these numbers is: 48

11. Write a shell script for a reverse of given number.

Practical:- echo -n "Enter year (YYYY):


" read y a = 'expr $y%4' b = 'expr

$y%100' c = 'expr $y%400' if[$a eq

0 -a $b -ne - -o $c -eq 0] then echo

"$y is leap year" else echo

"$y is not a leap year"

fi

Output:-
Input: 2024
Output: "2024 is leap year"

Input: 2018

Output: "2018 is not leap year"


12. Write a shell script for mark sheets of given marks. Practical:-
echo
"Enter a Number:" read

rev=0 sd=0 or=$a

while [ $a -gt 0 ] do sd=`expr

$a % 10` temp=`expr $rev \*

10` rev=`expr $temp + $sd`

a=`expr $a / 10` done

echo "Reverse of $or is $rev"

Output:
reverse number: of

12345 is 54321

13. Write a shell script to display the following details in a pay


list Pay slip details , House rent allowance, Dearness allowance,
Provident fund. HRA is to be calculated at the rate of 20% of basic,
DA at the rate of 40% of basic and PF at the rate of 10% of basic.

Practical:- echo "Enter the five subject marks for the student" read m1 m2 m3 m4

m5 sum1=`expr $m1 +

$m2 + $m3 + $m4 + $m5` echo "Sum of 5 subjects are: "

$sum1 per=`expr $sum1 / 5` echo " Percentage: " $per if [


$per -ge 60 ] then echo "You get Distinction” elif [ $per ge

50 ] then echo “You get First class” elif [ $per -ge 40 ]


then echo "You get Second class" else echo "You get

Fail"

fi

Output:-
Enter the five subject marks for the student

45

35

30

40

42

Sum of 5 subjects are: 192

Percentage : 76.8

14. Write a shell script to display the following details in a pay list
Pay slip details , House rent allowance, Dearness allowance,
Provident fund. HRA is to be calculated at the rate of 20% of
basic, DA at the rate of 40% of basic and PF at the rate of 10% of
basic.
Practical:
- i="y" while [

$i = "y" ] do echo "Please enter


your Basic:" read basic echo "PAY
SLIP DETAILS" echo "1.
HOUSE RENT ALLOWANCE" echo
"2. DEARNESS ALLOWANCE" echo
"3.
PROVIDENT FUND" echo "your choice:"
read ch case $ch in
1) hra=`expr $basic \* 20 / 100` echo Your
HOUSE RENT ALLOWANCE is Rs. $hra;; 2)
da=`expr
$basic \* 40 / 100`
echo Your DEARNESS ALLOWANCE is Rs. $da;;
3) pf=`expr $basic \* 10 / 100` echo
Your PPOVIDENT FUND is Rs. $pf;;
*) echo "Not a valid choice";; esac
echo "Do u want to
continue ?" read i if [ $i != "y"
] then exit fi

Output:-

Please enter your basic:


1000
PAY SLIP DETAILS
1. HOUSE RENT ALLOWANCE
2. DEARNESS ALLOWANCE
3. PROVIDENT FUND YOUR CHOISE
1
YOUR HOUSE RENT ALLOWANCE IS RS. 200 Do you want
to continue?

15. Write a shell script to display a list of all files in the current
directory to which you have read, write and execute
permissions.

Practical:- echo "enter the directory


name"

read dir if [ -d

$dir ] then cd
$dir ls > f exec

< f while read

line

do
if [ -f $line ] then if [ -r $line -a -w

$line -a -x $line ] then echo

"$line has all permissions" else

echo "files not having all

permissions"

fi fi

done

fi

Output:-
enter the directory name dir1
ff has all permissions files
not having permission

16.Write a shell script to perform addition, subtraction,

multiplication and division of two numbers using case. Practical:echo


Enter n1 read n1 echo Enter n2 read n2

echo Enter operator[+: addition, -: subtraction, *: multiplication, /: division] read op case


sop

in
+) expr $n1 + $n2 ;;

-) expr $n1 - $n2 ;;

\*) expr $n1 \* $n2 ;;

/) expr $n1 / $n2 ;;

esac

Output:-
Enter n1
2

Enter n2 3
N1+n2 5 N1-n2
1

N1*n2 6 N1/n2
0.666

You might also like