0% found this document useful (0 votes)
16 views55 pages

Practical File

The document is a practical file on Operating Systems submitted by Nimratpreet Takhi to Mr. Naveen Dogra, covering various topics including the introduction to operating systems, scheduling, Linux, and shell commands. It discusses the advantages and disadvantages of operating systems, types of OS, CPU and disk scheduling algorithms, page replacement strategies, and key features of Linux and its shell. The document serves as a comprehensive guide for understanding the fundamental concepts and functionalities of operating systems.

Uploaded by

nimrtakhi2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views55 pages

Practical File

The document is a practical file on Operating Systems submitted by Nimratpreet Takhi to Mr. Naveen Dogra, covering various topics including the introduction to operating systems, scheduling, Linux, and shell commands. It discusses the advantages and disadvantages of operating systems, types of OS, CPU and disk scheduling algorithms, page replacement strategies, and key features of Linux and its shell. The document serves as a comprehensive guide for understanding the fundamental concepts and functionalities of operating systems.

Uploaded by

nimrtakhi2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 55

PRACTICAL FILE

OPERATING SYSTEMS

SUBMITTED BY : SUBMITTED TO:


NIMRTAPREET TAKHI MR. NAVEEN DOGRA SIR
SG22328
BE CSE 4th sem

INDEX
Sr. Topic Remark
no.
1. Introduction to OS
2. Scheduling
3. Introduction to Linux and
Shell
4. Shell Commands

5. MS-DOS

Signature

1.
Introduction to OS
Operating system can be defined as the software that controls the
operation of a computer and directs the processing of programs by assigning
storage space in memory and controlling input and output functions. In other
words, an operating system is a powerful and usually extensive program that
controls and manages the hardware and other software on a computer.
Operating system controls the operation of a computer, directs the input and
output of data, keeps track of files, and controls the processing of computer
programs. Its roles include managing the functioning of the computer
hardware, running the applications programs, serving as an interface between
the computer and the user, and allocating computer resources to various
function.

Advantages of Operating System


There are several advantages of operating systems. We have listed some of
them below:
 Ensuring correct and efficient use of the computer’s hardware.
 Allowing different applications to run concurrently.
 Managing files and folders.
 Providing a user interface.
 Managing security.
 Managing resources.
 Managing printing.
 Providing a platform for software development.

Disadvantages of Operating System

There are several disadvantages of operating systems. We have listed some of


them below:

 They can be complex and difficult to use.


 They can be expensive to purchase and maintain.
 They can be vulnerable to attacks from malicious users.

Types of Operating Systems


The types of operating systems (OS) have evolved significantly, adapting to
technological advancements and changing user needs. Here’s a summary of
various types of operating systems:

 Batch OS: Traditionally used for executing a series of jobs without


manual intervention. While still relevant in specific contexts, modern
computing has largely moved beyond batch processing due to the rise of
more interactive and real-time systems.
 Distributed OS: These systems manage a network of interconnected
computers, distributing the workload among them. They are becoming
increasingly relevant with the rise of cloud computing and edge
computing. Distributed systems are critical for handling large-scale,
distributed applications efficiently.
 Real-Time OS (RTOS): RTOSs are crucial in scenarios where time-critical
operations are necessary, such as in embedded systems, robotics, and
IoT devices. They ensure timely processing and responses, a key
requirement in autonomous systems and industrial automation.
 Parallel Operating : Parallel operating systems are specifically designed
and optimized for parallel computing, concurrency, scalability, and high-
performance computing by supporting and facilitating parallelism,
concurrency, scheduling, communication, coordination, load balancing,
fault tolerance, resource management, and optimization in parallel and
distributed computing environments, systems, and architectures. Proper
design, implementation, configuration, management, and optimization
of parallel operating systems .
 Time-sharing : Time-sharing operating systems, also known as
multitasking or multiprogramming operating systems, are designed and
optimized to enable multiple users, processes, tasks, and programs to
share and utilize a single or shared computer system, resources, and
infrastructure concurrently and simultaneously by dividing and
partitioning computing time, cycles, and intervals into smaller, discrete,
and manageable time slices, intervals, or quantum, and dynamically
allocating, scheduling, and switching between tasks, processes, and
programs to provide interactive, responsive, and efficient computing,
execution, and interaction for users and applications.
2.
Scheduling

CPU scheduling
Process scheduling is a task of operating system to schedules the processes
of different states like ready, running, waiting. This task is very useful in
maintain the computer system. Process scheduling allocates the time
interval of each process in which the process is to be executed by the
central processing unit (CPU). Process scheduling is very important in
multiprogramming and multitasking operating system, where multiple
processes execute simultaneously. Process scheduling ensures maximum
utilization of central processing unit (CPU) because a process is always
running at the specific instance of time. At first, the processes that are to be
executed are placed in a queue called Job queue. The processes which are
already placed in the main memory and are ready for CPU allocation, are
placed in a queue called Ready queue. If the process is waiting for input /
output, then that process is placed in the queue called Device queue.
Operating system performs the task of scheduling processes based on
priorities using
1. First come first serve (FCFS)
In this scheduling algorithm the first process entered in queue is
processed first.
2. Shortest job first (SJF)
In this scheduling algorithm the process which requires shortest CPU
time to execute is processed first.
3. Priority scheduling
In this scheduling algorithm the priority is assigned to all the processes
and the process with highest priority executed first. Priority assignment
of processes is done on the basis of internal factor such as CPU and
memory requirements or external factor such as user’s choice. The
priority scheduling algorithm supports preemptive and non - preemptive
scheduling policy.
4. Round Robin (RR) scheduling
In this algorithm the process is allocated the CPU for the specific time
period called time slice, which is normally of 10 to 100 milliseconds. If
the process completes its execution within this time slice, then it is
removed from the queue otherwise it has to wait for another time slice.

