Os File
Os File
STUDIES
SEC-9 DWARKA, NEW DELHI- 110075
(AFFILIATED TO)
GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY
SECTOR-16C, DWARKA, NEW DELHI
LINUX – OS LAB
BCA - 371
2021-2024
SUBMITTED BY: SUBMITTED TO:
Prince kumar Ms. Nishika
Enrollment: 05224002021 Assistant Professor
INDEX
Introduction to Linux
Linux is a free and open-source operating system that is based on Unix. It is developed and
maintained by a community of volunteers around the world. Linux is available in a variety of
distributions, each with its own focus and features. Linux is popular among both home users and
enterprise users.
History
Linux was created by Linus Torvalds in 1991 as a hobby project. He was inspired by Unix, but he
wanted to create an operating system that was free and open source. Torvalds released the first
version of Linux to the public in 1991, and it quickly gained popularity among computer
enthusiasts.
Architecture
Linux is a monolithic kernel-based operating system. This means that the kernel is the core of the
operating system and it is responsible for managing all of the system's resources, including the
CPU, memory, and peripherals. The kernel also provides a set of system calls that allow
applications to interact with the operating system.
Features
Linux is a powerful and versatile operating system that offers a wide range of features,
including:
• Stability and reliability: Linux is known for its stability and reliability. It is often used for
servers and workstations because it can run for long periods of time without crashing.
• Security: Linux is also known for its security. It has a number of security features built in,
such as user permissions and access control lists.
• Scalability: Linux is a scalable operating system. This means that it can be used on a
variety of hardware platforms, from small embedded devices to large supercomputers.
• Open source: Linux is an open-source operating system. This means that the source code
is freely available and anyone can modify it and redistribute it.
Diagram
Here is a diagram of the basic Linux architecture:
The Linux operating system's architecture mainly contains some of the components: the Kernel,
System Library, Hardware layer, System, and Shell utility.
1. Kernel: Kernel is the core of the Linux based operating system. It virtualizes the common
hardware resources of the computer to provide each process with its virtual resources. This makes
the process seem as if it is the sole process running on the machine.
2. System Library: Is the special types of functions that are used to implement the functionality
of the operating system.
3. Shell: It is an interface to the kernel which hides the complexity of the kernel’s functions from
the users. It takes commands from the user and executes the kernel’s functions.
4. Hardware Layer: This layer consists all peripheral devices like RAM/ HDD/ CPU etc.
5. System Utility: It provides the functionalities of an operating system to the user.
File Structure
Linux has a hierarchical file structure. This means that the file system is organized as a tree, with
directories at the top and files at the bottom. The root directory is the top of the tree and it contains
all of the other directories and files.
Features
Unix is a powerful and versatile operating system that offers a wide range of features,
including:
• Multitasking: Unix allows multiple users to run multiple programs simultaneously.
• Multiuser: Unix allows multiple users to log in to the system and use its resources.
• Portability: Unix is written in C, which makes it easy to port to different hardware
platforms.
• Stability: Unix is known for its stability and reliability. It can run for long periods of time
without crashing.
• Security: Unix has a number of security features built in, such as user permissions and
access control lists.
Diagram
Here is a diagram of the basic Unix architecture:
The Linux operating system's architecture mainly contains some of the components: Kernel,
Hardware System, Shell and Utilities and Applications.
1. Hardware: This layer of UNIX consists of all hardware-related information in the UNIX
environment.
2. Kernel: The core of the operating system that's liable for maintaining the full functionality is
named the kernel. The kernel of UNIX runs on the particular machine hardware and interacts with
the hardware effectively.
3. Shell: The shell is a command-line interpreter that allows users to interact with the Unix
operating system. The shell interprets user commands and executes them.
4. Applications: Applications are programs that run on the Unix operating system. Applications
can be used for a variety of purposes, such as web browsing, word processing, and programming.
File Structure
Unix has a hierarchical file structure. This means that the file system is organized as a tree, with
directories at the top and files at the bottom. The root directory is the top of the tree and it contains
all of the other directories and files.
Directory Structure
The following is a basic overview of the Unix directory structure:
/ - Root directory
/bin - Contains essential command-line utilities
/boot - Contains the Linux kernel and other files needed to boot the system
/dev - Contains device files for all of the system's hardware devices
/etc - Contains configuration files for the system and its applications
/home - Contains the home directories for all of the system's users
/lib - Contains shared libraries that are used by applications
/media - Contains mount points for removable media devices
/mnt - Contains mount points for other file systems
/opt - Contains optional software packages
/proc - Contains information about the system and its processes
/root - Home directory for the root user
/sbin - Contains system administration utilities
/srv - Contains data for services that are running on the system
/sys - Contains information about the system's hardware devices
/tmp - Contains temporary files
/usr - Contains most of the system's applications and libraries
/var - Contains variable data, such as log files and spool directories
History
The first version of Windows, Windows 1.0, was released in 1985. Windows was initially a
graphical user interface (GUI) for MS-DOS, but it eventually evolved into a standalone operating
system. Windows has become increasingly popular over the years, and it is now the most popular
operating system in the world.
Architecture
Windows is a monolithic kernel-based operating system. This means that the kernel is the core of
the operating system and it is responsible for managing all of the system's resources, including the
CPU, memory, and peripherals. The kernel also provides a set of system calls that allow
applications to interact with the operating system.
Features
Windows offers a wide range of features, including:
1. User-friendly interface: Windows has a user-friendly interface that is easy to learn and
use.
2. Wide range of software compatibility: Windows has a wide range of software
compatibility. There are millions of software applications available for Windows.
3. Hardware compatibility: Windows has wide range of hardware compatibility. Most
hardware devices will work with Windows.
4. Security: Windows has a number of security features built in, such as user permissions and
access control lists.
5. Networking: Windows has built-in networking support. This makes it easy to connect to
other computers and networks.
Diagram
Here is a diagram of the basic Windows architecture:
The Windows operating system's architecture mainly contains some of the components: Kernel,
Sub-System, Kernel-mode Subsystem, User-mode Subsystem, and Application
1. Kernel: The kernel is the core of the Windows operating system. It is responsible for
managing all of the system's resources, including the CPU, memory, and peripherals. The
kernel also provides a set of system calls that allow applications to interact with the
operating system.
2. Subsystems: The Windows kernel provides a layer of abstraction called the subsystem
layer. This layer allows applications to run on Windows without having to know the details
of the underlying hardware or kernel. There are two main types of subsystems in Windows:
user-mode subsystems and kernel-mode subsystems.
3. User-mode subsystems: User-mode subsystems provide an environment for applications
to run in user mode. User mode is a less privileged mode than kernel mode, and it is more
secure. The two main user-mode subsystems in Windows are the Win32 subsystem and the
POSIX subsystem.
4. Kernel-mode subsystems: Kernel-mode subsystems provide an environment for
applications to run in kernel mode. Kernel mode is a more privileged mode than user mode,
and it allows applications to access more system resources. The two main kernel-mode
subsystems in Windows are the Windows Driver Model (WDM) subsystem and the
Graphics Device Interface (GDI) subsystem.
5. Applications: Applications are programs that run on the Windows operating system.
Applications can be used for a variety of purposes, such as web browsing, word processing,
and programming. Windows applications are typically written in C++, C#, or Visual Basic
.NET.
File Structure
Windows has a hierarchical file structure. This means that the file system is organized as a tree,
with directories at the top and files at the bottom. The root directory is the top of the tree and it
contains all of the other directories and files.
Directory Structure
The following is a basic overview of the Windows directory structure:
C:\ - Root directory
C:\Windows - Contains Windows system files
C:\Program Files - Contains program files for installed applications
C:\Users - Contains user profiles and folders
Advantages and Disadvantages of Windows
Advantages:
User-friendly interface
Wide range of software compatibility
Wide range of hardware compatibility
Built-in networking support
Security features
Disadvantages:
The help commands man, info, help, whatis, and apropos are all used to get
information about commands and utilities in Linux and other Unix-like operating
systems.
man (manual) is the most comprehensive help system, providing detailed
documentation for individual commands, API functions, concepts, configuration file
syntax, and file formats.
info is another documentation system that is specifically designed for GNU
commands and utilities. Info pages are typically more structured and easier to read
than man pages, and they often include additional information such as tutorials and
examples.
help is a built-in command that provides brief help messages for most shell
commands.
whatis is a command that displays one-line descriptions of commands. It is similar
to the help command, but it is more concise and does not include any options or
arguments.
apropos is a command that searches for commands and utilities based on keywords.
It is useful if you know the general function of a command but cannot remember its
name.
Practical-3
To understand basic directory navigation commands like cat,cd, mv, cp,
rm, mkdir,rmdir ,file, pwd command.
Practical-4
AIM: To understand basic commands like: date ,cal ,echo ,bc, ls, who, whoami
, hostname, uname, tty, aliase
Practical-5
AIM: To understand process related commands like: - ps, top, pstree, nice,
renice in Linux.
Practical-6
AIM: To understand how to examine and change File permissions.
Practical-7
AIM: Set a file to be read-only with the chmod command. Interpret the file
permissions displayedby the ls -l command.
Practical-8
AIM: 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.
Practical-9
AIM: 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.
Practical-10
AIM: To understand vi basics, three modes of vi Editor, how to write, save,
execute a shell script in vi editor
The three main modes of vi are:
Command mode: This is the default mode, and it is used to enter commands, such as moving the
cursor, deleting text, and searching for patterns.
Insert mode: This mode is used to insert text into the document.
Visual mode: This mode is used to select and edit text visually.
To switch between modes, you press the ESC key to enter command mode, the I key to enter insert
mode, and the V key to enter visual mode.
To write a shell script in vi, you can simply follow these steps:
Create a new file with the .sh extension.
/home/arjun/Pictures/Screenshots/Screenshot from 2023-10-15 20-56-32.png
Exit vi and make the shell script executable by running the following command:
To execute the shell script, you can simply run the following command:
./shell_script.sh
Practical-11
AIM: Write basic shell script to display the table of a number.
Input:
Output:
Practical-12
AIM: Write basic shell script to input a character from user and then check
whether it is uppercase, lowercase or digit.
Input:
Output:
Practical-13
AIM: Write basic shell script to calculate factorial of a number.
Input:
Output:
Practical-14
AIM: Write basic shell script to input the month number and generate
corresponding calendar.
Input:
Output:
Practical-15
AIM: Write basic shell script to list all directories.
Input:
Output:
Practical-16
AIM: Write basic shell script to display greatest of three numbers.
Input:
Output:
Practical-17
AIM: Write basic shell script to check whether the number entered by user is
prime or not.
Input:
Output:
Practical-18
AIM: Write a program to determine whether a string is palindrome or not.
Input:
Output:
Practical-19
Output:
Practical-20
AIM: Write a program to find whether a number is even or odd.
Input:
Output: