0% found this document useful (0 votes)
220 views

OS Practical File

1. ps displays information about active processes. 2. top provides a dynamic view of system processes and their CPU and memory usage. 3. pstree shows running processes as a tree to visualize their relationships. 4. nice and renice are used to change the scheduling priority of a process, with nice lowering and renice raising priority. These commands allow adjusting the CPU resources allocated to processes.

Uploaded by

kanika Mittal
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)
220 views

OS Practical File

1. ps displays information about active processes. 2. top provides a dynamic view of system processes and their CPU and memory usage. 3. pstree shows running processes as a tree to visualize their relationships. 4. nice and renice are used to change the scheduling priority of a process, with nice lowering and renice raising priority. These commands allow adjusting the CPU resources allocated to processes.

Uploaded by

kanika Mittal
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/ 25

MAHARAJA SURAJMAL INSTITUTE

Affiliated to GGSIP University & NAAC ‘A+’ grade accredited

DEPARTMENT OF COMPUTER APPLICATIONS

LINUX – OS
PRACTICAL FILE
SUBJECT CODE – BCA 371

Submitted by : Kanika Mittal Submitted to :- Mr. Manpreet Singh


Enrollment no : 00121202021 Assistant Professor , MSI
Sem : 5th Sec : A (2nd shift) Sign :- ____________
INDEX
S.No. Practical Sign Page
No.
1. Write the steps to connect the Linux Server and understand the 3-4
basic Directory Structure of Linux.
2. To understand help commands like : man, info, help, whatis, 5-7
apropos.
3. To understand basic directory navigation commands like: cat, 8-9
cd, mv, cp, rm, mkdir, rmdir, file, pwd, command.
4. To understand basic commands like: date, cal, echo, bc, ls, who, 10-12
whoami, hostname, uname, tty, aliase.
5. To understand process related commands like: ps, top, pstree, 13-14
nice, renice in linux.
6. To understand vi basics, Three modes of vi Editor, how to write, 15
save, execute a shell script in vi editor.
7. To understand how to examine and change File permissions. 16
8. Set a read-only with the chmod command. Interpret the file 17
permission display by 1s- 1 command.
9. Change your directory to the directory exercises. Create a file in 18
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.
10. Write basic shell script to display the table of a number. 19
11. Write basic shell script to input a character from user and then 20
check whether it is uppercase, lowercase or digit.
12. Write basic shell script to calculate factorial of a number. 21
13. Write basic shell script to input the month number and 22
generate corresponding calendar.
14. Write basic shell script to list all directories. 23
15. Write basic shell script to display greatest of three numbers. 24
16. Write basic shell script to check whether the number entered 25
by user is prime or not.
Practical – 1

Ques. Write the steps to connect the Linux Server and understand the basic
Directory Structure of Linux.

Theory :-
➢ Steps to connect with Linux Server:
• Open a terminal (for Linux) or a command line (for Windows) on your
computer.
• Enter the command: ssh [username]@[server IP]

➢ Directory structure of Linux:


• /(Root Directory) : The root directory is the top-level directory in the Linux
file system.
• /bin (Binary) : Essential executables are stored here. Common commands
like ls, cp, and mv are located here.
• /etc (Configuration) : System-wide configuration files and shell scripts are
stored here.
• /home (Home Directories) : User home directories are located here. Each
user has their own subdirectory.
• /lib (Libraries) : Essential system libraries are stored here.
• /dev (Devices) : Device files representing hardware devices are stored here.
• /var (Variable) : Variable data such as logs, temporary files, and spool files
are stored here.
• /tmp (Temporary) : Temporary files are stored here. This directory is often
cleared on system reboot.
• /usr (User) : User-related programs and data are stored here. It has
subdirectories like /usr/bin and /usr/lib.
• /sbin (System Binary) : System administration binaries are stored here.
• /opt (Optional) : Optional software packages can be installed here.
• /mnt (Mount) : Mount points for mounting additional filesystems are created
here.

Page 3 of 26
• /media (Media) : Mount points for removable media like USB drives are
created here.
• /proc (Process) : Virtual directory containing information about processes
and system resources.

• /srv (Service) : Data for services provided by the system is stored here.
• /boot (Boot Loader) : Boot loader files and the kernel and stored here.
• /lib64 (64-bit Libraries) : 64-bit libraries are stored here on 64-bit systems.
• /run (Runtime) : Temporary files created by system processes are stored
here.
• /sys (Sysfs) : A virtual file system exposing kernel information.
• /lost+found (Lost and Found) : Recovered files after a system crash are
placed here.

Page 4 of 25
Practical – 2

Ques. To understand help commands like : man, info, help, whatis, apropos.

Theory :-
1. man (Manual) : The man command is used to display the manual or documentation
for a particular command. It provides detailed information about the command,
including its usage, options, and examples.

Page 5 of 25
2. info: The info command is similar to man but often provides more detailed and
structured information. Its commonly used for GNU software.

3. help: The help command is built into shell (e.g., Bash) and provides information
about shell built-in commands. Its not used for external commands.

Page 6 of 25
4. whatis: The whatis command provides a brief description of a command. Its useful
for quickly finding out what a command does without displaying the full manual
page.

5. apropos: The apropos command is used to search the manual page names and
description for a specified keyword. It helps ypu find relevant commands based on a
particular topic.

Page 7 of 25
Practical – 3