DISC SCHEDULING
"Disk Scheduling Algorithms" in an operating system can be referred to
as a manager of a grocery store that manages all the incoming and outgoing
requests for goods of that store. He keeps a record of what is available in-
store, what we need further, and manages the timetable of transaction of
goods.
The 'Disk Structure in OS' is made in such a way that there are many layers of
storage blocks on the disk. When we need to access these data from disk, we
initialize a 'request' to the system to give us the required data. These requests
are done on a large scale. So, there is a large number of input and output
requests coming to the disk.
The operating system manages the timetable of all these requests in a proper
algorithm. This is called a "Disk Scheduling Algorithm in OS". This algorithm
helps OS to maintain an efficient manner in which input-output requests can
be managed to execute a process. It manages a proper order to deal with
sequential requests to the disk and provide the required data. Since multiple
requests are approaching the disk, this algorithm also manages the upcoming
requests of the future and does a lining up of requests.
Types of Disk Scheduling
1. FCFS disk scheduling algorithm: It stands for 'first-come-first-serve'. As
the name suggests, the request that comes first will be processed first
and so on. The requests coming to the disk are arranged in a proper
sequence as they arrive. Since every request is processed in this
algorithm, so there is no chance of 'starvation'.
2. SSTF disk scheduling algorithm : It stands for 'Shortest seek time first'.
As the name suggests, it searches for the request having
the least 'seek time' and executes them first. This algorithm has less
'seek time' as compared to the FCFS Algorithm.
3. SCAN disk scheduling algorithm: In this algorithm, the head starts to
scan all the requests in a direction and reaches the end of the disk.
After that, it reverses its direction and starts to scan again the
requests in its path and serves them. Due to this feature, this
algorithm is also known as the "Elevator Algorithm".

Page replacement
Page replacement is a crucial concept in computer memory management,
particularly in the context of virtual memory systems used by modern
operating systems like Windows, Linux, and macOS. Virtual memory allows the
operating system to use a combination of RAM (physical memory) and disk
space (paging file or swap space) to provide a larger, contiguous, and
addressable memory space for running applications and processes.
Effective page replacement is essential for optimizing memory usage,
minimizing page faults, and ensuring optimal system performance in virtual
memory systems. Operating systems employ sophisticated page replacement
algorithms and memory management techniques to balance memory
utilization, performance, and responsiveness based on system resources,
workload characteristics, and user requirements.
Types of Page replacement
FIFO (First-In, First-Out):This algorithm replaces the oldest page in
memory, based on the assumption that the oldest page is least likely to
be needed in the near future.Simple and easy to implement.May suffer
from the "Belady's Anomaly," where increasing the number of page
frames can lead to an increase in the number of page faults.
LRU (Least Recently Used): This algorithm replaces the page that has not
been accessed for the longest time, based on the principle that recently
used pages are more likely to be used again in the near future.Effective
for applications with temporal locality (frequent reuse of recently
accessed pages) and can minimize the number of page faults.Requires
additional tracking and maintenance of access timestamps or counters
for each page, which can be computationally expensive.
LFU (Least Frequently Used): This algorithm replaces the page that has
been accessed the least number of times, based on the assumption that
less frequently used pages are less likely to be needed in the
future.Focuses on removing pages that are less likely to be used, which
can be beneficial for applications with spatial locality (access to a specific
set of pages at a time).Requires tracking and maintenance of access
frequencies or counters for each page, which can be complex and may
not always reflect future access patterns accurately.
Optimal Page Replacement: This algorithm replaces the page that will
not be used for the longest time in the future, based on a lookahead
prediction of future memory accesses.Serves as an ideal benchmark for
evaluating the performance of other page replacement
algorithms.Impractical to implement in real systems due to its predictive
nature and requirement to know future memory access patterns.
Clock (Second-Chance): This algorithm maintains a circular list (or
"clock") of page frames and uses a "use" bit or reference bit to identify
and replace the oldest page that has not been accessed recently.
Balances simplicity and effectiveness by considering recent access
history without the need for detailed tracking of access timestamps or
frequencies. May not always accurately reflect future access patterns or
prioritize pages based on access recency effectively.
Random Page Replacement: This algorithm randomly selects a page from
memory to replace when a page fault occurs .Simple and easy to
implement, and may perform well in certain scenarios or workloads.
Does not consider access patterns or prioritize pages based on usage
history, which can lead to suboptimal performance and unpredictable
behavior .
3.
Introduction to Linux and Shell

