0% found this document useful (0 votes)
27 views32 pages

OS Practical File Ansh

The document outlines a Linux Operating System lab course for Bachelor of Computer Applications students at Vivekananda Institute of Professional Studies. It includes various problem statements and programming tasks aimed at teaching basic Linux commands, directory navigation, file permissions, and shell scripting. Each task is accompanied by code and expected outputs to facilitate practical understanding of Linux operations.

Uploaded by

varep71210
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)
27 views32 pages

OS Practical File Ansh

The document outlines a Linux Operating System lab course for Bachelor of Computer Applications students at Vivekananda Institute of Professional Studies. It includes various problem statements and programming tasks aimed at teaching basic Linux commands, directory navigation, file permissions, and shell scripting. Each task is accompanied by code and expected outputs to facilitate practical understanding of Linux operations.

Uploaded by

varep71210
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/ 32

VIVEKANANDA INSTITUTE OF PROFESSIONAL

STUDIES – TECHNICAL CAMPUS


VIVEKANANDA SCHOOL OF INFORMATION TECHNOLOGY

BACHELOR OF COMPUTER APPLICATIONS


Linux – Operating System Lab
Paper Code: BCA 371

SUBMITTED TO: SUBMITTED BY:


Dr. Shalini Bhartiya Ansh Garg
Assistant Professor 36117702022
VSIT, VIPS BCA 5-C
Index
S. No. Problem Statement Date Signature
To understand help commands like: man, info,
1.
help, whatis, apropos
To understand basic directory navigation
2. commands like cat, cd, mv, cp, rm, mkdir, rmdir,
file, pwd command.
To understand basic commands like: date, cal,
3. echo, bc, ls, who, whoami, hostname, uname,
tty, aliase
i. Display the name of the client machine
with complete details.
ii. Count the number of words, sentences
and characters in the directory.
iii. To list the directories and sub directories
by specifying their locations.
iv. To list the total time that the system has
4. been setup
v. Display the directory contents of your
directory. The output should be multi
column and should contain the hidden
files.
vi. Create and verify a new file using the cat
command. Also display its contents
vii. Delete file(s) and directory(s)
5. Wildcards
To understand vi basics, three modes of vi Editor,
6. how to write, save, execute a shell script in vi
editor.
To understand process related commands like:
7.
ps, top, pstree, nice, renice in Linux.
To understand how to examine and change File
8.
permissions.
i. Symbolically (e.g rwxr-xr-x), what are the
permissions 644, 755, 000, 711, 700, 777,
555, 111, 600, 731?
9. ii. Given a file with permissions 755, what
commands would change the permissions
to r-x-r--r--?
iii. List the processes for the current shell(ps).
iv. Display detailed information about
processes (ps –f).
v. Search for a string inside a file.
vi. Search for a string inside the directory.
vii. Stop any currently running process.
viii. Run the process in the background.
ix. Kill the process.
x. Search for a string recursively.
xi. Questions on pipes
Set a file to be read-only with the chmod
10. command. Interpret the file permissions
displayed by the ls -l command.
Delete one or more directories with the rmdir
command. See what happens if the directory is
11.
not empty. Experiment (carefully!) with the rm -r
command to delete a directory and its content.
Change your directory to the directory exercises.
Create a file in that directory, named the file as
example1 using the cat command containing the
12.
following text: ‘water, water everywhere and all
the boards did shrink; water, water everywhere,
no drop to drink.’
13. Case Construct and Loops.
Write basic shell script to display the table of a
14.
number.
Write basic shell script to input a character from
15. user and then check whether it is uppercase,
lowercase or digit.
Write basic shell script to calculate factorial of a
16.
number.
Write basic shell script to input the month
17.
number and generate corresponding calendar.
18. Write basic shell script to list all directories.
Write basic shell script to display greatest of
19.
three numbers.
Write basic shell script to check whether the
20.
number entered by user is prime or not.
Write basic shell script to check whether the year
21.
entered is leap or not.
Program 1: To understand help commands like: man, info, help,
whatis, apropos
Code and Output:
man command (Displays the manual pages of a command):

info command (Displays information about a command):


help command (Displays all options of a command):

whatis command (Displays what a command does):

apropos command (Finds commands and programs of an entered keyword):


Program 2: To understand basic directory navigation commands like
cat, cd, mv, cp, rm, mkdir, rmdir, file, pwd command.
Code and Output:
pwd command (Returns Present Working Directory):

cd command (Change directory):

mkdir command (Make directory):

rmdir command (Removes directory):

cp command (Copies data from one file to another):


mv command (Moves data from one file to another):

rm command (Removes file from a directory):

file command (Displays file information):


Program 3: To understand basic commands like: date, cal, echo, bc,
ls, who, whoami, hostname, uname, tty, aliase
Code and Output:
date command (Displays the current date):

