0% found this document useful (0 votes)
12 views19 pages

Osy PR QB

Uploaded by

Ishwari khebade
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)
12 views19 pages

Osy PR QB

Uploaded by

Ishwari khebade
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/ 19

1. How you will record all the activities performed by the user on terminal?

Give
stpes.
=> we use script command to record the activities performed by the user
Steps are :
script [filename]
statements
.
.
.
.
Press CTRl+d to stop recording
Bydefault the session is recorded into filename typescript

2. Give a command to display calendar for month of April 2024.


=> cal 04 2024

3. Find your weekday of your birthdate by displaying calendar of birth month..


=> cal 05 2006

3. Give single statement command to display the calendar of previous current &
next month.
=> cal -3

5. Give the command to display full week day in a date.


=> date “+ %A”

6. Give command for displaying present working directory.


=> pwd

7. List currently logged in users using command.


=> who
8. Acquire the status of super user.
=> su or sudo command

9. Write use and output for following commands


i) $who; clear; who am i
=> this will give the output of who command first then it will clear it and then will give
the output of who am i command
ii)$who; tty; date
=> this will display the names of users who are currently logged in then it will display
terminal type and then it will display the date

10.What is name of your login shell?


=>
11.How to display help on any command in Linux?
=> we can display help for any command using man command . this command gives the
manual for that particular command
Syntax: man command

12.Display following in date:


a. 2 digit year => date “+ %y”
b. full month name => date “+ %B”
c. date in the form of dd/mm/yyyy => date “+ %d / %m / %Y”
d. current time in hh:mm:ss format => date “+ %H:%M:%S”

13.Display the statement “Todays century is ______” using date command.


=> date “+ Todays century is %C”
14.What are various options of kill command? Execute and write output.
=> kill command is used to terminate the process forcebily
options of kill command are :
-9 : this is sure to kill signal when the process denies to terminate then we use -9 signal
Syntax: kill -9 PID

15.What are various options of ps commands? How to display PPID?


=> ps command gives the status of processes running in the memory
Options of ps command are :
1) ps -f : it displays PID, PPID, User ID, CPU usage time and command
2) ps -A: it displays status of all processes including user processes and system
processes (? Indicates system processes pts/ or tty/ indicates user processes)
3) ps -u username : it displays the process status of particular user

we can display ppid using ps -f command

16.Explain about sleep command with example.


=> sleep command is used to insert time delay between two operations
Syntax: sleep seconds
e.g., who; sleep 10; tty

17.Create files ‘exam1’ & ‘exam2’ with 5 lines text in each file. Merge ‘exam1’ &
‘exam2’ to a single file ‘exam’.
=> cat > exam1.txt
This is osy subject
This is osy practical exam
We are creating file
We are using cat command
File created
CTRL+d to exit

Cat > exam2.txt


First subject is EST
Second subject is OSY
Third subject is Fam
Fourth subject is CCD
Fifth subject is CSS
CTRL+d to exit

cat exam1.txt exam2.txt >exam.txt

18.Create a new file ‘subject’ with 5 lines of text using cat command. Append 5
more line it.
=> cat >subject.txt
To append : cat exam2.txt >>subject.txt
This will append the content of exam2.txt in subject.txt
19.What are different options of ls command? Write down the command along
with the option and write the output.
=> ls command displays list of files and directories in alphabetical order that are
available in current directory or specific directory
Options are :
1) ls -l : it displays long list of files. It displays the characteristic of each file that are
file type, file name , file permission , username , user group name , size of file
,time and date of last modification
2) ls -a : displays all files including hidden file
3) ls -d : displays a list of directories
4) ls -r : display file name in reverse
5) ls -R : display recursive list of directory and subdirectories
6) ls -i : display inode that is index node or number for each file

20.What is the use of mv command? Give example.


=> mv command is used to move file from one location to other or to rename the file
Syntax to move file :
mv file directoryname
syntax to rename file:
mv old_filename new_filename
21.What is use of split command? Create one file named “KKWP” with 10 lines
and split it into 5 files with tag name “Nashik”.
=> split command is used to slit a long file into small small files
Syntax : split -n filename [tag name]
Cat > KKWP.txt
Split -2 KKWP.txt Nashik

22.Write output of following commands;


i) Display all file names which starts with ‘p’ and ends with ‘a’
=> ls p*a
iii) Enlist all the files beginning with ‘j’ and ending with any range of 1 to 5.
=> ls j*[1-5]
iv) Show the contents of the files whose file names contains exactly two characters
=> ls ??
ii) Create a file ABCD.txt, create a copy with XXX.txt. Rename the original file
with AACD.txt. Delete the file XXX.txt.
=> cat > ABCD.txt
cp ABCD.txt XXX.txt
mv ABCD.txt AACD.txt
rm XXX.txt
iii) Display the inodes of any two files at the same time.
=> ls -i AACD.txt kkwp.txt

23.List all file processing commands


=> ls , rm, mv, cat, cp, touch, head, tail, split, join
24.How many lines will be displayed with head command if number is not
specified.
=> 10 lines
25.Create two files chapter1 and chapter2 and perform the following operation
i) Copy contents of chapter1 as chapter3
=> cp chapter1.txt chapter3.txt
ii) Rename the file ‘chapter1’ to ‘Lesson1’
=> mv chapter1.txt lesson1.txt
26.How to shift from any directory to User (Home) directory?
=> to shift from any directory to home directory we use cd e command
27.How to see directory? Write command to go in and come out from specific
directory
=> to see the directories present we use ls -d command. to go in and come out of
directory we use cd command
1) cd [path of directory ]: to go in specific directory
2) cd.. : change to parent directory or one directory upward
3) cd e : go to home directory from any directory
4) cd / : go to root directory

28.What is default set of permissions given by the system to new file and directory?
=> for user read and write permission for group read permission for other read
permission

29.Create ‘OSY’ directory & Assign all the permissions to OSY directory for other
users using symbolic method.
=> mkdir OSY
chmod o+rwx OSY

30.Create ‘TYAN’ directory & Assign read & write the permissions to OSY
directory for group & other users using octal method.
=> mkdir TYAN
chmod 666 TYAN
31.Write the command for performing the following tasks sequentially
a. Display your current directory.
=> pwd
b. Create a directory ‘subject’ in the current directory.
=> mkdir subject
c. Create a file ‘sample’ in the directory ‘subject’
=> cd subject
cat >sample.txt
d. Remove the write permission for the owner for ‘sample’ using symbolic method
=> chmod u-w sample.txt
e. Delete the file ‘sample. What is an error message displayed?
=> remove wright protected regular file ‘sample.txt’?

32.What are the permissions assigned to the file after execution of following
commands?
a. chmod 700 abc
=> for user all permissions for group no permission for other no permission
b. chmod u+rwx, go-rwx file1 file 2
=> for user all permission for groud and other no permission
c. chmod 536 xyz
=> for user read and execute permission for group write and for other read and write
permission

33.Create new files ‘cup’ and ‘fan’ and perform the commands
chmod ugo=r cup
=> assigned absolute value only read to every user
chmod ugo+r fan
=> assigned read permission to all user and write permission is there for user
34.Assign read and write permission for the owner, write permission for the group
and execute permission for the others using octal method for the mfile.
=> chmod 621 file

35.Write commands to assign following permissions to the file OSY using octal
method
a. _ _ _ _ _ _ _ _ _
=> chmod 000 OSY
b. _rw_r_xr__
=> chmod 654 OSY
c. _r_xr_xr_x
=> chmod 555 OSY

36.Write commands to assign following permissions to the file OSY using symbolie
method.
a._rwxr_xr__
=> chmod u+rwx, g+rx, o+r OSY
37.Try the commands and write output with its meaning
i. tr “[a-f]” “[0-5]” < employee
=> it will translate a-f letters to 0-5 numbers in file employee
ii. tr –s “ ” < employee
=> it will remove all the extra spaces from the file
iii.tr –d “f” <employee
=> it will delete f letter from employee file
38.Do the following operations using vi editor
i. Cerate sample.txt file using vi editor
=> open vi
insert mode write 5 lines
escape and then :x sample.txt
ii. Insert 5 lines of text
=> vi sample.txt
insert mode and then add 5 lines
iii. Copy first 3 lines of text and paste at the end of file.
=> vi sample.txt
move cursor to the first line and then type 3yy
then move cursor to end of file and then paste using P
iv. Delete 4 to 6 lines of text in a file
=> 3dd or 4,6d
v. Display line numbers in a file.
=> :set number

39.Write a shell script to print table of given number using FOR loop.
=> read -p “Enter a number for multiplication : ” no
echo “Multiplication table of $no is :”
for i in 1 2 3 4 5 6 7 8 9 10
do
prod=`expr $no \* $i`
echo “$prod”
done
40.Execute shell script to print following pattern using FOR loop.

*****
****
***
**
*
=> for i in 5 4 3 2 1
do
for j in 1 2 3 4 5
do
if [ $j -le $i ]
then
echo -n “*”
fi
done
echo “ ”
done

41.Write a shell script to display Fibonacci series for n numbers. Input n from user.
=>
read -p “enter no of terms :” no
n1=0
n2=1
i=0
while [ $i -lt $no ]
do
echo “$n1”
n3=`expr $n1 + $n2`
n1=$n2
n2=$n3
i=`expr $i + 1`
done

42.Write a shell script to display factorial of a given no.


=>
read -p “Enter a number : ” no
fact=1
i=1
while [ $i -le $no ]
do
fact=`expr $fact \* $i`
i=`expr $i + 1`
done
echo “factorial of $no is $fact ”

43.Write a shell script to check whether given no. is ODD or EVEN.


=>
read -p “Enter a number : ” no
r=`expr $no % 2`
if [ $r -eq 0 ]
then
echo “$no is Even”
else
echo “$no is odd”
fi
44.Write a shell script to display tables of n using While loop. Input n from user.
=>
read -p “enter a number :” no
i=1
while [ $i -le 10 ]
do
prod=`expr $no \* $i`
echo “$no x $i = $prod”
i=`expr $i + 1`
done

45.Write a shell script to accept four digit number and perform addition of all
digits.
=>
read -p “Enter 4 digit no: ” no
sum=0
while [ $no -gt 0 ]
do
digit=`expr $no % 10`
sum=`expr $sum + $no`
no=`expr $no / 10`
done
echo “Sum is $sum”
46.Execute the script for the following
i. The for loop using day of week list.
=>
for day in Sunday Monday Tuesday Wednesday Thursday Friday Saturday
do
echo “day”
done

47.Execute the script for the following


i. The while loop to print different * patterns
=>
r=5
while [ $r -ge 1 ]
do
c=1
while [ $c -le $r ]
do
echo -n “*”
c=`expr $c + 1`
done
echo “ ”
r=`expr $r -1`
done

48.Execute the script for the following


i. The case statement for performing various mathematical operations
=>
echo "menu"
echo "1.Addition"
echo "2.subtraction"
echo "3.multiplication"
echo "4.division"
echo "5.remainder"
echo "6.exit"
read -p "enter your choice :" ch
case $ch in
1)#Addition
read -p "Enter two numbers : " no1 no2
sum=`expr $no1 + $no2`
echo "Addition is $sum";;
2)
read -p "Enter two numbers : " no1 no2
diff=`expr $no1 - $no2`
echo "subtraction is $diff";;
3)
read -p "Enter two numbers : " no1 no2
prod=`expr $no1 \* $no2`
echo "multiplication is $prod";;
4)
read -p "Enter two numbers : " no1 no2
div=`expr $no1 / $no2`
echo "division is $div";;
5)
read -p "Enter two numbers : " no1 no2
mod=`expr $no1 % $no2`
echo "remainder is $mod";;
6)
exit;;
*)
echo "choose valid option";;
esac

49.Write a shell script to copy source file into the destination file
=>
read -p "Enter source file :" src_file
read -p "Enter detination file :" dest_file
if [ ! -f $src_file ]
then
echo "$src_file doesn't exist "
exit
fi
if [ -f $dest_file ]
then
echo "$dest_file already exist cant copy"
exit 0
fi
else
cp $src_file $dest_file
echo "file copied successfully"
fi
50.Write a shell script to find smallest/greatest no among two/three no.s.
=>
read -p "Enter three numbers :" no1 no2 no3
if [ $no1 -gt $no2 -a $no1 -gt $no3 ]
then
echo "$no1 is greater"
elif [ $no2 -gt $no1 -a $no2 -gt $no3 ]
then
echo "$no2 is greater"
else
echo "$no3 is greater"
fi

51.Write a shell script which displays list of all directories in your home directories
=>
for fname in `ls -1`
do
if [ -d $fname ]
then
echo "directories are $fname "
fi
done

52.Write a shell script which displays list of all files in your home directory.
=>
for fname in `ls -1`
do
if [ -f $fname ]
then
echo "files are $fname "
fi
done
53.Write a file handling program . First check whether it is file or directory, then if
it is file the program shall ask user for choices of copying, removing and renaming
files. Use case statement.
=>
for fname in `ls -1`
do
if [ -f $fname ]
then
echo "1. copy"
echo "2. remove"
echo "3. rename"
read -p "Enter a choice " ch
case $ch in
1)
read -p "Enter source file :" src_file
read -p "Enter detination file :" dest_file
if [ ! -f $src_file ]
then
echo "$src_file doesn't exist "
exit
elif [ -f $dest_file ]
then
echo "$dest_file already exist cant copy"
exit 0
else
cp $src_file $dest_file
echo "file copied successfully"
fi ;;
2)
rm $fname ;;
3)
read -p "Enter new file name :" new
mv $fname $new;;
*)
echo "Invalid choice !!"
esac
elif [ -d $fname ]
echo "this is directory "
fi

54.Write a shell script which displays the list of all executable files in the current
working directory
=>
echo "executable file in current directory "
for fname in `ls -1`
do
if [ -f $fname -a -x $fname ]
echo "Executable files are $fname"
fi
done

55.Write a shell script which displays a list of all the files in the current directory to
which user has read, write and execute permission.
=>
echo “Files having read, write and execute permissions are :”
for fname in `ls -1`
if [ -r $fname -a -w $fname -a -x $fname ]
then
echo “$fname”
fi
done

56.Write a shell script which accepts a filename and assigns it all the permissions.
=>
read -p “Enter a file to which you want to apply all permission” fname
if [ -e $fname ]
chmod ugo+rwx $fname
echo “all permissions assigned ”
else
echo “file doesn’t exist”
fi

57.Implement a C program to calculate Average Waiting time using FCFS


Scheduling Algorithm.
=>

58.Implement FIFO Page Replacement Algorithm.


=>

You might also like