Linux is a family of open-source Unix-like operating systems based on the


Linux kernel, an operating system kernel first released by Linus Torvalds in
1991. It is widely used in various computing platforms, from servers and
mainframes to desktops and embedded devices.

Key characteristics of Linux include:

 Open Source: Linux is open-source software, which means its source


code is freely available to the public. This allows users to view, modify,
and distribute the code, fostering collaboration and innovation.
 Modularity: Linux is highly modular, allowing users to customize and
tailor the operating system to their specific needs. Different distributions
(or "distros") of Linux provide various combinations of software
packages, desktop environments, and system configurations.
 Security: Linux is known for its robust security features, including user
permissions, access control, and built-in firewalls. Its open-source nature
also enables a large community of developers to quickly identify and fix
security vulnerabilities.
 Stability: Linux systems are renowned for their stability and reliability,
often running for extended periods without requiring rebooting. This
makes Linux a popular choice for servers and critical infrastructure.
 Portability: Linux can run on a wide range of hardware architectures,
from personal computers and smartphones to supercomputers and
embedded systems. This versatility contributes to its widespread adoption
across different platforms and devices.
 Package Management: Linux distributions utilize package management
systems like apt, yum, pacman, and dnf to simplify software installation,
updates, and dependency resolution. These tools help users manage
software repositories, ensuring that applications are kept up-to-date and
secure.
 Command-Line Interface (CLI): Linux offers a powerful command-
line interface, allowing users to perform system administration tasks,
execute commands, and automate tasks through shell scripting. Tools like
bash, zsh, and fish provide versatile and customizable command-line
environments.
 Desktop Environments: Linux supports various desktop environments,
such as GNOME, KDE Plasma, XFCE, and LXDE, each offering
different user interfaces, features, and aesthetics. Users can choose the
desktop environment that best suits their preferences and workflow.
 Compatibility: Linux provides excellent compatibility with a wide range
of file systems, including ext4, Btrfs, XFS, and NTFS (through utilities
like ntfs-3g). This flexibility enables seamless integration with different
storage devices and operating systems.
 Virtualization and Containers: Linux supports virtualization
technologies like KVM, Xen, and VirtualBox, allowing users to run
multiple operating systems concurrently. Additionally, containerization
technologies like Docker and Kubernetes leverage Linux namespaces and
cgroups to facilitate lightweight and scalable application deployment.
 Networking: Linux offers robust networking capabilities, supporting
various protocols and services such as TCP/IP, IPv6, DNS, DHCP, VPN,
and firewall configurations. Tools like iptables, netplan, and
NetworkManager enable users to manage network settings and
connectivity effectively.
 Documentation and Community Support: The Linux community is
known for its extensive documentation, forums, and online resources,
making it easier for users to troubleshoot issues, learn new skills, and
collaborate with fellow enthusiasts. Websites like Stack Overflow,
LinuxQuestions.org, and official documentation from distributions
provide valuable guidance and support.
 Performance Monitoring and Optimization: Linux provides tools like
top, htop, vmstat, and iotop for monitoring system performance, resource
utilization, and processes. Advanced tuning and optimization techniques,
such as kernel tweaking, filesystem tuning, and memory management,
allow users to optimize system responsiveness and efficiency.
 Education and Learning: Linux is widely used in educational
institutions and training programs to teach computer science, system
administration, and programming skills. Its open-source nature and
community-driven development model encourage learning,
experimentation, and innovation among students and professionals.

Popular Linux distributions include Ubuntu, Fedora, Debian, CentOS, and


Linux Mint, each offering a unique set of features, package managers, and user
interfaces tailored to various user preferences and requirements.

Overall, Linux has become a cornerstone of modern computing, powering a vast


array of devices and systems worldwide.
The shell in Linux (and Unix-like operating systems) refers to the command-
line interface that allows users to interact with the operating system by
executing commands. It serves as the intermediary between the user and the
operating system kernel, interpreting user input and launching programs or
processes accordingly.

Here are some key aspects and features of the shell:

1. Types of Shells: There are various shells available in Linux, including:


 Bash (Bourne Again Shell): The default shell for most Linux
distributions, offering powerful scripting capabilities and extensive
features.
 Zsh (Z Shell): A highly customizable shell with advanced features,
including enhanced tab completion and theme support.
 Fish (Friendly Interactive Shell): A user-friendly shell with syntax
highlighting, autosuggestions, and a clean interface.
 Dash, Ksh, Tcsh, etc.: Other shells with specific features and syntaxes