cal command (Displays the calendar):

echo command (Prints on the console):

bc command (Basic Calculator):

ls command (Lists all the directories and files):


who / whoami / uname commands (Returns the user and hardware information):

tty command (Displays the file name of the terminal connected to the standard input):

alias command (Create shortcuts for long or complex commands):


Program 4:
i. Display the name of the client machine with complete details.
ii. Count the number of words, sentences and characters in the directory.
iii. To list the directories and sub directories by specifying their locations.
iv. To list the total time that the system has been setup.
v. Display the directory contents of your directory. The output should be
multi column and should contain the hidden files.
vi. Create and verify a new file using the cat command. Also display its
contents.
vii. Delete file(s) and directory(s)
Code and Output:
hostnamectl (Displays client machine details):

wc command (Returns word count of a file):

pwd command (Returns the Present Working Directory):


uptime command (Returns the total time the system has been setup):

ls -la command (Returns the list of directories along with hidden files):
cat command (Prints the contents of a file):

rm/rmdir commands (Removes files and directories):


Program 5: Wildcards
Code and Output:
*/? (Serves as wildcards placeholders):
Program 6: To understand vi basics, three modes of vi Editor, how to
write, save, execute a shell script in vi editor.
Code and Output:
Program 7: To understand process related commands like: ps, top,
pstree, nice, renice in Linux.
Code and Output:
ps command (Shows the currently running processes):

top command (Shows a real-time view of running processes):


pstree command (Shows the currently running processes in a tree-like manner):

nice command (Sets the priority of a process):

renice command (Also sets the priority of a process):


Program 8: To understand how to examine and change File
permissions.
Code and Output:
chmod command (Changes the access permissions of a file):
Program 9:
i. Symbolically (e.g rwxr-xr-x), what are the permissions 644, 755, 000,
711, 700, 777, 555, 111, 600, 731?
ii. Given a file with permissions 755, what commands would change the
permissions to r-x-r--r--?
iii. List the processes for the current shell(ps).
iv. Display detailed information about processes (ps –f).
v. Search for a string inside a file.
vi. Search for a string inside the directory.
vii. Stop any currently running process.
viii. Run the process in the background.
ix. Kill the process.
x. Search for a string recursively.
xi. Questions on pipes
Code and Output:
Symbolic
Octal Value Owner Group Other
Representation
644 rw-r—r-- read, write read read
read, write,
755 rwxr-x-r-x read, execute read, execute
execute
000 --------- No permissions No permissions No permissions
read, write,
711 rwx—x--x execute execute
execute
read, write,
700 rwx------ No permissions No permissions
execute
read, write, read, write, read, write,
777 rwxrwxrwx
execute execute execute
555 r-xr-xr-x read, execute read, execute read, execute
111 --x--x--x execute execute execute
600 rw------- read, write No permissions No permissions
read, write,
731 rwx-wx--x write, execute write, execute
execute
chmod command (Changes the access permissions of a file):
ps command (Lists the current shell processes):

ps -f command (Lists the current shell processes with more information):

grep command (Searches for a string inside a file or directory):


kill command (Kills a process):

& symbol (Runs a process in the background):

killall command (Kills the process with a specified name):

grep -r command (Searches for a string recursively):

Pipes in Linux are a way to pass the output of one command as input to another command
Program 10: Set a file to be read-only with the chmod command.
Interpret the file permissions displayed by the ls -l command.
Code and Output:
chmod command (Changes the access permissions of a file):
Program 11: Delete one or more directories with the rmdir
command. See what happens if the directory is not empty.
Experiment (carefully!) with the rm -r command to delete a
directory and its content.
Code and Output:
rmdir command (Removes a directory):
Program 12: Change your directory to the directory exercises.
Create a file in that directory, named the file as example1 using the
cat command containing the following text: ‘water, water
everywhere and all the boards did shrink; water, water everywhere,
no drop to drink.’
Code and Output:
cat command (Displays file content):
Program 13: Case Construct and Loops.
Code and Output:
Program 14: Write basic shell script to display the table of a
number.
Code and Output:
Program 15: Write basic shell script to input a character from user
and then check whether it is uppercase, lowercase or digit.
Code and Output:
Program 16: Write basic shell script to calculate factorial of a
number.
Code and Output:
Program 17: Write basic shell script to input the month number and
generate corresponding calendar.
Code and Output:
Program 18: Write basic shell script to list all directories.
Code and Output:
Program 19: Write basic shell script to display greatest of three
numbers.
Code and Output:
Program 20: Write basic shell script to check whether the number
entered by user is prime or not.
Code and Output:
Program 21: Write basic shell script to check whether the year
entered is leap or not.
Code and Output:

You might also like