Unit - 1
Introduction to Operating System
Q1) Explain Architecture of Linux?
A1) Kernel, shell and applications
The Linux operating system is a common variant of the UNIX operating system that aims to provide a free or low-cost operating system for personal computer users. It earned a reputation as a system that was both fast and effective. This is an incredibly comprehensive operating system, with features such as a graphical user interface (GUI), TCP/IP, the Emacs editor, and the X Window System. Debian, Ubuntu, Fedora, Red Hat Linux, SUSE Linux, Gentoo, Kali Linux, and Centos are the best Linux operating systems.
Fig 1: Linux architecture
Kernel
The kernel is the most important component of Linux. It is in charge of the operating system's main functions. It is made up of different modules that communicate directly with the hardware. Kernel provides the required abstraction for device or application programs to hide low-level hardware information.
The kernel is the central interface between a computer's hardware and its processes and is the most important part of a Linux operating system (OS). It interacts between the two, allowing for the most effective use of resources.
The following are the different forms of Kernels:
● Monolithic Kernel
● Microkernels
● Exo kernels
● Hybrid kernels
The kernel performs four functions:
- Memory management - Keep track of how much memory is being used for what, and where it is being stored.
- Process management - Determine can processes, when and for how long, should use the central processing unit (CPU).
- Device driver - Act as a liaison between the hardware and the processes.
- System call and security - Receive service requests from the processes.
Shell
The shell is a user-to-kernel interface that allows the kernel to provide services to the user. It receives user commands and performs the kernel's functions. The Shell can be used in a variety of operating systems and is divided into two categories: command-line shells and graphical shells.
A command-line interface is provided by command-line shells, while a graphical user interface is provided by graphical line shells. Despite the fact that both shells execute operations, graphical user interface shells are slower than command line interface shells.
An interface to the kernel that conceals the ambiguity of the kernel's functions from the user. The shell receives user commands and performs kernel functions.
Shells are divided into four categories:
● Korn shell
● Bourne shell
● C shell
● POSIX shell
Q2) Write the features of Linux?
A2) Features of Linux
Some of the most significant features of the Linux Operating System are mentioned below.
● Portable - Software's portability refers to its ability to run on various types of hardware in the same way. The Linux kernel and application programs can be installed on virtually any hardware platform.
● Open Source - Linux is a community-based programming project with freely available source code. Multiple teams collaborate to improve the capabilities of the Linux operating system, which is constantly changing.
● Multi-User - Linux is a multiuser system, which means that multiple users can share system resources such as memory, ram, and application programs.
● Multiprogramming - Linux is a multiprogramming method, which means it can run several programs at the same time.
● Hierarchical File System - System files and user files are organized in a common file structure in Linux.
● Shell - Linux has a special interpreter program that can be used to run operating system commands. It can be used to perform a variety of tasks, such as calling application programs.
● Security - User security is provided by Linux by authentication features such as password protection, restricted access to sensitive files, and data encryption.
Q3) What is operating system and explain its features?
A3) An Operating system (OS) is a software which acts as an interface between the end user and computer hardware. Every computer must have at least one OS to run other programs. An application like Chrome, MS Word, Games, etc needs some environment in which it will run and perform its task. The OS helps you to communicate with the computer without knowing how to speak the computer's language. It is not possible for the user to use any computer or mobile device without having an operating system.
Features of Operating System
Here is a list commonly found important features of an Operating System:
● Protected and supervisor mode
● Allows disk access and file systems Device drivers Networking Security
● Program Execution
● Memory management Virtual Memory Multitasking
● Handling I/O operations
● Manipulation of the file system
● Error Detection and handling
● Resource allocation
● Information and Resource Protection
Q4) What are the Functions of an Operating System?
A4) Functions of Operating System
Fig 2. Function of an Operating System
In an operating system software performs each of the function:
- Process management: Process management helps OS to create and delete processes. It also provides mechanisms for synchronization and communication among processes.
- Memory management: Memory management module performs the task of allocation and deallocation of memory space to programs in need of this resources.
- File management: It manages all the file-related activities such as organization storage, retrieval, naming, sharing, and protection of files.
- Device Management: Device management keeps tracks of all devices. This module also responsible for this task is known as the I/O controller. It also performs the task of allocation and deallocation of the devices.
- I/O System Management: One of the main objects of any OS is to hide the peculiarities of that hardware devices from the user.
- Secondary-Storage Management: Systems have several levels of storage which includes primary storage, secondary storage, and cache storage. Instructions and data must be stored in primary storage or cache so that a running program can reference it.
- Security: Security module protects the data and information of a computer system against malware threat and authorized access.
- Command interpretation: This module is interpreting commands given by the and acting system resources to process that commands.
- Networking: A distributed system is a group of processors which do not share memory, hardware devices, or a clock. The processors communicate with one another through the network.
- Job accounting: Keeping track of time & resource used by various job and users.
- Communication management: Coordination and assignment of compilers, interpreters, and another software resource of the various users of the computer systems..
Q5) What are the advantages and disadvantages of operating systems?
A5) The advantage of using Operating System
● Allows you to hide details of hardware by creating an abstraction
● Easy to use with a GUI
● Offers an environment in which a user may execute programs/applications
● The operating system must make sure that the computer system convenient to use
● Operating System acts as an intermediary among applications and the hardware components
● It provides the computer system resources with easy to use format
● Acts as an intermediator between all hardware's and software's of the system
Disadvantages of using Operating System
● If any issue occurs in OS, you may lose all the contents which have been stored in your system
● Operating system's software is quite expensive for small size organization which adds burden on them. Example Windows
● It is never entirely secure as a threat can occur at any time
Q6) Explain the Unix system?
A6) Unix System: The UNIX operating system is a set of programs that act as a link between the computer and the user. The computer programs that allocate the system resources and coordinate all the details of the computer's internal is called the operating system or kernel.
Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.
Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas Mcllroy, and Joe Ossanna.
There are various Unix variants available in the market. Solaris Unix, AIX, HP Unix and BSD are few examples, Linux is also a flavor of Unix which is freely available.
Several people can use a UNIX computer at the same time, hence UNIX is called a multiuser system. A user can also run multiple programs at the same time; hence UNIX is called multitasking.
A Brief History of UNIX
Q7) Explain Linux system?
A7) Linux
From smartphones to cars, supercomputers and home appliances, home desktops to enterprise servers, the Linux operating system is everywhere.
Linux has been around since the mid-1990s and has since reached a user-base that spans the globe. Linux is actually everywhere: It's in your phones, your thermostats, in your cars, refrigerators, Roku devices, and televisions. It also runs most of the Internet, all of the world’s top 500 supercomputers, and the world’s stock exchanges.
But besides being the platform of choice to run desktops, servers, and embedded systems across the globe, Linux is one of the most reliable, secure and worry-free operating systems available.
Here is all the information you need to get up to speed on the Linux platform.
What is Linux?
Just like Windows, iOS, and Mac OS, Linux is an operating system. In fact, one of the most popular platforms on the planet, Android, is powered by the Linux operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply, the operating system manages the communication between your software and your hardware. Without the operating system (OS), the software wouldn’t function.
The Linux operating system comprises several different pieces:
● Bootloader – The software that manages the boot process of your computer. For most users, this will simply be a splash screen that pops up and eventually goes away to boot into the operating system.
● Kernel – This is the one piece of the whole that is actually called Linux. The kernel is the core of the system and manages the CPU, memory, and peripheral devices. The kernel is the lowest level of the OS.
● Init system – This is a sub-system that bootstraps the user space and is charged with controlling daemons. One of the most widely used init systems is system which also happens to be one of the most controversial. It is the init system that manages the boot process, once the initial booting is handed over from the bootloader (i.e., GRUB or GRand Unified Bootloader).
● Daemons – These are background services (printing, sound, scheduling, etc.) that either start up during boot or after you log into the desktop.
● Graphical server – This is the sub-system that displays the graphics on your monitor. It is commonly referred to as the X server or just X.
● Desktop environment – This is the piece that the users actually interact with. There are many desktop environments to choose from (GNOME, Cinnamon, Mate, Pantheon, Enlightenment, KDE, Xfce, etc.). Each desktop environment includes built-in applications (such as file managers, configuration tools, web browsers, and games).
● Applications – Desktop environments do not offer the full array of apps. Just like Windows and macOS, Linux offers thousands upon thousands of high-quality software titles that can be easily found and installed. Most modern Linux distributions (more on this below) include App Store-like tools that centralize and simplify application installation. For example, Ubuntu Linux has the Ubuntu Software Center (a rebrand of GNOME Software? Figure 1) which allows you to quickly search among the thousands of apps and install them from one centralized location.
Q8) What are the features of Linux?
A8) Features of Linux
Some of the most significant features of the Linux Operating System are mentioned below.
● Portable - Software's portability refers to its ability to run on various types of hardware in the same way. The Linux kernel and application programs can be installed on virtually any hardware platform.
● Open Source - Linux is a community-based programming project with freely available source code. Multiple teams collaborate to improve the capabilities of the Linux operating system, which is constantly changing.
● Multi-User - Linux is a multiuser system, which means that multiple users can share system resources such as memory, ram, and application programs.
● Multiprogramming - Linux is a multiprogramming method, which means it can run several programs at the same time.
● Hierarchical File System - System files and user files are organized in a common file structure in Linux.
● Shell - Linux has a special interpreter program that can be used to run operating system commands. It can be used to perform a variety of tasks, such as calling application programs.
● Security - User security is provided by Linux by authentication features such as password protection, restricted access to sensitive files, and data encryption.
Q9) Explain cal command?
A9) cal command
The cal command in Linux is used to display the calendar for a particular month or for the entire year.
Syntax:
Cal [ [ month ] year]
Or
Cal [options] [month] [year]
Calendar other option
-1 - As a production, it shows a single month.
-3 - Prev/current/next month production is shown.
-s - The first day of the week is shown as Sunday.
-m - The first day of the week is shown as Monday.
-j - Julian dates are shown (days one-based, numbered from January 1).
-y - The current year's calendar is shown.
Example 1:
Cal -3 5 2008
The calendar for the months of April, May, and June in the year 2008 is shown.
Example 2:
Q10) Write syntax and example of date command?
A10) date command
The date command is used to show the current date and time on the machine. The date command is often used to set the system's date and time.
Syntax:
$date
Example:
Q11) Explain echo command?
A11) echo command
In Linux, the echo command is used to show a line of text/string that has been passed as an argument. This is a built-in command that outputs status text to the screen or a file. It's mainly used in shell scripts and batch files.
Syntax:
Echo "enter text"
Example:
In this example, we use the -p command line option to enter the input on the same PROMPT:
Read -p PROMPT <variable_name>
Echo option
-n: The trailing newline should not be production.
-E: STRINGs would not be able to read certain sequences.
Example:
Q12) Explain who commands?
A12) who command
Who w – Command: UNIX maintains an account for all the current system. Because it is a multi-user system it is prudent for the user to be aware of other current users so that s/he can communicate with them if required. The user login details of all the current users by using the who command. The use of who command provides a list of all the current users in the three-column format by default, as shown follows:
$ who
Raj console Nov 19 09:35
Reena tty01 Nov 19 09:40
Priya tty02 Nov 19 09:41
The first column shows the name of the users, the second column shows the device names and the third column shows the login time. Some options like -H, -u and -T can be used with this command.
The H option provides headers for the columns and the -u option provides more details like idle time, PID and comments as shown in the example below.
$ who-Hu
NAME LINE TIME IDLE PID COMMENTS
Raj console Nov 19 09:35 # 32
Reena tty01 Nov 19 09:40 0:20 33
Priya tty01 Nov 19 09:41 0:40 34
If any terminal is idle If any terminal is idle (not active) for the last 1 minute, the information, that is, for how long that terminal is idle will be indicated on the IDLE column. Thus, 0:20 indicates that reena's terminal is IDLE for the last 20 minutes. This information will be useful to the system administrator. The PID indicates the process identification number. The self-login details of a user can be obtained as a single line output using am and i arguments along with the who command as follows.
$ who am i
Reena tty01 Nov 1909:40
Generally, the who command is used by the system administrator for monitoring terminals.
The w command is a quick way to see who is logged on and what they are doing.
Q13) Define creating and removing directories?
A13) mkdir
The command mkdir means 'make directory.' You can construct a new directory anywhere in your system by using the mkdir command. Simply type "mkdir dir name>" (instead of dir name>, type the name of the new directory you want to create) and hit enter.
Syntax:
Mkdir <dirname>
Mkdir option
Option | Description |
Mkdir, -p, -parents | Add the directory, as well as its subdirectories. |
Mkdir, -v, -verbose | For each newly formed directory, print a message. |
Mkdir -m -mode=MODE | Set the permissions for entry. |
Rmdir
Removing Directories
The rmdir command can be used to remove directories as follows:
$rmdir dirname
$
If you want to delete a directory, make sure it's empty, which means there should be no files or subdirectories inside.
You can delete several folders at the same time by doing the following:
$rmdir dirname1 dirname2 dirname3
$
If the directories dirname1, dirname2, and dirname3 are empty, the command above removes them. If the rmdir command is effective, no output is generated.
Rmdir -p
This command deletes a directory and all of its subdirectories at the same time. The command 'rmdir -p' was used to remove all sub-directories.
Q14) What are changing directories?
A14) To modify the current working directory in Linux, use the cd command ( i.e., in which the current user is working). 'Change directory' is represented by the letter "cd." In the Linux terminal, it's one of the most commonly used commands.
Syntax:
Cd <dirname>
It's one of the most critical and widely used commands in the Linux system, and you'll see it a lot. We can navigate through our system's directories with the aid of this order. We may go back to the previous directory, forward to the next directory, or anywhere else.
The cd command can be used for more than just changing directories. By specifying a valid absolute or relative path, you can change to any directory. The syntax is as follows:
$cd dirname
$
The name of the directory you want to change to is provided by dirname. For instance, the command
$cd /usr/local/bin
$
Changes to the /usr/local/bin directory. You may use the following relative path to cd to the directory /usr/home/amrood from this directory:
$cd ../../home/amrood
$
Q15) Describe the types of file?
A15) A file type is used to describe the type of data that is saved in a file. Linux recognizes seven different file forms. Regular files, Directory files, Link files, Character special files, Block special files, Socket files, and Named pipe files are all examples of file types.
A list of these file types can be found in the table below.
/-----------------------------------------------\
|-|Regular File|
|d|Directory|
|l|Symbolic Link|
|b|Block Special File|
|c|Character Special File
|p|Named Pipe|
|s|Socket|
\-----------------------------------------------/
Regular file
Text, audio, video, images, scripts, and programs are only some of the content types that can be stored in regular or ordinary files. There are a plethora of content styles to choose from. Standard files, with or without an extension, can be built in Linux.
An extension is a collection of characters added to the end of a file name to give it a unique identity or to group it with other files of the same type of material. Files of various content types often use well-known file extensions for ease of identification and processing.
Despite the fact that the Linux file system does not need file extensions, you can still use them. They assist us in recognizing the different types of content contained in files. If a file's extension is.mp4, for example, you can assume it's a video file.
The /etc/mime.types file contains a full list of content types and file extensions that your Linux framework supports. The MIME (Multipurpose Internet Mail Extensions) standard assigns file content types a standard designation and classification.
To access the contents of this file, use any standard file reading command.
Directory
File systems use folders to arrange data in a hierarchy. Directories are similar to files, but instead of storing data, they keep track of where other files are located. Directory entries are used to store the location of files stored in the directory. A single file's name and location are stored in each directory entry.
The Linux file system begins with the directory /, also known as the root directory. This directory is where all files and directory files are made. Each directory, with the exception of the root directory, has a parent directory.
Symbolic link
We can use a file with a different filename and from a different location with link files. We use connecting files for this. A connection file is a file that contains a reference to another file. A hard connection and a symbolic or soft link are the two forms of connections.
A hard connection makes a copy of the original file that is identical to it. A hard connection to a directory or file on another filesystem is not possible. A reference to the original file is created by a soft or symbolic connection. A soft connection to a directory or file on another filesystem can be formed.
Block or Character special file
Block Special Files are used to communicate with hardware in blocks of data of 512 bytes, 1024 bytes, or 2048 bytes, depending on the hardware.
Hard drives, printers, displays, terminal emulators, and CD/DVD drives are all treated as special files in Linux. This ensures that a program can view and use files and devices in the same way that a user can. This feature makes it simpler and more versatile to build programs in Linux.
The /dev directory is where Linux stores all special files and system files. A character special file and a block special file are the two types of special files. A character special file represents a computer, such as a monitor or printer, that transfers data in bytes. A block special file represents a computer, such as a hard drive, that transfers data in blocks.
One character at a time is communicated with hardware using the Character Special File. Block and Character Special Files are usually found in the /dev directory.
Named pipe
A named pipe is a file that transfers data from one process to another.
The data that is passed between one process writing data into a named pipe and another process reading data from the named pipe is not stored in the named pipe. The mkfifo command can be used to build a named pipe.
We can use Linux to send the output of some process or command as the input to another process or command. The pipe is the name for this element. Only when both processes are initiated by the same user and are in the same parent process space do pipes function.
Standard pipes will not function if processes are run under different user names and permissions. Named pipes are used in these situations. Named pipes are similar to regular pipes, but they can be accessed via the filesystem.
The empty pipe files are known as named pipe files. Named pipe files are processed by the kernel without being written to the file system. Pipe files with names can be found anywhere in the file system. The FIFO (First In First Out) files are also known as pipe files.
Socket
The Socket File is a stylized inter-process communication mechanism.
It is highly uncommon for a user or even a system administrator to build a socket directly.
A socket is a data-exchange communication endpoint used by applications. When an application needs to communicate with another application, it connects to the application's socket.
A socket is used for any application that offers services to other applications or remote clients. Each socket has an IP address and port number associated with it, allowing it to accept connections from clients.
For example, if a local system application needs to communicate with a remote system application, it connects to that application's socket using the IP address and port number associated with that socket.
Sockets are very difficult to understand. Socket files are used by Linux to make communication between local applications easier. Socket files allow local device applications to share data without having to go through the complicated networking and sockets processes.
Socket files are files that use a file name instead of an IP address and port number as their address. To allow inter-process communication between local applications, socket files use the sendmsg() and recvmsg() system calls.
Q16) What are the needs of the operating system?
A16) Need of Operating System
● OS as a platform for Application programs: The operating system serves as a foundation for other programmes known as application programmes to execute on. These application programmes make it easier for consumers to complete a given task. It serves as a link between the user and the computer. It is created in such a way that it can operate, control, and execute various computer applications.
● Managing Input-Output unit: The computer's operating system also allows it to manage its own resources, such as memory, display, keyboard, printer, and so on. Effective usage of these resources necessitates resource management. The operating system manages the system's input-output resources and distributes them to users or programmes based on their needs.
○ Consistent user interface: The operating system offers the user with an easy-to-use user interface, allowing the user to focus on the content and be productive as quickly as possible without having to learn a new UI each time. The operating system provides templates and UI components to make using a computer as simple as possible for the user.
● Multitasking: Memory is managed by the operating system, which allows several programmes to execute in their own space and even connect with one another via shared memory. Users benefit from multitasking since they can complete multiple tasks on a computer at the same time.
● Booting: The process of starting the computer is known as booting. When the CPU is turned on for the first time, there is nothing in the memory. So, in order to turn on the computer, we must first load the operating system into main memory. As a result, booting is the process of loading the operating system into main memory in order to start the computer. As a result, the operating system aids in the initialization of the computer when the power is turned on.
● Platform for other application software: Different application programmes are required by users to complete particular jobs on the system. The operating system (OS) supervises and regulates these programmes to ensure that they run smoothly. To put it another way, it serves as a link between the user and the programmes.
● Manages the memory: It aids in the management of the computer's main memory. It also allocates and deallocates memory for all programmes and tasks.
● Manages the system files: It aids in the organization of files on the computer. All of the data on the system is stored in files, as we all know. It makes working with the files simple.
● Provides Security: It uses authorisation to keep the system and applications safe. As a result, the operating system protects the system.
Q17) Write the difference between firmware and operating system?
A17) Difference between Firmware and Operating System
Firmware | Operating System |
Firmware is one kind of programming that is embedded on a chip in the device which controls that specific device. | OS provides functionality over and above that which is provided by the firmware. |
Firmware is programs that been encoded by the manufacture of the IC or something and cannot be changed. | OS is a program that can be installed by the user and can be changed. |
It is stored on non-volatile memory. | OS is stored on the hard drive. |
Q18) Write the difference between linux and window system?
A18) The following are the key distinctions between Linux and Windows
Sr. No. | Key | Linux | Windows |
1 | Open Source | Linux is an open source operating system that is completely free to use. | Windows isn't free to use and isn't open source. |
2 | Case sensitivity | The case of files in the Linux file system is important. | The Windows file system does not care about case. |
3 | Kernel type | Linux uses monolithic kernel. | Windows uses micro kernel. |
4 | Efficiency | When compared to Windows, Linux is more efficient in terms of operations. | In terms of operations, Windows is less efficient. |
5 | Path Separator | The forward slash is used in Linux as a path separator between directories. | The backward slash is used as a path separator in Windows. |
6 | Security | In comparison to Windows, Linux is quite secure. | When compared to Linux, Windows offers inferior security. |
Q19) Explain cat and cp command?
A19) cat command
The command 'cat' is the most often used and powerful. It's regarded as one of the most commonly used commands. It can display a file's content, copy content from one file to another, concatenate the contents of multiple files, display the line number, display $ at the end of a line, and so on.
Syntax:
Cat [OPTION]... [FILE]..
To make a file, follow these steps:
Cat > <file name>
// Enter file content
To save the file, press the "CTRL+ D" keys. To see the contents of the file, run it like this:
Cat <file name>
Linux cat command usage
Option | Function |
Cat > [fileName] | To create a file. |
Cat [oldfile] > [newfile] | Copy material from an older file to a new one. |
Cat [file1 file2 and so on] > [new file name] | To combine the contents of several files into a single file. |
Cat -n/cat -b [fileName] | To display line numbers. |
Cat -e [fileName] | The $ character will be displayed at the end of each line. |
Cat [fileName] <<EOF | Used to indicate the end of a page. |
Cp command
'cp' stands for copy. To copy a file or a directory, use the 'cp' command.
Syntax:
To copy in the same directory:
Cp <existing file name> <new file name>
Cp Options
Option | Function |
Cp -r | To duplicate a directory and all of its subdirectories.. |
Cp file1 file 2 directory name | Multiple files or directories in a directory are copied. |
Cp -backup | Before overwriting an existing file, make a backup. |
Cp -i | Asks for confirmation. |
Cp -l | To create a file with a hard link. |
Cp -p | Preserves a file's attribute. |
Cp -u -v | To ensure that the source file is older than the destination file. |
Q20) Write short notes on rm commands?
A20) rm command
'rm' stands for 'remove.' To remove a file, use this command. Unlike other GUIs, the command line does not feature a recycling bin or trash to recover files. As a result, exercise extreme caution when using this command. When you delete a file, it is permanently deleted.
Syntax:
Rm <file name>
Rm Options
Option | Description |
Rm *extension | Deletes files with the same extension. |
Rm -r or R | To recursively erase a directory. |
Rm -i | Interactively delete a file. |
Rm -rf | Forcefully delete a directory. |
Unit - 1
Introduction to Operating System
Q1) Explain Architecture of Linux?
A1) Kernel, shell and applications
The Linux operating system is a common variant of the UNIX operating system that aims to provide a free or low-cost operating system for personal computer users. It earned a reputation as a system that was both fast and effective. This is an incredibly comprehensive operating system, with features such as a graphical user interface (GUI), TCP/IP, the Emacs editor, and the X Window System. Debian, Ubuntu, Fedora, Red Hat Linux, SUSE Linux, Gentoo, Kali Linux, and Centos are the best Linux operating systems.
Fig 1: Linux architecture
Kernel
The kernel is the most important component of Linux. It is in charge of the operating system's main functions. It is made up of different modules that communicate directly with the hardware. Kernel provides the required abstraction for device or application programs to hide low-level hardware information.
The kernel is the central interface between a computer's hardware and its processes and is the most important part of a Linux operating system (OS). It interacts between the two, allowing for the most effective use of resources.
The following are the different forms of Kernels:
● Monolithic Kernel
● Microkernels
● Exo kernels
● Hybrid kernels
The kernel performs four functions:
- Memory management - Keep track of how much memory is being used for what, and where it is being stored.
- Process management - Determine can processes, when and for how long, should use the central processing unit (CPU).
- Device driver - Act as a liaison between the hardware and the processes.
- System call and security - Receive service requests from the processes.
Shell
The shell is a user-to-kernel interface that allows the kernel to provide services to the user. It receives user commands and performs the kernel's functions. The Shell can be used in a variety of operating systems and is divided into two categories: command-line shells and graphical shells.
A command-line interface is provided by command-line shells, while a graphical user interface is provided by graphical line shells. Despite the fact that both shells execute operations, graphical user interface shells are slower than command line interface shells.
An interface to the kernel that conceals the ambiguity of the kernel's functions from the user. The shell receives user commands and performs kernel functions.
Shells are divided into four categories:
● Korn shell
● Bourne shell
● C shell
● POSIX shell
Q2) Write the features of Linux?
A2) Features of Linux
Some of the most significant features of the Linux Operating System are mentioned below.
● Portable - Software's portability refers to its ability to run on various types of hardware in the same way. The Linux kernel and application programs can be installed on virtually any hardware platform.
● Open Source - Linux is a community-based programming project with freely available source code. Multiple teams collaborate to improve the capabilities of the Linux operating system, which is constantly changing.
● Multi-User - Linux is a multiuser system, which means that multiple users can share system resources such as memory, ram, and application programs.
● Multiprogramming - Linux is a multiprogramming method, which means it can run several programs at the same time.
● Hierarchical File System - System files and user files are organized in a common file structure in Linux.
● Shell - Linux has a special interpreter program that can be used to run operating system commands. It can be used to perform a variety of tasks, such as calling application programs.
● Security - User security is provided by Linux by authentication features such as password protection, restricted access to sensitive files, and data encryption.
Q3) What is operating system and explain its features?
A3) An Operating system (OS) is a software which acts as an interface between the end user and computer hardware. Every computer must have at least one OS to run other programs. An application like Chrome, MS Word, Games, etc needs some environment in which it will run and perform its task. The OS helps you to communicate with the computer without knowing how to speak the computer's language. It is not possible for the user to use any computer or mobile device without having an operating system.
Features of Operating System
Here is a list commonly found important features of an Operating System:
● Protected and supervisor mode
● Allows disk access and file systems Device drivers Networking Security
● Program Execution
● Memory management Virtual Memory Multitasking
● Handling I/O operations
● Manipulation of the file system
● Error Detection and handling
● Resource allocation
● Information and Resource Protection
Q4) What are the Functions of an Operating System?
A4) Functions of Operating System
Fig 2. Function of an Operating System
In an operating system software performs each of the function:
- Process management: Process management helps OS to create and delete processes. It also provides mechanisms for synchronization and communication among processes.
- Memory management: Memory management module performs the task of allocation and deallocation of memory space to programs in need of this resources.
- File management: It manages all the file-related activities such as organization storage, retrieval, naming, sharing, and protection of files.
- Device Management: Device management keeps tracks of all devices. This module also responsible for this task is known as the I/O controller. It also performs the task of allocation and deallocation of the devices.
- I/O System Management: One of the main objects of any OS is to hide the peculiarities of that hardware devices from the user.
- Secondary-Storage Management: Systems have several levels of storage which includes primary storage, secondary storage, and cache storage. Instructions and data must be stored in primary storage or cache so that a running program can reference it.
- Security: Security module protects the data and information of a computer system against malware threat and authorized access.
- Command interpretation: This module is interpreting commands given by the and acting system resources to process that commands.
- Networking: A distributed system is a group of processors which do not share memory, hardware devices, or a clock. The processors communicate with one another through the network.
- Job accounting: Keeping track of time & resource used by various job and users.
- Communication management: Coordination and assignment of compilers, interpreters, and another software resource of the various users of the computer systems..
Q5) What are the advantages and disadvantages of operating systems?
A5) The advantage of using Operating System
● Allows you to hide details of hardware by creating an abstraction
● Easy to use with a GUI
● Offers an environment in which a user may execute programs/applications
● The operating system must make sure that the computer system convenient to use
● Operating System acts as an intermediary among applications and the hardware components
● It provides the computer system resources with easy to use format
● Acts as an intermediator between all hardware's and software's of the system
Disadvantages of using Operating System
● If any issue occurs in OS, you may lose all the contents which have been stored in your system
● Operating system's software is quite expensive for small size organization which adds burden on them. Example Windows
● It is never entirely secure as a threat can occur at any time
Q6) Explain the Unix system?
A6) Unix System: The UNIX operating system is a set of programs that act as a link between the computer and the user. The computer programs that allocate the system resources and coordinate all the details of the computer's internal is called the operating system or kernel.
Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.
Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas Mcllroy, and Joe Ossanna.
There are various Unix variants available in the market. Solaris Unix, AIX, HP Unix and BSD are few examples, Linux is also a flavor of Unix which is freely available.
Several people can use a UNIX computer at the same time, hence UNIX is called a multiuser system. A user can also run multiple programs at the same time; hence UNIX is called multitasking.
A Brief History of UNIX
Q7) Explain Linux system?
A7) Linux
From smartphones to cars, supercomputers and home appliances, home desktops to enterprise servers, the Linux operating system is everywhere.
Linux has been around since the mid-1990s and has since reached a user-base that spans the globe. Linux is actually everywhere: It's in your phones, your thermostats, in your cars, refrigerators, Roku devices, and televisions. It also runs most of the Internet, all of the world’s top 500 supercomputers, and the world’s stock exchanges.
But besides being the platform of choice to run desktops, servers, and embedded systems across the globe, Linux is one of the most reliable, secure and worry-free operating systems available.
Here is all the information you need to get up to speed on the Linux platform.
What is Linux?
Just like Windows, iOS, and Mac OS, Linux is an operating system. In fact, one of the most popular platforms on the planet, Android, is powered by the Linux operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply, the operating system manages the communication between your software and your hardware. Without the operating system (OS), the software wouldn’t function.
The Linux operating system comprises several different pieces:
● Bootloader – The software that manages the boot process of your computer. For most users, this will simply be a splash screen that pops up and eventually goes away to boot into the operating system.
● Kernel – This is the one piece of the whole that is actually called Linux. The kernel is the core of the system and manages the CPU, memory, and peripheral devices. The kernel is the lowest level of the OS.
● Init system – This is a sub-system that bootstraps the user space and is charged with controlling daemons. One of the most widely used init systems is system which also happens to be one of the most controversial. It is the init system that manages the boot process, once the initial booting is handed over from the bootloader (i.e., GRUB or GRand Unified Bootloader).
● Daemons – These are background services (printing, sound, scheduling, etc.) that either start up during boot or after you log into the desktop.
● Graphical server – This is the sub-system that displays the graphics on your monitor. It is commonly referred to as the X server or just X.
● Desktop environment – This is the piece that the users actually interact with. There are many desktop environments to choose from (GNOME, Cinnamon, Mate, Pantheon, Enlightenment, KDE, Xfce, etc.). Each desktop environment includes built-in applications (such as file managers, configuration tools, web browsers, and games).
● Applications – Desktop environments do not offer the full array of apps. Just like Windows and macOS, Linux offers thousands upon thousands of high-quality software titles that can be easily found and installed. Most modern Linux distributions (more on this below) include App Store-like tools that centralize and simplify application installation. For example, Ubuntu Linux has the Ubuntu Software Center (a rebrand of GNOME Software? Figure 1) which allows you to quickly search among the thousands of apps and install them from one centralized location.
Q8) What are the features of Linux?
A8) Features of Linux
Some of the most significant features of the Linux Operating System are mentioned below.
● Portable - Software's portability refers to its ability to run on various types of hardware in the same way. The Linux kernel and application programs can be installed on virtually any hardware platform.
● Open Source - Linux is a community-based programming project with freely available source code. Multiple teams collaborate to improve the capabilities of the Linux operating system, which is constantly changing.
● Multi-User - Linux is a multiuser system, which means that multiple users can share system resources such as memory, ram, and application programs.
● Multiprogramming - Linux is a multiprogramming method, which means it can run several programs at the same time.
● Hierarchical File System - System files and user files are organized in a common file structure in Linux.
● Shell - Linux has a special interpreter program that can be used to run operating system commands. It can be used to perform a variety of tasks, such as calling application programs.
● Security - User security is provided by Linux by authentication features such as password protection, restricted access to sensitive files, and data encryption.
Q9) Explain cal command?
A9) cal command
The cal command in Linux is used to display the calendar for a particular month or for the entire year.
Syntax:
Cal [ [ month ] year]
Or
Cal [options] [month] [year]
Calendar other option
-1 - As a production, it shows a single month.
-3 - Prev/current/next month production is shown.
-s - The first day of the week is shown as Sunday.
-m - The first day of the week is shown as Monday.
-j - Julian dates are shown (days one-based, numbered from January 1).
-y - The current year's calendar is shown.
Example 1:
Cal -3 5 2008
The calendar for the months of April, May, and June in the year 2008 is shown.
Example 2:
Q10) Write syntax and example of date command?
A10) date command
The date command is used to show the current date and time on the machine. The date command is often used to set the system's date and time.
Syntax:
$date
Example:
Q11) Explain echo command?
A11) echo command
In Linux, the echo command is used to show a line of text/string that has been passed as an argument. This is a built-in command that outputs status text to the screen or a file. It's mainly used in shell scripts and batch files.
Syntax:
Echo "enter text"
Example:
In this example, we use the -p command line option to enter the input on the same PROMPT:
Read -p PROMPT <variable_name>
Echo option
-n: The trailing newline should not be production.
-E: STRINGs would not be able to read certain sequences.
Example:
Q12) Explain who commands?
A12) who command
Who w – Command: UNIX maintains an account for all the current system. Because it is a multi-user system it is prudent for the user to be aware of other current users so that s/he can communicate with them if required. The user login details of all the current users by using the who command. The use of who command provides a list of all the current users in the three-column format by default, as shown follows:
$ who
Raj console Nov 19 09:35
Reena tty01 Nov 19 09:40
Priya tty02 Nov 19 09:41
The first column shows the name of the users, the second column shows the device names and the third column shows the login time. Some options like -H, -u and -T can be used with this command.
The H option provides headers for the columns and the -u option provides more details like idle time, PID and comments as shown in the example below.
$ who-Hu
NAME LINE TIME IDLE PID COMMENTS
Raj console Nov 19 09:35 # 32
Reena tty01 Nov 19 09:40 0:20 33
Priya tty01 Nov 19 09:41 0:40 34
If any terminal is idle If any terminal is idle (not active) for the last 1 minute, the information, that is, for how long that terminal is idle will be indicated on the IDLE column. Thus, 0:20 indicates that reena's terminal is IDLE for the last 20 minutes. This information will be useful to the system administrator. The PID indicates the process identification number. The self-login details of a user can be obtained as a single line output using am and i arguments along with the who command as follows.
$ who am i
Reena tty01 Nov 1909:40
Generally, the who command is used by the system administrator for monitoring terminals.
The w command is a quick way to see who is logged on and what they are doing.
Q13) Define creating and removing directories?
A13) mkdir
The command mkdir means 'make directory.' You can construct a new directory anywhere in your system by using the mkdir command. Simply type "mkdir dir name>" (instead of dir name>, type the name of the new directory you want to create) and hit enter.
Syntax:
Mkdir <dirname>
Mkdir option
Option | Description |
Mkdir, -p, -parents | Add the directory, as well as its subdirectories. |
Mkdir, -v, -verbose | For each newly formed directory, print a message. |
Mkdir -m -mode=MODE | Set the permissions for entry. |
Rmdir
Removing Directories
The rmdir command can be used to remove directories as follows:
$rmdir dirname
$
If you want to delete a directory, make sure it's empty, which means there should be no files or subdirectories inside.
You can delete several folders at the same time by doing the following:
$rmdir dirname1 dirname2 dirname3
$
If the directories dirname1, dirname2, and dirname3 are empty, the command above removes them. If the rmdir command is effective, no output is generated.
Rmdir -p
This command deletes a directory and all of its subdirectories at the same time. The command 'rmdir -p' was used to remove all sub-directories.
Q14) What are changing directories?
A14) To modify the current working directory in Linux, use the cd command ( i.e., in which the current user is working). 'Change directory' is represented by the letter "cd." In the Linux terminal, it's one of the most commonly used commands.
Syntax:
Cd <dirname>
It's one of the most critical and widely used commands in the Linux system, and you'll see it a lot. We can navigate through our system's directories with the aid of this order. We may go back to the previous directory, forward to the next directory, or anywhere else.
The cd command can be used for more than just changing directories. By specifying a valid absolute or relative path, you can change to any directory. The syntax is as follows:
$cd dirname
$
The name of the directory you want to change to is provided by dirname. For instance, the command
$cd /usr/local/bin
$
Changes to the /usr/local/bin directory. You may use the following relative path to cd to the directory /usr/home/amrood from this directory:
$cd ../../home/amrood
$
Q15) Describe the types of file?
A15) A file type is used to describe the type of data that is saved in a file. Linux recognizes seven different file forms. Regular files, Directory files, Link files, Character special files, Block special files, Socket files, and Named pipe files are all examples of file types.
A list of these file types can be found in the table below.
/-----------------------------------------------\
|-|Regular File|
|d|Directory|
|l|Symbolic Link|
|b|Block Special File|
|c|Character Special File
|p|Named Pipe|
|s|Socket|
\-----------------------------------------------/
Regular file
Text, audio, video, images, scripts, and programs are only some of the content types that can be stored in regular or ordinary files. There are a plethora of content styles to choose from. Standard files, with or without an extension, can be built in Linux.
An extension is a collection of characters added to the end of a file name to give it a unique identity or to group it with other files of the same type of material. Files of various content types often use well-known file extensions for ease of identification and processing.
Despite the fact that the Linux file system does not need file extensions, you can still use them. They assist us in recognizing the different types of content contained in files. If a file's extension is.mp4, for example, you can assume it's a video file.
The /etc/mime.types file contains a full list of content types and file extensions that your Linux framework supports. The MIME (Multipurpose Internet Mail Extensions) standard assigns file content types a standard designation and classification.
To access the contents of this file, use any standard file reading command.
Directory
File systems use folders to arrange data in a hierarchy. Directories are similar to files, but instead of storing data, they keep track of where other files are located. Directory entries are used to store the location of files stored in the directory. A single file's name and location are stored in each directory entry.
The Linux file system begins with the directory /, also known as the root directory. This directory is where all files and directory files are made. Each directory, with the exception of the root directory, has a parent directory.
Symbolic link
We can use a file with a different filename and from a different location with link files. We use connecting files for this. A connection file is a file that contains a reference to another file. A hard connection and a symbolic or soft link are the two forms of connections.
A hard connection makes a copy of the original file that is identical to it. A hard connection to a directory or file on another filesystem is not possible. A reference to the original file is created by a soft or symbolic connection. A soft connection to a directory or file on another filesystem can be formed.
Block or Character special file
Block Special Files are used to communicate with hardware in blocks of data of 512 bytes, 1024 bytes, or 2048 bytes, depending on the hardware.
Hard drives, printers, displays, terminal emulators, and CD/DVD drives are all treated as special files in Linux. This ensures that a program can view and use files and devices in the same way that a user can. This feature makes it simpler and more versatile to build programs in Linux.
The /dev directory is where Linux stores all special files and system files. A character special file and a block special file are the two types of special files. A character special file represents a computer, such as a monitor or printer, that transfers data in bytes. A block special file represents a computer, such as a hard drive, that transfers data in blocks.
One character at a time is communicated with hardware using the Character Special File. Block and Character Special Files are usually found in the /dev directory.
Named pipe
A named pipe is a file that transfers data from one process to another.
The data that is passed between one process writing data into a named pipe and another process reading data from the named pipe is not stored in the named pipe. The mkfifo command can be used to build a named pipe.
We can use Linux to send the output of some process or command as the input to another process or command. The pipe is the name for this element. Only when both processes are initiated by the same user and are in the same parent process space do pipes function.
Standard pipes will not function if processes are run under different user names and permissions. Named pipes are used in these situations. Named pipes are similar to regular pipes, but they can be accessed via the filesystem.
The empty pipe files are known as named pipe files. Named pipe files are processed by the kernel without being written to the file system. Pipe files with names can be found anywhere in the file system. The FIFO (First In First Out) files are also known as pipe files.
Socket
The Socket File is a stylized inter-process communication mechanism.
It is highly uncommon for a user or even a system administrator to build a socket directly.
A socket is a data-exchange communication endpoint used by applications. When an application needs to communicate with another application, it connects to the application's socket.
A socket is used for any application that offers services to other applications or remote clients. Each socket has an IP address and port number associated with it, allowing it to accept connections from clients.
For example, if a local system application needs to communicate with a remote system application, it connects to that application's socket using the IP address and port number associated with that socket.
Sockets are very difficult to understand. Socket files are used by Linux to make communication between local applications easier. Socket files allow local device applications to share data without having to go through the complicated networking and sockets processes.
Socket files are files that use a file name instead of an IP address and port number as their address. To allow inter-process communication between local applications, socket files use the sendmsg() and recvmsg() system calls.
Q16) What are the needs of the operating system?
A16) Need of Operating System
● OS as a platform for Application programs: The operating system serves as a foundation for other programmes known as application programmes to execute on. These application programmes make it easier for consumers to complete a given task. It serves as a link between the user and the computer. It is created in such a way that it can operate, control, and execute various computer applications.
● Managing Input-Output unit: The computer's operating system also allows it to manage its own resources, such as memory, display, keyboard, printer, and so on. Effective usage of these resources necessitates resource management. The operating system manages the system's input-output resources and distributes them to users or programmes based on their needs.
○ Consistent user interface: The operating system offers the user with an easy-to-use user interface, allowing the user to focus on the content and be productive as quickly as possible without having to learn a new UI each time. The operating system provides templates and UI components to make using a computer as simple as possible for the user.
● Multitasking: Memory is managed by the operating system, which allows several programmes to execute in their own space and even connect with one another via shared memory. Users benefit from multitasking since they can complete multiple tasks on a computer at the same time.
● Booting: The process of starting the computer is known as booting. When the CPU is turned on for the first time, there is nothing in the memory. So, in order to turn on the computer, we must first load the operating system into main memory. As a result, booting is the process of loading the operating system into main memory in order to start the computer. As a result, the operating system aids in the initialization of the computer when the power is turned on.
● Platform for other application software: Different application programmes are required by users to complete particular jobs on the system. The operating system (OS) supervises and regulates these programmes to ensure that they run smoothly. To put it another way, it serves as a link between the user and the programmes.
● Manages the memory: It aids in the management of the computer's main memory. It also allocates and deallocates memory for all programmes and tasks.
● Manages the system files: It aids in the organization of files on the computer. All of the data on the system is stored in files, as we all know. It makes working with the files simple.
● Provides Security: It uses authorisation to keep the system and applications safe. As a result, the operating system protects the system.
Q17) Write the difference between firmware and operating system?
A17) Difference between Firmware and Operating System
Firmware | Operating System |
Firmware is one kind of programming that is embedded on a chip in the device which controls that specific device. | OS provides functionality over and above that which is provided by the firmware. |
Firmware is programs that been encoded by the manufacture of the IC or something and cannot be changed. | OS is a program that can be installed by the user and can be changed. |
It is stored on non-volatile memory. | OS is stored on the hard drive. |
Q18) Write the difference between linux and window system?
A18) The following are the key distinctions between Linux and Windows
Sr. No. | Key | Linux | Windows |
1 | Open Source | Linux is an open source operating system that is completely free to use. | Windows isn't free to use and isn't open source. |
2 | Case sensitivity | The case of files in the Linux file system is important. | The Windows file system does not care about case. |
3 | Kernel type | Linux uses monolithic kernel. | Windows uses micro kernel. |
4 | Efficiency | When compared to Windows, Linux is more efficient in terms of operations. | In terms of operations, Windows is less efficient. |
5 | Path Separator | The forward slash is used in Linux as a path separator between directories. | The backward slash is used as a path separator in Windows. |
6 | Security | In comparison to Windows, Linux is quite secure. | When compared to Linux, Windows offers inferior security. |
Q19) Explain cat and cp command?
A19) cat command
The command 'cat' is the most often used and powerful. It's regarded as one of the most commonly used commands. It can display a file's content, copy content from one file to another, concatenate the contents of multiple files, display the line number, display $ at the end of a line, and so on.
Syntax:
Cat [OPTION]... [FILE]..
To make a file, follow these steps:
Cat > <file name>
// Enter file content
To save the file, press the "CTRL+ D" keys. To see the contents of the file, run it like this:
Cat <file name>
Linux cat command usage
Option | Function |
Cat > [fileName] | To create a file. |
Cat [oldfile] > [newfile] | Copy material from an older file to a new one. |
Cat [file1 file2 and so on] > [new file name] | To combine the contents of several files into a single file. |
Cat -n/cat -b [fileName] | To display line numbers. |
Cat -e [fileName] | The $ character will be displayed at the end of each line. |
Cat [fileName] <<EOF | Used to indicate the end of a page. |
Cp command
'cp' stands for copy. To copy a file or a directory, use the 'cp' command.
Syntax:
To copy in the same directory:
Cp <existing file name> <new file name>
Cp Options
Option | Function |
Cp -r | To duplicate a directory and all of its subdirectories.. |
Cp file1 file 2 directory name | Multiple files or directories in a directory are copied. |
Cp -backup | Before overwriting an existing file, make a backup. |
Cp -i | Asks for confirmation. |
Cp -l | To create a file with a hard link. |
Cp -p | Preserves a file's attribute. |
Cp -u -v | To ensure that the source file is older than the destination file. |
Q20) Write short notes on rm commands?
A20) rm command
'rm' stands for 'remove.' To remove a file, use this command. Unlike other GUIs, the command line does not feature a recycling bin or trash to recover files. As a result, exercise extreme caution when using this command. When you delete a file, it is permanently deleted.
Syntax:
Rm <file name>
Rm Options
Option | Description |
Rm *extension | Deletes files with the same extension. |
Rm -r or R | To recursively erase a directory. |
Rm -i | Interactively delete a file. |
Rm -rf | Forcefully delete a directory. |
Unit - 1
Introduction to Operating System
Q1) Explain Architecture of Linux?
A1) Kernel, shell and applications
The Linux operating system is a common variant of the UNIX operating system that aims to provide a free or low-cost operating system for personal computer users. It earned a reputation as a system that was both fast and effective. This is an incredibly comprehensive operating system, with features such as a graphical user interface (GUI), TCP/IP, the Emacs editor, and the X Window System. Debian, Ubuntu, Fedora, Red Hat Linux, SUSE Linux, Gentoo, Kali Linux, and Centos are the best Linux operating systems.
Fig 1: Linux architecture
Kernel
The kernel is the most important component of Linux. It is in charge of the operating system's main functions. It is made up of different modules that communicate directly with the hardware. Kernel provides the required abstraction for device or application programs to hide low-level hardware information.
The kernel is the central interface between a computer's hardware and its processes and is the most important part of a Linux operating system (OS). It interacts between the two, allowing for the most effective use of resources.
The following are the different forms of Kernels:
● Monolithic Kernel
● Microkernels
● Exo kernels
● Hybrid kernels
The kernel performs four functions:
- Memory management - Keep track of how much memory is being used for what, and where it is being stored.
- Process management - Determine can processes, when and for how long, should use the central processing unit (CPU).
- Device driver - Act as a liaison between the hardware and the processes.
- System call and security - Receive service requests from the processes.
Shell
The shell is a user-to-kernel interface that allows the kernel to provide services to the user. It receives user commands and performs the kernel's functions. The Shell can be used in a variety of operating systems and is divided into two categories: command-line shells and graphical shells.
A command-line interface is provided by command-line shells, while a graphical user interface is provided by graphical line shells. Despite the fact that both shells execute operations, graphical user interface shells are slower than command line interface shells.
An interface to the kernel that conceals the ambiguity of the kernel's functions from the user. The shell receives user commands and performs kernel functions.
Shells are divided into four categories:
● Korn shell
● Bourne shell
● C shell
● POSIX shell
Q2) Write the features of Linux?
A2) Features of Linux
Some of the most significant features of the Linux Operating System are mentioned below.
● Portable - Software's portability refers to its ability to run on various types of hardware in the same way. The Linux kernel and application programs can be installed on virtually any hardware platform.
● Open Source - Linux is a community-based programming project with freely available source code. Multiple teams collaborate to improve the capabilities of the Linux operating system, which is constantly changing.
● Multi-User - Linux is a multiuser system, which means that multiple users can share system resources such as memory, ram, and application programs.
● Multiprogramming - Linux is a multiprogramming method, which means it can run several programs at the same time.
● Hierarchical File System - System files and user files are organized in a common file structure in Linux.
● Shell - Linux has a special interpreter program that can be used to run operating system commands. It can be used to perform a variety of tasks, such as calling application programs.
● Security - User security is provided by Linux by authentication features such as password protection, restricted access to sensitive files, and data encryption.
Q3) What is operating system and explain its features?
A3) An Operating system (OS) is a software which acts as an interface between the end user and computer hardware. Every computer must have at least one OS to run other programs. An application like Chrome, MS Word, Games, etc needs some environment in which it will run and perform its task. The OS helps you to communicate with the computer without knowing how to speak the computer's language. It is not possible for the user to use any computer or mobile device without having an operating system.
Features of Operating System
Here is a list commonly found important features of an Operating System:
● Protected and supervisor mode
● Allows disk access and file systems Device drivers Networking Security
● Program Execution
● Memory management Virtual Memory Multitasking
● Handling I/O operations
● Manipulation of the file system
● Error Detection and handling
● Resource allocation
● Information and Resource Protection
Q4) What are the Functions of an Operating System?
A4) Functions of Operating System
Fig 2. Function of an Operating System
In an operating system software performs each of the function:
- Process management: Process management helps OS to create and delete processes. It also provides mechanisms for synchronization and communication among processes.
- Memory management: Memory management module performs the task of allocation and deallocation of memory space to programs in need of this resources.
- File management: It manages all the file-related activities such as organization storage, retrieval, naming, sharing, and protection of files.
- Device Management: Device management keeps tracks of all devices. This module also responsible for this task is known as the I/O controller. It also performs the task of allocation and deallocation of the devices.
- I/O System Management: One of the main objects of any OS is to hide the peculiarities of that hardware devices from the user.
- Secondary-Storage Management: Systems have several levels of storage which includes primary storage, secondary storage, and cache storage. Instructions and data must be stored in primary storage or cache so that a running program can reference it.
- Security: Security module protects the data and information of a computer system against malware threat and authorized access.
- Command interpretation: This module is interpreting commands given by the and acting system resources to process that commands.
- Networking: A distributed system is a group of processors which do not share memory, hardware devices, or a clock. The processors communicate with one another through the network.
- Job accounting: Keeping track of time & resource used by various job and users.
- Communication management: Coordination and assignment of compilers, interpreters, and another software resource of the various users of the computer systems..
Q5) What are the advantages and disadvantages of operating systems?
A5) The advantage of using Operating System
● Allows you to hide details of hardware by creating an abstraction
● Easy to use with a GUI
● Offers an environment in which a user may execute programs/applications
● The operating system must make sure that the computer system convenient to use
● Operating System acts as an intermediary among applications and the hardware components
● It provides the computer system resources with easy to use format
● Acts as an intermediator between all hardware's and software's of the system
Disadvantages of using Operating System
● If any issue occurs in OS, you may lose all the contents which have been stored in your system
● Operating system's software is quite expensive for small size organization which adds burden on them. Example Windows
● It is never entirely secure as a threat can occur at any time
Q6) Explain the Unix system?
A6) Unix System: The UNIX operating system is a set of programs that act as a link between the computer and the user. The computer programs that allocate the system resources and coordinate all the details of the computer's internal is called the operating system or kernel.
Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.
Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas Mcllroy, and Joe Ossanna.
There are various Unix variants available in the market. Solaris Unix, AIX, HP Unix and BSD are few examples, Linux is also a flavor of Unix which is freely available.
Several people can use a UNIX computer at the same time, hence UNIX is called a multiuser system. A user can also run multiple programs at the same time; hence UNIX is called multitasking.
A Brief History of UNIX
Q7) Explain Linux system?
A7) Linux
From smartphones to cars, supercomputers and home appliances, home desktops to enterprise servers, the Linux operating system is everywhere.
Linux has been around since the mid-1990s and has since reached a user-base that spans the globe. Linux is actually everywhere: It's in your phones, your thermostats, in your cars, refrigerators, Roku devices, and televisions. It also runs most of the Internet, all of the world’s top 500 supercomputers, and the world’s stock exchanges.
But besides being the platform of choice to run desktops, servers, and embedded systems across the globe, Linux is one of the most reliable, secure and worry-free operating systems available.
Here is all the information you need to get up to speed on the Linux platform.
What is Linux?
Just like Windows, iOS, and Mac OS, Linux is an operating system. In fact, one of the most popular platforms on the planet, Android, is powered by the Linux operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply, the operating system manages the communication between your software and your hardware. Without the operating system (OS), the software wouldn’t function.
The Linux operating system comprises several different pieces:
● Bootloader – The software that manages the boot process of your computer. For most users, this will simply be a splash screen that pops up and eventually goes away to boot into the operating system.
● Kernel – This is the one piece of the whole that is actually called Linux. The kernel is the core of the system and manages the CPU, memory, and peripheral devices. The kernel is the lowest level of the OS.
● Init system – This is a sub-system that bootstraps the user space and is charged with controlling daemons. One of the most widely used init systems is system which also happens to be one of the most controversial. It is the init system that manages the boot process, once the initial booting is handed over from the bootloader (i.e., GRUB or GRand Unified Bootloader).
● Daemons – These are background services (printing, sound, scheduling, etc.) that either start up during boot or after you log into the desktop.
● Graphical server – This is the sub-system that displays the graphics on your monitor. It is commonly referred to as the X server or just X.
● Desktop environment – This is the piece that the users actually interact with. There are many desktop environments to choose from (GNOME, Cinnamon, Mate, Pantheon, Enlightenment, KDE, Xfce, etc.). Each desktop environment includes built-in applications (such as file managers, configuration tools, web browsers, and games).
● Applications – Desktop environments do not offer the full array of apps. Just like Windows and macOS, Linux offers thousands upon thousands of high-quality software titles that can be easily found and installed. Most modern Linux distributions (more on this below) include App Store-like tools that centralize and simplify application installation. For example, Ubuntu Linux has the Ubuntu Software Center (a rebrand of GNOME Software? Figure 1) which allows you to quickly search among the thousands of apps and install them from one centralized location.
Q8) What are the features of Linux?
A8) Features of Linux
Some of the most significant features of the Linux Operating System are mentioned below.
● Portable - Software's portability refers to its ability to run on various types of hardware in the same way. The Linux kernel and application programs can be installed on virtually any hardware platform.
● Open Source - Linux is a community-based programming project with freely available source code. Multiple teams collaborate to improve the capabilities of the Linux operating system, which is constantly changing.
● Multi-User - Linux is a multiuser system, which means that multiple users can share system resources such as memory, ram, and application programs.
● Multiprogramming - Linux is a multiprogramming method, which means it can run several programs at the same time.
● Hierarchical File System - System files and user files are organized in a common file structure in Linux.
● Shell - Linux has a special interpreter program that can be used to run operating system commands. It can be used to perform a variety of tasks, such as calling application programs.
● Security - User security is provided by Linux by authentication features such as password protection, restricted access to sensitive files, and data encryption.
Q9) Explain cal command?
A9) cal command
The cal command in Linux is used to display the calendar for a particular month or for the entire year.
Syntax:
Cal [ [ month ] year]
Or
Cal [options] [month] [year]
Calendar other option
-1 - As a production, it shows a single month.
-3 - Prev/current/next month production is shown.
-s - The first day of the week is shown as Sunday.
-m - The first day of the week is shown as Monday.
-j - Julian dates are shown (days one-based, numbered from January 1).
-y - The current year's calendar is shown.
Example 1:
Cal -3 5 2008
The calendar for the months of April, May, and June in the year 2008 is shown.
Example 2:
Q10) Write syntax and example of date command?
A10) date command
The date command is used to show the current date and time on the machine. The date command is often used to set the system's date and time.
Syntax:
$date
Example:
Q11) Explain echo command?
A11) echo command
In Linux, the echo command is used to show a line of text/string that has been passed as an argument. This is a built-in command that outputs status text to the screen or a file. It's mainly used in shell scripts and batch files.
Syntax:
Echo "enter text"
Example:
In this example, we use the -p command line option to enter the input on the same PROMPT:
Read -p PROMPT <variable_name>
Echo option
-n: The trailing newline should not be production.
-E: STRINGs would not be able to read certain sequences.
Example:
Q12) Explain who commands?
A12) who command
Who w – Command: UNIX maintains an account for all the current system. Because it is a multi-user system it is prudent for the user to be aware of other current users so that s/he can communicate with them if required. The user login details of all the current users by using the who command. The use of who command provides a list of all the current users in the three-column format by default, as shown follows:
$ who
Raj console Nov 19 09:35
Reena tty01 Nov 19 09:40
Priya tty02 Nov 19 09:41
The first column shows the name of the users, the second column shows the device names and the third column shows the login time. Some options like -H, -u and -T can be used with this command.
The H option provides headers for the columns and the -u option provides more details like idle time, PID and comments as shown in the example below.
$ who-Hu
NAME LINE TIME IDLE PID COMMENTS
Raj console Nov 19 09:35 # 32
Reena tty01 Nov 19 09:40 0:20 33
Priya tty01 Nov 19 09:41 0:40 34
If any terminal is idle If any terminal is idle (not active) for the last 1 minute, the information, that is, for how long that terminal is idle will be indicated on the IDLE column. Thus, 0:20 indicates that reena's terminal is IDLE for the last 20 minutes. This information will be useful to the system administrator. The PID indicates the process identification number. The self-login details of a user can be obtained as a single line output using am and i arguments along with the who command as follows.
$ who am i
Reena tty01 Nov 1909:40
Generally, the who command is used by the system administrator for monitoring terminals.
The w command is a quick way to see who is logged on and what they are doing.
Q13) Define creating and removing directories?
A13) mkdir
The command mkdir means 'make directory.' You can construct a new directory anywhere in your system by using the mkdir command. Simply type "mkdir dir name>" (instead of dir name>, type the name of the new directory you want to create) and hit enter.
Syntax:
Mkdir <dirname>
Mkdir option
Option | Description |
Mkdir, -p, -parents | Add the directory, as well as its subdirectories. |
Mkdir, -v, -verbose | For each newly formed directory, print a message. |
Mkdir -m -mode=MODE | Set the permissions for entry. |
Rmdir
Removing Directories
The rmdir command can be used to remove directories as follows:
$rmdir dirname
$
If you want to delete a directory, make sure it's empty, which means there should be no files or subdirectories inside.
You can delete several folders at the same time by doing the following:
$rmdir dirname1 dirname2 dirname3
$
If the directories dirname1, dirname2, and dirname3 are empty, the command above removes them. If the rmdir command is effective, no output is generated.
Rmdir -p
This command deletes a directory and all of its subdirectories at the same time. The command 'rmdir -p' was used to remove all sub-directories.
Q14) What are changing directories?
A14) To modify the current working directory in Linux, use the cd command ( i.e., in which the current user is working). 'Change directory' is represented by the letter "cd." In the Linux terminal, it's one of the most commonly used commands.
Syntax:
Cd <dirname>
It's one of the most critical and widely used commands in the Linux system, and you'll see it a lot. We can navigate through our system's directories with the aid of this order. We may go back to the previous directory, forward to the next directory, or anywhere else.
The cd command can be used for more than just changing directories. By specifying a valid absolute or relative path, you can change to any directory. The syntax is as follows:
$cd dirname
$
The name of the directory you want to change to is provided by dirname. For instance, the command
$cd /usr/local/bin
$
Changes to the /usr/local/bin directory. You may use the following relative path to cd to the directory /usr/home/amrood from this directory:
$cd ../../home/amrood
$
Q15) Describe the types of file?
A15) A file type is used to describe the type of data that is saved in a file. Linux recognizes seven different file forms. Regular files, Directory files, Link files, Character special files, Block special files, Socket files, and Named pipe files are all examples of file types.
A list of these file types can be found in the table below.
/-----------------------------------------------\
|-|Regular File|
|d|Directory|
|l|Symbolic Link|
|b|Block Special File|
|c|Character Special File
|p|Named Pipe|
|s|Socket|
\-----------------------------------------------/
Regular file
Text, audio, video, images, scripts, and programs are only some of the content types that can be stored in regular or ordinary files. There are a plethora of content styles to choose from. Standard files, with or without an extension, can be built in Linux.
An extension is a collection of characters added to the end of a file name to give it a unique identity or to group it with other files of the same type of material. Files of various content types often use well-known file extensions for ease of identification and processing.
Despite the fact that the Linux file system does not need file extensions, you can still use them. They assist us in recognizing the different types of content contained in files. If a file's extension is.mp4, for example, you can assume it's a video file.
The /etc/mime.types file contains a full list of content types and file extensions that your Linux framework supports. The MIME (Multipurpose Internet Mail Extensions) standard assigns file content types a standard designation and classification.
To access the contents of this file, use any standard file reading command.
Directory
File systems use folders to arrange data in a hierarchy. Directories are similar to files, but instead of storing data, they keep track of where other files are located. Directory entries are used to store the location of files stored in the directory. A single file's name and location are stored in each directory entry.
The Linux file system begins with the directory /, also known as the root directory. This directory is where all files and directory files are made. Each directory, with the exception of the root directory, has a parent directory.
Symbolic link
We can use a file with a different filename and from a different location with link files. We use connecting files for this. A connection file is a file that contains a reference to another file. A hard connection and a symbolic or soft link are the two forms of connections.
A hard connection makes a copy of the original file that is identical to it. A hard connection to a directory or file on another filesystem is not possible. A reference to the original file is created by a soft or symbolic connection. A soft connection to a directory or file on another filesystem can be formed.
Block or Character special file
Block Special Files are used to communicate with hardware in blocks of data of 512 bytes, 1024 bytes, or 2048 bytes, depending on the hardware.
Hard drives, printers, displays, terminal emulators, and CD/DVD drives are all treated as special files in Linux. This ensures that a program can view and use files and devices in the same way that a user can. This feature makes it simpler and more versatile to build programs in Linux.
The /dev directory is where Linux stores all special files and system files. A character special file and a block special file are the two types of special files. A character special file represents a computer, such as a monitor or printer, that transfers data in bytes. A block special file represents a computer, such as a hard drive, that transfers data in blocks.
One character at a time is communicated with hardware using the Character Special File. Block and Character Special Files are usually found in the /dev directory.
Named pipe
A named pipe is a file that transfers data from one process to another.
The data that is passed between one process writing data into a named pipe and another process reading data from the named pipe is not stored in the named pipe. The mkfifo command can be used to build a named pipe.
We can use Linux to send the output of some process or command as the input to another process or command. The pipe is the name for this element. Only when both processes are initiated by the same user and are in the same parent process space do pipes function.
Standard pipes will not function if processes are run under different user names and permissions. Named pipes are used in these situations. Named pipes are similar to regular pipes, but they can be accessed via the filesystem.
The empty pipe files are known as named pipe files. Named pipe files are processed by the kernel without being written to the file system. Pipe files with names can be found anywhere in the file system. The FIFO (First In First Out) files are also known as pipe files.
Socket
The Socket File is a stylized inter-process communication mechanism.
It is highly uncommon for a user or even a system administrator to build a socket directly.
A socket is a data-exchange communication endpoint used by applications. When an application needs to communicate with another application, it connects to the application's socket.
A socket is used for any application that offers services to other applications or remote clients. Each socket has an IP address and port number associated with it, allowing it to accept connections from clients.
For example, if a local system application needs to communicate with a remote system application, it connects to that application's socket using the IP address and port number associated with that socket.
Sockets are very difficult to understand. Socket files are used by Linux to make communication between local applications easier. Socket files allow local device applications to share data without having to go through the complicated networking and sockets processes.
Socket files are files that use a file name instead of an IP address and port number as their address. To allow inter-process communication between local applications, socket files use the sendmsg() and recvmsg() system calls.
Q16) What are the needs of the operating system?
A16) Need of Operating System
● OS as a platform for Application programs: The operating system serves as a foundation for other programmes known as application programmes to execute on. These application programmes make it easier for consumers to complete a given task. It serves as a link between the user and the computer. It is created in such a way that it can operate, control, and execute various computer applications.
● Managing Input-Output unit: The computer's operating system also allows it to manage its own resources, such as memory, display, keyboard, printer, and so on. Effective usage of these resources necessitates resource management. The operating system manages the system's input-output resources and distributes them to users or programmes based on their needs.
○ Consistent user interface: The operating system offers the user with an easy-to-use user interface, allowing the user to focus on the content and be productive as quickly as possible without having to learn a new UI each time. The operating system provides templates and UI components to make using a computer as simple as possible for the user.
● Multitasking: Memory is managed by the operating system, which allows several programmes to execute in their own space and even connect with one another via shared memory. Users benefit from multitasking since they can complete multiple tasks on a computer at the same time.
● Booting: The process of starting the computer is known as booting. When the CPU is turned on for the first time, there is nothing in the memory. So, in order to turn on the computer, we must first load the operating system into main memory. As a result, booting is the process of loading the operating system into main memory in order to start the computer. As a result, the operating system aids in the initialization of the computer when the power is turned on.
● Platform for other application software: Different application programmes are required by users to complete particular jobs on the system. The operating system (OS) supervises and regulates these programmes to ensure that they run smoothly. To put it another way, it serves as a link between the user and the programmes.
● Manages the memory: It aids in the management of the computer's main memory. It also allocates and deallocates memory for all programmes and tasks.
● Manages the system files: It aids in the organization of files on the computer. All of the data on the system is stored in files, as we all know. It makes working with the files simple.
● Provides Security: It uses authorisation to keep the system and applications safe. As a result, the operating system protects the system.
Q17) Write the difference between firmware and operating system?
A17) Difference between Firmware and Operating System
Firmware | Operating System |
Firmware is one kind of programming that is embedded on a chip in the device which controls that specific device. | OS provides functionality over and above that which is provided by the firmware. |
Firmware is programs that been encoded by the manufacture of the IC or something and cannot be changed. | OS is a program that can be installed by the user and can be changed. |
It is stored on non-volatile memory. | OS is stored on the hard drive. |
Q18) Write the difference between linux and window system?
A18) The following are the key distinctions between Linux and Windows
Sr. No. | Key | Linux | Windows |
1 | Open Source | Linux is an open source operating system that is completely free to use. | Windows isn't free to use and isn't open source. |
2 | Case sensitivity | The case of files in the Linux file system is important. | The Windows file system does not care about case. |
3 | Kernel type | Linux uses monolithic kernel. | Windows uses micro kernel. |
4 | Efficiency | When compared to Windows, Linux is more efficient in terms of operations. | In terms of operations, Windows is less efficient. |
5 | Path Separator | The forward slash is used in Linux as a path separator between directories. | The backward slash is used as a path separator in Windows. |
6 | Security | In comparison to Windows, Linux is quite secure. | When compared to Linux, Windows offers inferior security. |
Q19) Explain cat and cp command?
A19) cat command
The command 'cat' is the most often used and powerful. It's regarded as one of the most commonly used commands. It can display a file's content, copy content from one file to another, concatenate the contents of multiple files, display the line number, display $ at the end of a line, and so on.
Syntax:
Cat [OPTION]... [FILE]..
To make a file, follow these steps:
Cat > <file name>
// Enter file content
To save the file, press the "CTRL+ D" keys. To see the contents of the file, run it like this:
Cat <file name>
Linux cat command usage
Option | Function |
Cat > [fileName] | To create a file. |
Cat [oldfile] > [newfile] | Copy material from an older file to a new one. |
Cat [file1 file2 and so on] > [new file name] | To combine the contents of several files into a single file. |
Cat -n/cat -b [fileName] | To display line numbers. |
Cat -e [fileName] | The $ character will be displayed at the end of each line. |
Cat [fileName] <<EOF | Used to indicate the end of a page. |
Cp command
'cp' stands for copy. To copy a file or a directory, use the 'cp' command.
Syntax:
To copy in the same directory:
Cp <existing file name> <new file name>
Cp Options
Option | Function |
Cp -r | To duplicate a directory and all of its subdirectories.. |
Cp file1 file 2 directory name | Multiple files or directories in a directory are copied. |
Cp -backup | Before overwriting an existing file, make a backup. |
Cp -i | Asks for confirmation. |
Cp -l | To create a file with a hard link. |
Cp -p | Preserves a file's attribute. |
Cp -u -v | To ensure that the source file is older than the destination file. |
Q20) Write short notes on rm commands?
A20) rm command
'rm' stands for 'remove.' To remove a file, use this command. Unlike other GUIs, the command line does not feature a recycling bin or trash to recover files. As a result, exercise extreme caution when using this command. When you delete a file, it is permanently deleted.
Syntax:
Rm <file name>
Rm Options
Option | Description |
Rm *extension | Deletes files with the same extension. |
Rm -r or R | To recursively erase a directory. |
Rm -i | Interactively delete a file. |
Rm -rf | Forcefully delete a directory. |
Unit - 1
Introduction to Operating System
Q1) Explain Architecture of Linux?
A1) Kernel, shell and applications
The Linux operating system is a common variant of the UNIX operating system that aims to provide a free or low-cost operating system for personal computer users. It earned a reputation as a system that was both fast and effective. This is an incredibly comprehensive operating system, with features such as a graphical user interface (GUI), TCP/IP, the Emacs editor, and the X Window System. Debian, Ubuntu, Fedora, Red Hat Linux, SUSE Linux, Gentoo, Kali Linux, and Centos are the best Linux operating systems.
Fig 1: Linux architecture
Kernel
The kernel is the most important component of Linux. It is in charge of the operating system's main functions. It is made up of different modules that communicate directly with the hardware. Kernel provides the required abstraction for device or application programs to hide low-level hardware information.
The kernel is the central interface between a computer's hardware and its processes and is the most important part of a Linux operating system (OS). It interacts between the two, allowing for the most effective use of resources.
The following are the different forms of Kernels:
● Monolithic Kernel
● Microkernels
● Exo kernels
● Hybrid kernels
The kernel performs four functions:
- Memory management - Keep track of how much memory is being used for what, and where it is being stored.
- Process management - Determine can processes, when and for how long, should use the central processing unit (CPU).
- Device driver - Act as a liaison between the hardware and the processes.
- System call and security - Receive service requests from the processes.
Shell
The shell is a user-to-kernel interface that allows the kernel to provide services to the user. It receives user commands and performs the kernel's functions. The Shell can be used in a variety of operating systems and is divided into two categories: command-line shells and graphical shells.
A command-line interface is provided by command-line shells, while a graphical user interface is provided by graphical line shells. Despite the fact that both shells execute operations, graphical user interface shells are slower than command line interface shells.
An interface to the kernel that conceals the ambiguity of the kernel's functions from the user. The shell receives user commands and performs kernel functions.
Shells are divided into four categories:
● Korn shell
● Bourne shell
● C shell
● POSIX shell
Q2) Write the features of Linux?
A2) Features of Linux
Some of the most significant features of the Linux Operating System are mentioned below.
● Portable - Software's portability refers to its ability to run on various types of hardware in the same way. The Linux kernel and application programs can be installed on virtually any hardware platform.
● Open Source - Linux is a community-based programming project with freely available source code. Multiple teams collaborate to improve the capabilities of the Linux operating system, which is constantly changing.
● Multi-User - Linux is a multiuser system, which means that multiple users can share system resources such as memory, ram, and application programs.
● Multiprogramming - Linux is a multiprogramming method, which means it can run several programs at the same time.
● Hierarchical File System - System files and user files are organized in a common file structure in Linux.
● Shell - Linux has a special interpreter program that can be used to run operating system commands. It can be used to perform a variety of tasks, such as calling application programs.
● Security - User security is provided by Linux by authentication features such as password protection, restricted access to sensitive files, and data encryption.
Q3) What is operating system and explain its features?
A3) An Operating system (OS) is a software which acts as an interface between the end user and computer hardware. Every computer must have at least one OS to run other programs. An application like Chrome, MS Word, Games, etc needs some environment in which it will run and perform its task. The OS helps you to communicate with the computer without knowing how to speak the computer's language. It is not possible for the user to use any computer or mobile device without having an operating system.
Features of Operating System
Here is a list commonly found important features of an Operating System:
● Protected and supervisor mode
● Allows disk access and file systems Device drivers Networking Security
● Program Execution
● Memory management Virtual Memory Multitasking
● Handling I/O operations
● Manipulation of the file system
● Error Detection and handling
● Resource allocation
● Information and Resource Protection
Q4) What are the Functions of an Operating System?
A4) Functions of Operating System
Fig 2. Function of an Operating System
In an operating system software performs each of the function:
- Process management: Process management helps OS to create and delete processes. It also provides mechanisms for synchronization and communication among processes.
- Memory management: Memory management module performs the task of allocation and deallocation of memory space to programs in need of this resources.
- File management: It manages all the file-related activities such as organization storage, retrieval, naming, sharing, and protection of files.
- Device Management: Device management keeps tracks of all devices. This module also responsible for this task is known as the I/O controller. It also performs the task of allocation and deallocation of the devices.
- I/O System Management: One of the main objects of any OS is to hide the peculiarities of that hardware devices from the user.
- Secondary-Storage Management: Systems have several levels of storage which includes primary storage, secondary storage, and cache storage. Instructions and data must be stored in primary storage or cache so that a running program can reference it.
- Security: Security module protects the data and information of a computer system against malware threat and authorized access.
- Command interpretation: This module is interpreting commands given by the and acting system resources to process that commands.
- Networking: A distributed system is a group of processors which do not share memory, hardware devices, or a clock. The processors communicate with one another through the network.
- Job accounting: Keeping track of time & resource used by various job and users.
- Communication management: Coordination and assignment of compilers, interpreters, and another software resource of the various users of the computer systems..
Q5) What are the advantages and disadvantages of operating systems?
A5) The advantage of using Operating System
● Allows you to hide details of hardware by creating an abstraction
● Easy to use with a GUI
● Offers an environment in which a user may execute programs/applications
● The operating system must make sure that the computer system convenient to use
● Operating System acts as an intermediary among applications and the hardware components
● It provides the computer system resources with easy to use format
● Acts as an intermediator between all hardware's and software's of the system
Disadvantages of using Operating System
● If any issue occurs in OS, you may lose all the contents which have been stored in your system
● Operating system's software is quite expensive for small size organization which adds burden on them. Example Windows
● It is never entirely secure as a threat can occur at any time
Q6) Explain the Unix system?
A6) Unix System: The UNIX operating system is a set of programs that act as a link between the computer and the user. The computer programs that allocate the system resources and coordinate all the details of the computer's internal is called the operating system or kernel.
Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.
Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas Mcllroy, and Joe Ossanna.
There are various Unix variants available in the market. Solaris Unix, AIX, HP Unix and BSD are few examples, Linux is also a flavor of Unix which is freely available.
Several people can use a UNIX computer at the same time, hence UNIX is called a multiuser system. A user can also run multiple programs at the same time; hence UNIX is called multitasking.
A Brief History of UNIX
Q7) Explain Linux system?
A7) Linux
From smartphones to cars, supercomputers and home appliances, home desktops to enterprise servers, the Linux operating system is everywhere.
Linux has been around since the mid-1990s and has since reached a user-base that spans the globe. Linux is actually everywhere: It's in your phones, your thermostats, in your cars, refrigerators, Roku devices, and televisions. It also runs most of the Internet, all of the world’s top 500 supercomputers, and the world’s stock exchanges.
But besides being the platform of choice to run desktops, servers, and embedded systems across the globe, Linux is one of the most reliable, secure and worry-free operating systems available.
Here is all the information you need to get up to speed on the Linux platform.
What is Linux?
Just like Windows, iOS, and Mac OS, Linux is an operating system. In fact, one of the most popular platforms on the planet, Android, is powered by the Linux operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply, the operating system manages the communication between your software and your hardware. Without the operating system (OS), the software wouldn’t function.
The Linux operating system comprises several different pieces:
● Bootloader – The software that manages the boot process of your computer. For most users, this will simply be a splash screen that pops up and eventually goes away to boot into the operating system.
● Kernel – This is the one piece of the whole that is actually called Linux. The kernel is the core of the system and manages the CPU, memory, and peripheral devices. The kernel is the lowest level of the OS.
● Init system – This is a sub-system that bootstraps the user space and is charged with controlling daemons. One of the most widely used init systems is system which also happens to be one of the most controversial. It is the init system that manages the boot process, once the initial booting is handed over from the bootloader (i.e., GRUB or GRand Unified Bootloader).
● Daemons – These are background services (printing, sound, scheduling, etc.) that either start up during boot or after you log into the desktop.
● Graphical server – This is the sub-system that displays the graphics on your monitor. It is commonly referred to as the X server or just X.
● Desktop environment – This is the piece that the users actually interact with. There are many desktop environments to choose from (GNOME, Cinnamon, Mate, Pantheon, Enlightenment, KDE, Xfce, etc.). Each desktop environment includes built-in applications (such as file managers, configuration tools, web browsers, and games).
● Applications – Desktop environments do not offer the full array of apps. Just like Windows and macOS, Linux offers thousands upon thousands of high-quality software titles that can be easily found and installed. Most modern Linux distributions (more on this below) include App Store-like tools that centralize and simplify application installation. For example, Ubuntu Linux has the Ubuntu Software Center (a rebrand of GNOME Software? Figure 1) which allows you to quickly search among the thousands of apps and install them from one centralized location.
Q8) What are the features of Linux?
A8) Features of Linux
Some of the most significant features of the Linux Operating System are mentioned below.
● Portable - Software's portability refers to its ability to run on various types of hardware in the same way. The Linux kernel and application programs can be installed on virtually any hardware platform.
● Open Source - Linux is a community-based programming project with freely available source code. Multiple teams collaborate to improve the capabilities of the Linux operating system, which is constantly changing.
● Multi-User - Linux is a multiuser system, which means that multiple users can share system resources such as memory, ram, and application programs.
● Multiprogramming - Linux is a multiprogramming method, which means it can run several programs at the same time.
● Hierarchical File System - System files and user files are organized in a common file structure in Linux.
● Shell - Linux has a special interpreter program that can be used to run operating system commands. It can be used to perform a variety of tasks, such as calling application programs.
● Security - User security is provided by Linux by authentication features such as password protection, restricted access to sensitive files, and data encryption.
Q9) Explain cal command?
A9) cal command
The cal command in Linux is used to display the calendar for a particular month or for the entire year.
Syntax:
Cal [ [ month ] year]
Or
Cal [options] [month] [year]
Calendar other option
-1 - As a production, it shows a single month.
-3 - Prev/current/next month production is shown.
-s - The first day of the week is shown as Sunday.
-m - The first day of the week is shown as Monday.
-j - Julian dates are shown (days one-based, numbered from January 1).
-y - The current year's calendar is shown.
Example 1:
Cal -3 5 2008
The calendar for the months of April, May, and June in the year 2008 is shown.
Example 2:
Q10) Write syntax and example of date command?
A10) date command
The date command is used to show the current date and time on the machine. The date command is often used to set the system's date and time.
Syntax:
$date
Example:
Q11) Explain echo command?
A11) echo command
In Linux, the echo command is used to show a line of text/string that has been passed as an argument. This is a built-in command that outputs status text to the screen or a file. It's mainly used in shell scripts and batch files.
Syntax:
Echo "enter text"
Example:
In this example, we use the -p command line option to enter the input on the same PROMPT:
Read -p PROMPT <variable_name>
Echo option
-n: The trailing newline should not be production.
-E: STRINGs would not be able to read certain sequences.
Example:
Q12) Explain who commands?
A12) who command
Who w – Command: UNIX maintains an account for all the current system. Because it is a multi-user system it is prudent for the user to be aware of other current users so that s/he can communicate with them if required. The user login details of all the current users by using the who command. The use of who command provides a list of all the current users in the three-column format by default, as shown follows:
$ who
Raj console Nov 19 09:35
Reena tty01 Nov 19 09:40
Priya tty02 Nov 19 09:41
The first column shows the name of the users, the second column shows the device names and the third column shows the login time. Some options like -H, -u and -T can be used with this command.
The H option provides headers for the columns and the -u option provides more details like idle time, PID and comments as shown in the example below.
$ who-Hu
NAME LINE TIME IDLE PID COMMENTS
Raj console Nov 19 09:35 # 32
Reena tty01 Nov 19 09:40 0:20 33
Priya tty01 Nov 19 09:41 0:40 34
If any terminal is idle If any terminal is idle (not active) for the last 1 minute, the information, that is, for how long that terminal is idle will be indicated on the IDLE column. Thus, 0:20 indicates that reena's terminal is IDLE for the last 20 minutes. This information will be useful to the system administrator. The PID indicates the process identification number. The self-login details of a user can be obtained as a single line output using am and i arguments along with the who command as follows.
$ who am i
Reena tty01 Nov 1909:40
Generally, the who command is used by the system administrator for monitoring terminals.
The w command is a quick way to see who is logged on and what they are doing.
Q13) Define creating and removing directories?
A13) mkdir
The command mkdir means 'make directory.' You can construct a new directory anywhere in your system by using the mkdir command. Simply type "mkdir dir name>" (instead of dir name>, type the name of the new directory you want to create) and hit enter.
Syntax:
Mkdir <dirname>
Mkdir option
Option | Description |
Mkdir, -p, -parents | Add the directory, as well as its subdirectories. |
Mkdir, -v, -verbose | For each newly formed directory, print a message. |
Mkdir -m -mode=MODE | Set the permissions for entry. |
Rmdir
Removing Directories
The rmdir command can be used to remove directories as follows:
$rmdir dirname
$
If you want to delete a directory, make sure it's empty, which means there should be no files or subdirectories inside.
You can delete several folders at the same time by doing the following:
$rmdir dirname1 dirname2 dirname3
$
If the directories dirname1, dirname2, and dirname3 are empty, the command above removes them. If the rmdir command is effective, no output is generated.
Rmdir -p
This command deletes a directory and all of its subdirectories at the same time. The command 'rmdir -p' was used to remove all sub-directories.
Q14) What are changing directories?
A14) To modify the current working directory in Linux, use the cd command ( i.e., in which the current user is working). 'Change directory' is represented by the letter "cd." In the Linux terminal, it's one of the most commonly used commands.
Syntax:
Cd <dirname>
It's one of the most critical and widely used commands in the Linux system, and you'll see it a lot. We can navigate through our system's directories with the aid of this order. We may go back to the previous directory, forward to the next directory, or anywhere else.
The cd command can be used for more than just changing directories. By specifying a valid absolute or relative path, you can change to any directory. The syntax is as follows:
$cd dirname
$
The name of the directory you want to change to is provided by dirname. For instance, the command
$cd /usr/local/bin
$
Changes to the /usr/local/bin directory. You may use the following relative path to cd to the directory /usr/home/amrood from this directory:
$cd ../../home/amrood
$
Q15) Describe the types of file?
A15) A file type is used to describe the type of data that is saved in a file. Linux recognizes seven different file forms. Regular files, Directory files, Link files, Character special files, Block special files, Socket files, and Named pipe files are all examples of file types.
A list of these file types can be found in the table below.
/-----------------------------------------------\
|-|Regular File|
|d|Directory|
|l|Symbolic Link|
|b|Block Special File|
|c|Character Special File
|p|Named Pipe|
|s|Socket|
\-----------------------------------------------/
Regular file
Text, audio, video, images, scripts, and programs are only some of the content types that can be stored in regular or ordinary files. There are a plethora of content styles to choose from. Standard files, with or without an extension, can be built in Linux.
An extension is a collection of characters added to the end of a file name to give it a unique identity or to group it with other files of the same type of material. Files of various content types often use well-known file extensions for ease of identification and processing.
Despite the fact that the Linux file system does not need file extensions, you can still use them. They assist us in recognizing the different types of content contained in files. If a file's extension is.mp4, for example, you can assume it's a video file.
The /etc/mime.types file contains a full list of content types and file extensions that your Linux framework supports. The MIME (Multipurpose Internet Mail Extensions) standard assigns file content types a standard designation and classification.
To access the contents of this file, use any standard file reading command.
Directory
File systems use folders to arrange data in a hierarchy. Directories are similar to files, but instead of storing data, they keep track of where other files are located. Directory entries are used to store the location of files stored in the directory. A single file's name and location are stored in each directory entry.
The Linux file system begins with the directory /, also known as the root directory. This directory is where all files and directory files are made. Each directory, with the exception of the root directory, has a parent directory.
Symbolic link
We can use a file with a different filename and from a different location with link files. We use connecting files for this. A connection file is a file that contains a reference to another file. A hard connection and a symbolic or soft link are the two forms of connections.
A hard connection makes a copy of the original file that is identical to it. A hard connection to a directory or file on another filesystem is not possible. A reference to the original file is created by a soft or symbolic connection. A soft connection to a directory or file on another filesystem can be formed.
Block or Character special file
Block Special Files are used to communicate with hardware in blocks of data of 512 bytes, 1024 bytes, or 2048 bytes, depending on the hardware.
Hard drives, printers, displays, terminal emulators, and CD/DVD drives are all treated as special files in Linux. This ensures that a program can view and use files and devices in the same way that a user can. This feature makes it simpler and more versatile to build programs in Linux.
The /dev directory is where Linux stores all special files and system files. A character special file and a block special file are the two types of special files. A character special file represents a computer, such as a monitor or printer, that transfers data in bytes. A block special file represents a computer, such as a hard drive, that transfers data in blocks.
One character at a time is communicated with hardware using the Character Special File. Block and Character Special Files are usually found in the /dev directory.
Named pipe
A named pipe is a file that transfers data from one process to another.
The data that is passed between one process writing data into a named pipe and another process reading data from the named pipe is not stored in the named pipe. The mkfifo command can be used to build a named pipe.
We can use Linux to send the output of some process or command as the input to another process or command. The pipe is the name for this element. Only when both processes are initiated by the same user and are in the same parent process space do pipes function.
Standard pipes will not function if processes are run under different user names and permissions. Named pipes are used in these situations. Named pipes are similar to regular pipes, but they can be accessed via the filesystem.
The empty pipe files are known as named pipe files. Named pipe files are processed by the kernel without being written to the file system. Pipe files with names can be found anywhere in the file system. The FIFO (First In First Out) files are also known as pipe files.
Socket
The Socket File is a stylized inter-process communication mechanism.
It is highly uncommon for a user or even a system administrator to build a socket directly.
A socket is a data-exchange communication endpoint used by applications. When an application needs to communicate with another application, it connects to the application's socket.
A socket is used for any application that offers services to other applications or remote clients. Each socket has an IP address and port number associated with it, allowing it to accept connections from clients.
For example, if a local system application needs to communicate with a remote system application, it connects to that application's socket using the IP address and port number associated with that socket.
Sockets are very difficult to understand. Socket files are used by Linux to make communication between local applications easier. Socket files allow local device applications to share data without having to go through the complicated networking and sockets processes.
Socket files are files that use a file name instead of an IP address and port number as their address. To allow inter-process communication between local applications, socket files use the sendmsg() and recvmsg() system calls.
Q16) What are the needs of the operating system?
A16) Need of Operating System
● OS as a platform for Application programs: The operating system serves as a foundation for other programmes known as application programmes to execute on. These application programmes make it easier for consumers to complete a given task. It serves as a link between the user and the computer. It is created in such a way that it can operate, control, and execute various computer applications.
● Managing Input-Output unit: The computer's operating system also allows it to manage its own resources, such as memory, display, keyboard, printer, and so on. Effective usage of these resources necessitates resource management. The operating system manages the system's input-output resources and distributes them to users or programmes based on their needs.
○ Consistent user interface: The operating system offers the user with an easy-to-use user interface, allowing the user to focus on the content and be productive as quickly as possible without having to learn a new UI each time. The operating system provides templates and UI components to make using a computer as simple as possible for the user.
● Multitasking: Memory is managed by the operating system, which allows several programmes to execute in their own space and even connect with one another via shared memory. Users benefit from multitasking since they can complete multiple tasks on a computer at the same time.
● Booting: The process of starting the computer is known as booting. When the CPU is turned on for the first time, there is nothing in the memory. So, in order to turn on the computer, we must first load the operating system into main memory. As a result, booting is the process of loading the operating system into main memory in order to start the computer. As a result, the operating system aids in the initialization of the computer when the power is turned on.
● Platform for other application software: Different application programmes are required by users to complete particular jobs on the system. The operating system (OS) supervises and regulates these programmes to ensure that they run smoothly. To put it another way, it serves as a link between the user and the programmes.
● Manages the memory: It aids in the management of the computer's main memory. It also allocates and deallocates memory for all programmes and tasks.
● Manages the system files: It aids in the organization of files on the computer. All of the data on the system is stored in files, as we all know. It makes working with the files simple.
● Provides Security: It uses authorisation to keep the system and applications safe. As a result, the operating system protects the system.
Q17) Write the difference between firmware and operating system?
A17) Difference between Firmware and Operating System
Firmware | Operating System |
Firmware is one kind of programming that is embedded on a chip in the device which controls that specific device. | OS provides functionality over and above that which is provided by the firmware. |
Firmware is programs that been encoded by the manufacture of the IC or something and cannot be changed. | OS is a program that can be installed by the user and can be changed. |
It is stored on non-volatile memory. | OS is stored on the hard drive. |
Q18) Write the difference between linux and window system?
A18) The following are the key distinctions between Linux and Windows
Sr. No. | Key | Linux | Windows |
1 | Open Source | Linux is an open source operating system that is completely free to use. | Windows isn't free to use and isn't open source. |
2 | Case sensitivity | The case of files in the Linux file system is important. | The Windows file system does not care about case. |
3 | Kernel type | Linux uses monolithic kernel. | Windows uses micro kernel. |
4 | Efficiency | When compared to Windows, Linux is more efficient in terms of operations. | In terms of operations, Windows is less efficient. |
5 | Path Separator | The forward slash is used in Linux as a path separator between directories. | The backward slash is used as a path separator in Windows. |
6 | Security | In comparison to Windows, Linux is quite secure. | When compared to Linux, Windows offers inferior security. |
Q19) Explain cat and cp command?
A19) cat command
The command 'cat' is the most often used and powerful. It's regarded as one of the most commonly used commands. It can display a file's content, copy content from one file to another, concatenate the contents of multiple files, display the line number, display $ at the end of a line, and so on.
Syntax:
Cat [OPTION]... [FILE]..
To make a file, follow these steps:
Cat > <file name>
// Enter file content
To save the file, press the "CTRL+ D" keys. To see the contents of the file, run it like this:
Cat <file name>
Linux cat command usage
Option | Function |
Cat > [fileName] | To create a file. |
Cat [oldfile] > [newfile] | Copy material from an older file to a new one. |
Cat [file1 file2 and so on] > [new file name] | To combine the contents of several files into a single file. |
Cat -n/cat -b [fileName] | To display line numbers. |
Cat -e [fileName] | The $ character will be displayed at the end of each line. |
Cat [fileName] <<EOF | Used to indicate the end of a page. |
Cp command
'cp' stands for copy. To copy a file or a directory, use the 'cp' command.
Syntax:
To copy in the same directory:
Cp <existing file name> <new file name>
Cp Options
Option | Function |
Cp -r | To duplicate a directory and all of its subdirectories.. |
Cp file1 file 2 directory name | Multiple files or directories in a directory are copied. |
Cp -backup | Before overwriting an existing file, make a backup. |
Cp -i | Asks for confirmation. |
Cp -l | To create a file with a hard link. |
Cp -p | Preserves a file's attribute. |
Cp -u -v | To ensure that the source file is older than the destination file. |
Q20) Write short notes on rm commands?
A20) rm command
'rm' stands for 'remove.' To remove a file, use this command. Unlike other GUIs, the command line does not feature a recycling bin or trash to recover files. As a result, exercise extreme caution when using this command. When you delete a file, it is permanently deleted.
Syntax:
Rm <file name>
Rm Options
Option | Description |
Rm *extension | Deletes files with the same extension. |
Rm -r or R | To recursively erase a directory. |
Rm -i | Interactively delete a file. |
Rm -rf | Forcefully delete a directory. |