tailored for different use cases and preferences.
2. Shell Scripting: Shells allow users to write scripts (sequences of
commands) to automate tasks, manage files, and perform system
administration tasks. Shell scripting is a powerful feature that leverages
the shell's built-in commands, utilities, and programming constructs (like
loops, conditionals, and functions) to create custom workflows and
automate repetitive tasks.
3. Command Execution: Users can execute various commands and
programs directly from the shell prompt, providing a flexible and
efficient means of interacting with the system. Shell commands can
perform a wide range of tasks, such as file management, text processing,
system monitoring, network operations, and more.
4. Redirection and Pipes: Shells support input/output redirection and pipes,
allowing users to manipulate command input and output streams.
Operators like >, <, |, >>, and 2> enable users to redirect output to files,
read input from files, combine multiple commands, and manage error
streams effectively.
5. Environment Variables: Shells manage environment variables, which are
key-value pairs that store configuration settings and information about the
system environment. Users can view, set, and manipulate environment
variables using shell commands and scripts to customize the behavior of
programs and applications.
6. Job Control: Shells provide job control features, allowing users to
manage and control multiple processes running in the background or
foreground. Commands like bg, fg, jobs, and kill enable users to start,
stop, pause, resume, and manage processes effectively.
7. Tab Completion: Modern shells offer tab completion, a feature that
suggests and completes command names, file paths, and arguments based
on user input, enhancing productivity and reducing typing errors.

Overall, the shell is a fundamental component of Linux systems, providing a


powerful and flexible interface for users to interact with the operating system,
execute commands, manage processes, automate tasks, and customize their
computing environment.

4.
Shell Commands

1) MAN: man command in Linux is used to display the user manual of any
command that we can run on the terminal. It provides a detailed view of the
command which includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT
STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS and
SEE ALSO. man command syntax:
man [option] [section number] [command name]
 option – the search result output.
 section number – the section in which to look for the man page.
 command name – the name of the command which man page you want
to see.
Example :
a.
2) WHO: who command is a tool print information about users who are
currently
logged in. who command only see a real user who logged in.

Here’s how to read the output :


 1st column show the user name
 2nd column show how the user connected. Tty means the user is
connected
 directly to the computer, while pts means the user is connected from
remote
 3rd and 4th columns show the date and time
 5th column show the IP Address where the users are connected
3) MORE: The more command reads files and displays the text one screen at a
time. The command pauses after each screen and prints the word More at the
bottom of the screen.
4) PIPE: The pipe command in Linux, represented by the vertical bar symbol '|',
is an essential tool for command-line enthusiasts and professionals alike. The
primary purpose of the pipe command is to connect the output of one
command directly into the input of another. This command allows users to
chain multiple commands together in a single line, thereby improving efficiency
and enabling the creation of more complex commands.

5) FINGER: The finger command is a command-line-based utility in Linux-based


operating systems that gives details of all the users who are logged in. There
are various user information lookup commands like “whoami”, “who”, “lastlog”,
“users”, and so many more. The finger command is one such user information
lookup command.

6) CAT: The cat command is a vital tool for handling files and their contents in
the context of Linux and Unix-like operating systems. Cat is a shortcut for
"concatenate" and is used for a number of file generation, viewing, and
modification tasks.
7) LS: The ls command line utility lists all the files and directories under a
specified directory. By default, ls uses the current directory and lists files and
directories in alphabetical order by name. The ls command supports many flags
that modify its behavior.
8) CP: The cp command in Linux is used to copy files and directories from one
location to another within the filesystem. It allows users to duplicate files,
create backups, and manage data efficiently
9) MV: The mv command works with files and directories, yielding different
results depending on the used arguments. There are four basic ways to execute
an mv command:

10) RM: The rm command can delete files, groups of files, directories, or
complete directory trees.
11) PWD: The pwd command writes to standard output the full path name of
your current directory (from the root directory). All directories are separated
by a / (slash). The root directory is represented by the first /, and the last
directory named is your current directory.

12) CD: The 'cd' command is one of the most basic yet essential commands in
Linux. It stands for 'change directory', and as the name suggests, it allows you
to change your current working directory.
13) MKDIR: The mkdir command creates directories. This command can create
multiple directories at once as well as set the permissions for the directories. It
is important to note that the user executing this command must have enough
permissions to create a directory in the parent directory.

14) RMDIR: The rmdir command is used remove empty directories from the
filesystem. The rmdir command removes each directory specified in the
command line, but only if the directory is empty. Directories that have sub-
directories or files within them will not be removed.

15) WC: wc (short for word count) is a command line tool in Unix/Linux
operating systems, which is used to find out the number of newline count,
word count, byte and character count in the files specified by the File
arguments to the standard output and hold a total count for all named files.

16) DATE: Linux date command displays and sets the system date and time.
This command also allows users to print the time in different formats and
calculate future and past dates.
17) CAL: The cal command in Linux is used to display a simple calendar in the
terminal. By default, it shows the calendar for the current month. You can
specify a particular month or year to display.

18) DIFF: diff is a command-line utility that allows you to compare two files line
by line. It can also compare the contents of directories. The diff command is
most commonly used to create a patch containing the differences between one
or more files that can be applied using the patch command.
19) UNIQ: Linux uniq command is used to remove all the repeated lines from a
file. Also, it can be used to display a count of any word, only repeated lines,
ignore characters, and compare specific fields.

20) GREP: Grep is a useful command to search for matching patterns in a file.
grep is short for "global regular expression print".
21)Sort : Suppose you have a text file which contains the names of dogs

This list is unordered.


