Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

PRACTICAL OPERATING SYSTEM

1. Usage of following commands: ls, pwd, tty, cat, who,


whoami, rm, mkdir, rmdir, touch, cd.
Ans-
1) ls command - The ls is the list command and it shows the full
list/content of your directory.

2) pwd command- It is the print working directory command and


it print the current working directory

3) tty command- tty is short of teletype, but popularly known as


a terminal which displays information related to terminal.
4) cat command- (concatenate) is used to read the data from
the file and gives their content as output.

5) who command ( who -q :- shows no. of users logged in) –


Generally who command is used to find following information:
1. Time of last system boot
2. Current run level of the system
3. List of logged in users and more.

6) whoami – displays the username of the current user.

7) rm - stands for remove and is used to remove objects such as


files, directories, symbolic links and so on from the file system.
8) mkdir - allows the user to create multiple directories at once.

9)rmdir - is used to remove empty directories from the


filesystem.

10) touch command - is used to create, change and modify


timestamps of a file.

11) cd command - known as change directory command. It is


used to change current working directory.
2. Usage of following commands: cal, cat(append),
cat(concatenate), mv, cp, man, date.
Ans-

i) cal command

ii) cat(append)

iii) cat(concatenate)
iv)mv command

v)cp command

vi)man command

vii)date command

3. Usage of following commands: chmod, grep, tput (clear,


highlight), bc.
i) chmod command-

ii)grep command-

iv)tput (clear,highlight)-
i)clear-

ii) highlight
v)bc-

4. Write a shell script to display date in the mm/dd/yy format.


Ans-

5. Write a shell script to display the multiplication table any


number.
Ans-
Input->

Output->
6. Write a shell script to find the factorial of a given number.
Ans-
Input->

Output->

7. Program to show the pyramid of special character “*”.


Ans-

Input->
Output->

8. Write a shell script to find the sum of digits of a given number.


Ans-

Input->

Output->

9. Write a shell script to perform the tasks of basic calculator.


Ans-
Input->

Output->

10.Write a shell script to find the power of a given number.


Ans-
Input->
Output->
11.Write a shell script to check whether the number is Armstrong
or not.
Ans-
Input->

Output->

12.Write a shell script to find the GCD (greatest common divisor) of two
numbers.
Ans-
Input->

Output->

13.Write a shell script to check if the number entered at the


command line is prime or not.
Ans-
Input->

Output->

14.Write a shell script to display on the screen sorted output of


“who” command along with the total number of users.
Ans-
Input-
>

Output->

15) Write a shell script to accept a login name. If not a valid login name
display message – “Entered login name is invalid”.
Ans-

Input->

Output->

16.Write a shell script to compare two files and if found equal asks the
user to delete the duplicate file.
Ans-

Input- >

Output->
17.Write a shell script to merge the contents of three files, sort the
contents and then display them page by page.
Ans-

Input->

Output->

18.Write a shell script to check whether the file have all the permissions
or not.
Ans-
Input->

Output->

19.Write a shell script to modify “cal” command to display calendars of


the specified months.
Ans-
Input->
Output->

20. Write a shell script to modify “cal” command to display calendars of


the specified range of months.
Ans-
Input->

Output->

You might also like