Ques. To understand basic directory navigation commands like: cat, cd, mv,
cp, rm, mkdir, rmdir, file, pwd, command.

Theory :-
1. cat (Concatenate and Display): The cat command is used to concatenate and
display the content of files.

2. cd (Change Directory): The cd command is used ti change the current working


directory. You can navigate to a specific directory by providing its path.

3. mv (Move/Rename): The mv command is used to move files or directories from


one location to another. It can also be used to rename files.

4. cp (Copy): The cp command is used to copy files or directories from one location
to another.

Page 8 of 25
5. rm (Remove/Delete): The rm command is used to remove or delete files or
directories.

6. mkdir (Make Directory): The mkdir command is used to create a new directory.

7. rmdir (Remove Directory): The rmdir command is used to remove an empty


directory.

8. file: The file command is used to determine the type of file.

9. pwd (Print Working Directory): The pwd command prints the current working
directory.

Page 9 of 25
Practical – 4

Ques. To understand basic commands like: date, cal, echo, bc, ls, who,
whoami, hostname, uname, tty, aliase.

Theory :-
1. date: The date command is used to display or set he system date and time.

2. cal: The cal command displays a calendar.

3. echo: The echo command is used to print text or variables to the terminal.

4. bc (Basic Directory): The bc command is a basic calculator that supports


arithmetic operations.

Page 10 of 25
5. ls (List): The ls command is used to list the contents of a directory.

6. who: The who command displays information about users who are currently
logged in.

7. whoami: The whoami command prints the username of the current user.

8. Hostname: The hostname command displays the system’s hostname.

9. uname (Unix Name): The uname command provides system information like the
kernel name, network node hostname, kernel release, kernel version, and
machine hardware.

Page 11 of 25
10. tty (TeleTypewriter): The tty command prints the file name of the terminal
connected to the standard input.

11. alias: The alias command is used to create a shortcut or alias for a longer
command.

Page 12 of 25
Practical – 5

Ques. To understand process related commands like: ps, top, pstree, nice,
renice in linux.

Theory :-
1. ps (Process Status): The ps command is used to display information about active
processes.

2. top: The top command provides a dynamic, real-time view of the system
processes. It displays information about CPU usage, memory usage, and other
system statistics.

Page 13 of 25
3. nice: The nice command is used to run program with a specified priority, it
influences the scheduling priority of a process.

4. renice: The renice command is used to alter the priority of a running process.

Page 14 of 25
Practical – 6

Ques. To understand vi basics, three modes of vi Editor, how to write, save,


execute a shell script in vi editor.

Theory :-
• Open a new or existing shell script file:

• Switch to insert mode: Press ‘I’

• Write your script:

• Save and exit: Press esc to ensure you are in normal mode. Type :wq and press Enter.

• Make the script executable

• Execute the script

Page 15 of 25
Practical – 7

Ques. To understand how to examine and change File permissions.

Theory :-
• ls Command: The ls command with -l option shows a detailed listing, including file
permissions.

• stat Command: The stat command provides detailed information about a file,
including access and modification times.

• Changing File Permissions:


o chmod Command: The chmod command is used to change file permissions.

o Displaying file stats after using chmod command

Page 16 of 25
Practical – 8

Ques. Set a file to be read-only with the chmod command. Interpret the file
permissions displayed by the ls -l command.

Theory :-
• Set a file as Read-only:

• Interpret File Permission Display:


o After setting the file permission, you can use the ls -l command to display the
permissions.

Page 17 of 25
Practical – 9

Ques. 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.

Theory :-
• Create a new Directory named exercises.

• Create new file in exercises named as example1 and enter the text.

• Display the content of file.

Page 18 of 25
Practical – 10

Ques. Write basic shell script to display the table of a number.

Theory :-
• Create a new file, for example, table.sh, and add the content.

• Save the file and make it executable.

• Now, you can run the script by providing a number as an argument.

Page 19 of 25
Practical – 11

Ques. Write basic shell script to input a character from user and then check
whether it is uppercase, lowercase or digit.

Theory :-
• Create a new fil, for example, check_char.sh, and add the content:

• Save the file and make it executable.

• Now, you can run the script.

Page 20 of 25
Practical – 12

Ques. Write basic shell script to calculate factorial of a number.

Theory :-
• Create a new file, for example, fact.sh, and add the content:

• Save the file and make it executable.

• Now. You can run the script.

Page 21 of 25
Practical – 13

Ques. Write basic shell script to input the month number and generate
corresponding calendar.

Theory :-
• Create a new fil, for example, cal.sh, and add the content:

• Save the script in a file.

• Now, you can run the script.

Page 22 of 25
Practical – 14

Ques. Write basic shell script to list all directories.

Theory :-
• Create a new file, for example, di.sh. and add the content:

• Save the file and make it executable.

• Now. You can run the script.

Page 23 of 25
Practical – 15

Ques. Write basic shell script to display greatest of three numbers.

Theory :-
• Create a new file, for example, max.sh. and add the content:

• Save the file and make it executable.

• Now. You can run the script.

Page 24 of 25
Practical – 16

Ques. Write basic shell script to check whether the number entered by user is
prime or not.

Theory :-
• Create a new file, for example, check_prime.sh. and add the content:

• Save the file and make it executable.

• Now. You can run the script.

Page 25 of 25

You might also like