The sort command helps us sorting them by name
22)echo : The echo command does one simple job: it prints to the output the
argument passed to it.
This example:

23)chown : Every file/directory in an Operating System like Linux or macOS


(and every UNIX systems in general) has an owner.
The owner of a file can do everything with it. It can decide the fate of that
file.The owner (and the root user) can change the owner to another user, too,
using the chown command:
24)Chmod: Every file in the Linux / macOS Operating Systems (and UNIX
systems in general) has 3 permissions: Read, write, execute.
Go into a folder, and run the ls –alcommand.

The weird strings you see on each file line, like drwxr– xr–x , define the
permissions of the file or folder.
Let's dissect it.
The first letter indicates the type of file:
 –means it's a normal file
 d means it's a directory
 l means it's a link
Then you have 3 sets of values:
• The first set represents the permissions of the owner of the file
• The second set represents the permissions of the members of the group the
file is associated to
• The third set represents the permissions of the everyone elseThose sets are
composed by 3 values. rwx means that specific persona has read, write and
execution access. Anything that is removed is swapped with
– , which lets you form various combinations of values and relative
permissions: rw– , r––, r–x , and so on
 chmod a+r filename #everyone can now read
 chmod a+rw filename #everyone can now read and writ
 chmod o–rwx filename #others (not the owner, not in
 chmod og–r filename #other and group can't read any
You can change the permissions given to a file using the chmod
command.chmod can be used in 2 ways. The first is using symbolic arguments,
the second is using numeric arguments. Let's start with symbols first, which is
more intuitive.
You type chmod followed by a space, and a letter:
 a stands for all
 u stands for user
 g stands for group
 stands for others
Then you type either + or – to add a permission, or to remove it. Then you
enter one or more permissions symbols ( r , w , x ).

25)Du :The ducommand will calculate the size of a directory as a whole:

The 32 number here is a value expressed in bytes.


Running du C will calculate the size of each file individually:
26)Top :A quick guide to the top command, used to list the processes running
in real time
The top command is used to display dynamic real- time information about
running processes in the system.
It's really handy to understand what is going on.
Its usage is simple, you just type top , and the terminal will be fully immersed in
this new view:

27)Kill :Linux processes can receive signals and react to them.


That's one way we can interact with running programs.
The kill program can send a variety of signals to a program.
It's not just used to terminate a program, like the name would suggest, but
that's its main job.
We use it in this way:

HUP means hang up. It's sent automatically when a terminal window that
started a process is closed before terminating the process.
INT means interrupt, and it sends the same signal used when we press ctrl–C in
the terminal, which usually terminates the process.
KILL is not sent to the process, but to the operating system kernel, which
immediately stops and terminates the process.
TERM means terminate. The process will receive it and terminate itself. It's
thedefault signal sent bykill.
CONT means continue. It can be used to resume a stopped process.
STOP is not sent to the process, but to the operating system kernel, which
immediately stops (but does not terminate) the process.

27)Killall :Similar to the kill command, killall instead of sending a signal to a


specific process id will send the signal to multiple processes at once.
where name is the name of a program. For example you can have multiple
instances of the top program running, and killall top will terminate them all.
You can specify the signal, like with kill (and check the kill tutorial to read more
about the specific kinds of signals we can send), for example
28)Which : Suppose you have a command you can execute, because it's in the
shell path, but you want to know where it is located.
You can do so using which. The command will return the path to the command
specified:

which will only work for executables stored on disk, not aliases or built-in shell
functions.

29)Vim :
vim is a very popular file editor, especially among programmers. It's actively
developed and frequently updated, and there's a very big community around
it. There's even a Vim conference!
vi in modern systems is just an alias to vim , which means vi i m proved.
You start it by running vion the command line.
30)Su :While you're logged in to the terminal shell with one user, you might
have the need to switch to another user.
For example you're logged in as root to perform some maintenance, but then
you want to switch to a user account.

3.
Control Statements

 test (or [): Often used for conditional statements. It evaluates


expressions and returns an exit status (0 for true, non-zero for false). You
can combine it with relational operators like -eq (equal), -ne (not equal),
-lt (less than), -gt (greater than), -le (less than or equal), -ge (greater than
or equal), etc.
Example:
Bash
if [ $file1 -eq $file2 ]; then
echo "Files are equal."
else
echo "Files are not equal."
fi

 for: Iterates over a list of items.


Example:
Bash
for item in apple banana cherry; do
echo "Processing: $item"
done

 for-in: Iterates over filenames matching a pattern or over the lines in a


file.
Example:
Bash
for file in *.txt; do
echo "File: $file"
done
for line in $(cat myfile.txt); do
echo "Line: $line"
done

 if-then-else-fi: Executes code based on a condition.


Example:
Bash
if [ $age -ge 18 ]; then
echo "You are eligible to vote."
else
echo "You are not eligible to vote."
fi

 if-then-elif-fi: Executes code based on multiple conditions.


Example:
Bash
if [ $grade -eq 100 ]; then
echo "Perfect score!"
elif [ $grade -ge 90 ]; then
echo "Excellent work!"
else
echo "Keep practicing!"
fi
 while: Loops as long as a condition is true.
 Example:
Bash
count=0
while [ $count -lt 5 ]; do
echo "Iteration: $count"
count=$((count+1))
done
 until: Loops until a condition becomes true.
Example:
Bash
file_exists=false
until [ -f "myfile.txt" ]; do
echo "Waiting for file 'myfile.txt'..."
sleep 2
file_exists=true # Check again in the next iteration
done
echo "File found!"
case: Executes code based on a pattern match.
Example:
Bash
day=$(date +%w)
case $day in
echo "Sunday" ;;
echo "Monday" ;;
echo "Tuesday" ;;
*) echo "Unknown day" ;;
esac
5.
MS-DOS

MS-DOS, which stands for Microsoft Disk Operating System, is an


operating system for x86-based personal computers. It was the dominant
operating system for IBM-compatible PCs during the 1980s and early 1990s
before Windows became more popular. A disk operating system (DOS) is an
operating system for x86 based personal computers mostly developed by
Microsoft. MS-DOS, its rebranding as IBM PC DOS, and some operating systems
attempting to be compatible with MS-DOS. Sometimes it is referred to as
"DOS", which is also the generic acronym for disk operating system.
MS-DOS was the main operating system for IBM PC compatible personal
computers during the 1980s. It was gradually superseded by operating systems
offering a graphical user interface (GUI) in various graphical Microsoft Windows
operating system generations.
DOS is also used to describe several similar command-line disk operating
systems. Early computers, such as the Commodore 64, Atari 800, and Apple II,
all featured a disk operating system, including Commodore Business Machines
DOS, Atari DOS, and Apple DOS, respectively.
Several competing products were released for the x86 platform during its
lifetime, and MS-DOS went through eight versions until development ceased in
2000. Initially, MS-DOS was targeted at Intel 8086 processors running on
computer hardware using floppy disks to store and access the operating
system, application software, and user data.
Progressive version releases delivered support for other mass storage media in
ever greater sizes and formats and added feature support for newer processors
and rapidly evolving computer architectures. Microsoft's development was the
key product from a programming language company to a diverse software
development firm, providing essential revenue and marketing resources. It was
also the underlying basic operating system on which early versions of Windows
ran as a GUI.

How DOS works?


MS-DOS (Microsoft Disk Operating System) is a text-based operating system
that operates primarily through a command-line interface (CLI). Unlike modern
graphical user interfaces (GUIs) where users interact with icons, windows, and
menus using a mouse, MS-DOS requires users to type specific commands to
perform tasks.

Here's a basic overview of how MS-DOS works:

 Booting: When a computer is turned on or restarted, it goes through a


process called booting. During this process, the computer's BIOS (Basic
Input/Output System) initializes the hardware and then loads the
operating system into memory. For computers running MS-DOS, the
operating system is typically loaded from a floppy disk or hard drive.
 Command Prompt: Once MS-DOS is loaded, it displays a command
prompt on the screen, indicating that it's ready to accept commands
from the user. The command prompt usually includes the current drive
letter and directory (e.g., C:\>), allowing users to navigate the file system
and execute commands.
 File System: MS-DOS uses a hierarchical file system to organize and store
files on disk drives. Each drive is assigned a letter (e.g., C:, D:) and can
contain multiple directories (folders) and files. Users can navigate
through directories, create, delete, copy, and move files using MS-DOS
commands.
 Commands: MS-DOS provides a set of built-in commands that allow
users to perform various tasks such as managing files and directories,
running programs, formatting disks, and configuring system settings.
Users enter commands at the command prompt, followed by any
required parameters or options.
 Batch Files: MS-DOS supports batch files, which are text files containing a
series of MS-DOS commands. Users can create and execute batch files to
automate repetitive tasks or perform complex operations without typing
each command individually.
 Memory Management: MS-DOS is a single-tasking operating system,
meaning it can only run one program at a time. To manage memory and
allocate resources efficiently, MS-DOS uses a system of memory
segmentation and swapping.
 Termination: When a user wants to shut down or restart the computer,
they can use the exit command to exit MS-DOS and return to the BIOS or
boot another operating system.
 Overall, MS-DOS is a relatively simple and lightweight operating system
designed to provide basic computing functionality on early personal
computers. While it lacks the features and capabilities of modern
operating systems, it played a crucial role in the development of personal
computing and remains a notable part of computer history.

Features of DOS
MS-DOS (Microsoft Disk Operating System) is a foundational operating system
that provided the groundwork for many features and concepts used in modern
operating systems. While it's relatively simple compared to contemporary OSs
like Windows, macOS, or Linux, MS-DOS had several key features that made it
versatile and widely adopted during its heyday. Here are some of its notable
features:

 Command-Line Interface (CLI): MS-DOS operates primarily through a


text-based command-line interface, where users type commands to
perform tasks. This CLI allows for direct and precise control over the
system, making it efficient for many tasks, especially for users familiar
with the command syntax.
 File System: MS-DOS uses a hierarchical file system with directories
(folders) and files organized on disk drives. It supports basic file
operations like creating, deleting, renaming, copying, and moving files
and directories.
 Batch Processing: MS-DOS supports batch files, which are text files
containing sequences of MS-DOS commands. Batch files allow users to
automate repetitive tasks or execute multiple commands in sequence
without user intervention.
 Memory Management: MS-DOS employs memory segmentation to
manage and allocate system memory efficiently. It also supports memory
swapping to allow larger programs to run on systems with limited RAM.
 Device Drivers: MS-DOS uses device drivers to communicate with
hardware devices such as disk drives, printers, and displays. These
drivers act as intermediaries between the operating system and the
hardware, enabling MS-DOS to support a wide range of peripherals.
 File Access and Sharing: MS-DOS provides mechanisms for accessing and
sharing files over network connections and between different
computers. This includes support for file transfer protocols like FTP and
network file sharing protocols like SMB.
 Program Execution: MS-DOS can run a variety of programs, including
applications, utilities, and games, as long as they are compatible with the
system architecture and meet the memory requirements.
 Configurability: MS-DOS allows users to customize various system
settings and configurations through text-based configuration files and
command-line options. This flexibility enables users to tailor the system
to their specific needs and hardware configurations.
 Boot Process: MS-DOS has a straightforward boot process, where the
operating system is loaded from a bootable disk or partition into
memory during the system startup. This simplicity made it easy to install
and boot MS-DOS on a wide range of hardware platforms.
 Compatibility: One of MS-DOS's strengths was its compatibility with a
vast array of software and hardware available during its era. This
compatibility made MS-DOS a popular choice for personal computers
and contributed to its widespread adoption.
 While MS-DOS lacks many of the features and capabilities found in
modern operating systems, its simplicity, versatility, and compatibility
played a crucial role in the early development of personal computing and
set the stage for the evolution of more advanced operating systems in
the years that followed.

Limitations of MS-DOS
Despite its significance in the history of computing, MS-DOS had several
limitations compared to modern operating systems. Here are some of the most
notable limitations of MS-DOS:

 Single-Tasking: MS-DOS is a single-tasking operating system, meaning it


can only run one program at a time. Users cannot run multiple
applications concurrently or switch between them without exiting one
program and launching another.
 Lack of Multitasking: Unlike modern operating systems that support
multitasking, where multiple applications can run simultaneously and
share system resources, MS-DOS does not provide native multitasking
capabilities. This limitation restricted the system's efficiency and
productivity for users who needed to perform multiple tasks
simultaneously.
 Limited Memory Support: MS-DOS has limited memory management
capabilities, particularly for systems with large amounts of RAM. It uses
memory segmentation and swapping techniques to manage memory,
which can be inefficient and cumbersome compared to the memory
management systems used in modern operating systems.
 No Graphical User Interface (GUI): MS-DOS operates exclusively through
a text-based command-line interface (CLI). It lacks a graphical user
interface (GUI) with windows, icons, and menus, which many users find
more intuitive and user-friendly for navigating and interacting with the
system.
 Limited Hardware Support: While MS-DOS supported a wide range of
hardware devices through device drivers, its hardware support was not
as comprehensive or plug-and-play as modern operating systems. Users
often had to manually install and configure device drivers to support new
hardware components, which could be challenging and time-consuming.
 Limited Networking Capabilities: MS-DOS provides basic networking
capabilities through protocols like FTP and SMB, but its networking
support is limited compared to modern operating systems. It lacks built-
in support for advanced networking features, protocols, and services
commonly used in today's networked environments.
 File System Limitations: MS-DOS uses a simple file system that lacks
support for advanced features like journaling, file permissions, and
encryption, which are standard in modern file systems. This limitation
can pose security risks and make data management more challenging for
users.
 Limited Software Compatibility: While MS-DOS was compatible with a
vast array of software available during its era, it lacks compatibility with
many modern applications and technologies. Running modern software
or accessing modern file formats often requires emulation or
virtualization, which can be complex and inefficient.
 Security Vulnerabilities: MS-DOS has limited built-in security features
and is susceptible to various security vulnerabilities and exploits.
Without robust security mechanisms like user account management,
access control, and secure boot, MS-DOS systems are more vulnerable to
malware, unauthorized access, and data breaches.
 No Plug-and-Play Support: MS-DOS does not support plug-and-play
functionality for automatically detecting and configuring new hardware
devices. Users often had to manually configure hardware settings and
install device drivers, which could be a tedious and error-prone process.
 Despite these limitations, MS-DOS played a crucial role in the early
development of personal computing and laid the foundation for many
concepts and technologies used in modern operating systems. Its
simplicity, versatility, and compatibility contributed to its widespread
adoption and enduring legacy in the history of computing.

DOS Commands
DOS Commands are instructions that allow Windows users to conduct tasks on
files and folders. As you may know, a file is a container for a collection of
information or data, and a directory is a collection of files. These are case
insensitive.
The file name in MS-DOS is in 8dot format and broken into two parts - primary
and secondary names. The primary name can be up to eight characters long,
while the secondary name can be up to four characters with a dot. For
example, in the filename Logo.jpg, the primary name is Logo, while the
secondary name is .jpg. Secondary names are set for each type of file, so for
system files, the secondary name is .sys, and for text files, it is .txt, etc. Special
characters such as >, ., /, *, ?, |, & Space are not permitted in file or directory
names. Here is a list of the most common file types, along with their default
secondary names:

Types of DOS Commands


There are mainly two types of DOS Commands. These are as follows:
1. Internal Commands
2. External Commands
Internal Commands
Internal commands are loaded into the system memory during system booting.
These internal commands may not be seen, modified, detected, or deleted
because they do not exist in the form of a file. An internal command is the MS-
DOS command stored in system memory and loaded from command.com or
cmd.exe. Internal commands include MD, DATE, COPY, CD, TIME, COPR CON,
TYPE, etc.
External Commands
External commands are stored in the system memory after system booting.
These external commands may easily be viewed, changed, deleted, or copied
as they are present in the form of a file. External commands include FORMAT,
SYS, EDIT, PROMPT, COPY, PRINT, TREE, SORT, etc.

Commands of Disk Operating System


Here, you will learn the commands of the disk operating system. There are
three types of MS-DOS commands: Internal, External, and Recovery Console
Commands.
Internal Commands
There are various internal disk operating system commands. Some of the
internal commands are as follows:
External Commands
There are various external disk operating system commands. Some of the
external commands are as follows:
Recovery Console Commands
There are various recovery console commands. Some of the recovery
console commands are as follows:
Why are internal and external commands needed?
Internal commands are more common and essential to the functioning and use
of Windows OS. They could be instantly accessible and always available in MS-
DOS and Windows by embedding them in the command.com file.
External commands are really effective. They help in the resolution of
problems, the enhancement of performance, and the execution of other tasks.
External commands typically need more resources than internal commands.
These commands keep separate from internal commands aids to decrease the
load on Windows. They could also be added to Windows at any time by
copying the file containing the external command to the computer.
MS-DOS Files and Filenames
One of the primary functions of the OS is to handle disk files. A file can contain
only data, or it can contain a set of instructions, called a program, telling the
computer how to perform a particular task. Every file has associated with it a
unique filename which is used to identify it on the disk. A filename in MS-DOS
has two parts; the name and an extension.
The name can contain up to eight characters. Each filename can have a three-
character extension. The extension is separated from the name by a period.
The period serves as a delimiter, indicating where one portion of the filename
ends, and the next begins. An extension is usually used to identify files that are
related in some way. MS-DOS allows the following characters to be used in a
filename and extension:
 Uppercase and lowercase case letters A through Z
 Numbers 0 through 9
 Special characters $ # & @ () ! ^ ` ~ { }
Any other character used in a filename, including spaces, will cause the name
to be terminated at that character. It is generally good practice not to use
special characters in filenames because some programs may use them as
delimiters or other special purposes.
In addition, the extensions BAT, COM, EXE, and SYS have special meanings in
MS-DOS and should therefore normally not be used with your data files. Shown
below are examples of both valid and unacceptable filenames.
Valid MS-DOS Filenames:
 BEERSLAW
 DAT
 1
 EX
Invalid MS-DOS Filenames:
 EXP 1.DAT (space is not allowed)
 BEERSLAWDATA (too many characters in the name)
 EXP1 (too many characters in the extension)
A computer file created by an application running under the DOS operating
system. is called an MS-DOS file. There are three main files of DOS. During
the Booting process, the computer loads the operating system into its
memory. DOS booting involves reading the following files into memory
namely

1. IO. SYS: A hidden executable binary file that processes instructions


that tell the operating system (OS) how the computer is set up when
it is booted or started. It contains the default MS-DOS device drivers
(hardware interfacing routines) and the DOS initialization program.
2. MSDOS. SYS: The MSDOS.SYS file is a hidden, system, read-only file
created on the root of the boot drive. There are several
configurations that can be changed using this file. Most values in the
MSDOS.SYS are either 0 or 1, which is off or on.
3. COMMAND.COM: COMMAND.COM is the default command-line
interpreter for MS-DOS. It is the default user interface as
well.COMMAND.COM is the command shell on MS-DOS and PC-DOS,
as well as versions of Windows that depend on DOS. Gives users a
command line interface to DOS as well as a way to run scripts called
“batch files” with the .BAT file extension.
How to open MS-DOS in windows?
 Step 1: Click on Windows.
 Step 2: Search for ‘Run’ or directly use (Windows key+R) to open.
 Step 3: Type ‘cmd’ in run and press ‘Enter’.
 Step 4: MS-DOS will open in many cases with default command prompt
i.e. c:\>
Conclusion
MS-DOS allows the user to navigate, open, and otherwise manipulate files on
their computer from a command line instead of a GUI like Windows. Although
it is not widely used nowadays, however, the command shell, also known as
the Windows command line, is still used by many users. Legacy systems,
specifically older IBM PC-compatible computers, are still in use. Many are still
running some versions of MS-DOS. Compatible OSes have been published over
the years, including at least two open-source implementations of MS-DOS that
are still actively maintained. It’s still around supporting legacy usually
standalone applications, generally because they work well and the applications
would be expensive and risky to “modernize”.

You might also like