Orientation to Computing-I
L T P :2 0 0
1
www.lpu.in Lovely Professional University
UNIT - 3
Linux OS and its features
• Linux is one of the popular versions of the UNIX operating System.
• It is open source as its source code is freely available.
• It is free to use.
• Linux was designed considering UNIX compatibility.
• Its functionality list is quite similar to that of UNIX.
2
www.lpu.in Lovely Professional University
Linux OS and its features
Components of Linux System
Linux Operating System has primarily three components
• Kernel − Kernel is the core part of Linux. It is responsible for all major
activities of this operating system. It consists of various modules and it
interacts directly with the underlying hardware. Kernel provides the
required abstraction to hide low level hardware details to system or
application programs.
• System Library − System libraries are special functions or programs
using which application programs or system utilities accesses Kernel's
features. These libraries implement most of the functionalities of the
operating system and do not requires kernel module's code access rights.
• System Utility − System Utility programs are responsible to do
specialized, individual level tasks.
3
www.lpu.in Lovely Professional University
• Kernel Mode vs User Mode
• Kernel component code executes in a special privileged mode called kernel
mode with full access to all resources of the computer. This code
represents a single process, executes in single address space and do not
require any context switch and hence is very efficient and fast. Kernel runs
each processes and provides system services to processes, provides
protected access to hardware to processes.
• Support code which is not required to run in kernel mode is in System
Library. User programs and other system programs works in User Mode
which has no access to system hardware and kernel code. User programs/
utilities use System libraries to access Kernel functions to get system's low
level tasks.
4
www.lpu.in Lovely Professional University
5
www.lpu.in Lovely Professional University
• Basic Features
• Portable − Portability means software can works on different types of
hardware in same way. Linux kernel and application programs supports
their installation on any kind of hardware platform.
• Open Source − Linux source code is freely available and it is community
based development project. Multiple teams work in collaboration to
enhance the capability of Linux operating system and it is continuously
evolving.
• Multi-User − Linux is a multiuser system means multiple users can access
system resources like memory/ ram/ application programs at same time.
• Multiprogramming − Linux is a multiprogramming system means
multiple applications can run at same time.
• Hierarchical File System − Linux provides a standard file structure in
which system files/ user files are arranged.
• Shell − Linux provides a special interpreter program which can be used to
execute commands of the operating system. It can be used to do various
types of operations, call application programs. etc.
• Security − Linux provides user security using authentication features like
password protection/ controlled access to specific files/ encryption of data.
6
www.lpu.in Lovely Professional University
Distribution versions
7
www.lpu.in Lovely Professional University
Installation
1. Insert a bootable Linux USB drive
2. Click the start menu
3. Then hold down the SHIFT key while clicking Restart
4. Then select Use a Device
5. Find your device in the list
6. Your computer will now boot Linux
7. Select Install Linux
8. Go through the installation process
8
www.lpu.in Lovely Professional University
Linux Directory Structure and File System Hierarchy
Dir Description
The directory called "root." It is the
/ starting point for the file system
hierarchy. Note that this is not related
to the root, or superuser, account.
/bin Binaries and other executable
programs.
/etc System configuration files.
/home Home directories.
/opt Optional or third party software.
/tmp Temporary space, typically cleared on
reboot.
/usr User related programs.
/var Variable data, most notably log files.
9
www.lpu.in Lovely Professional University
10
www.lpu.in Lovely Professional University
How to partition a disk in Linux
• Creating and deleting partitions in Linux is a regular practice
because storage devices (such as hard drives and USB drives) must
be structured in some way before they can be used.
• In most cases, large storage devices are divided into separate
sections called partitions. Partitioning also allows you to divide your
hard drive into isolated sections, where each section behaves as its
own hard drive.
11
How to partition a disk in Linux
The following explains the process of partitioning a storage device
with the parted command.
• List the partitions: Use parted -l to identify the storage device you
want to partition.
• Typically, the first hard disk (/dev/sda or /dev/vda) will contain the
operating system, so look for another disk to find the one you want
(e.g., /dev/sdb, /dev/sdc, /dev/vdb, /dev/vdc, etc.).
12
www.lpu.in Lovely Professional University
• 2. Open the storage device: Use parted to begin working with
the selected storage device. It is important to indicate the
specific device you want to use. If you just type parted with no
device name, it will randomly select a storage device to
modify.
• 3. Set the partition table: Set the partition table type to GPT,
then type "Yes" to accept it. The mklabel and mktable
commands are used for the same purpose (making a partition
table on a storage device). The supported partition tables are:
aix, amiga, bsd, dvh, gpt, mac, ms-dos, pc98, sun, and loop.
Remember mklabel will not make a partition, rather it will
make a partition table.
13
www.lpu.in Lovely Professional University
• 4. Review the partition table: Show information about the
storage device.
• 5. Get help: To find out how to make a new partition, type:
(parted) help mkpart.
• 6. Make a partition: To make a new partition (in this
example, 1,396MB on partition 0), type the following:
(parted) mkpart primary 0 1396MB
14
www.lpu.in Lovely Professional University
Comparison of Windows and Linux OS
S.NO Linux Windows
1. Linux is a open source operating system. While windows are the not the open source operating system.
2. Linux is free of cost. While it is costly.
3. It’s file name case-sensitive. While it’s file name is case-insensitive.
4. In Linux, monolithic kernel is used. While in this, micro kernel is used.
5. Linux is more efficient in comparison of windows. While windows are less efficient.
While there is back slash is used for Separating the
6. There is forward slash is used for Separating the directories.
directories.
7. Linux provides more security than windows. While it provides less security than Linux.
8. Linux is widely used in hacking purpose based systems. While windows does not provide much efficiency in hacking.
There are 3 types of user account – There are 4 types of user account –
9.
(1) Regular , (2) Root , (3) Service account (1) Administrator , (2) Standard , (3) Child , (4) Guest
Administrator user has all administrative privileges of
10. Root user is the super user and has all administrative privileges.
computers.
Linux file naming convention in case sensitive. Thus, sample and In Windows, you cannot have 2 files with the same name in
11.
SAMPLE are 2 different files in Linux/Unix operating system. the same folder.
15
www.lpu.in Lovely Professional University
Virtual Machines
• A Virtual Machine (VM) is a compute resource that uses software instead
of a physical computer to run programs and deploy apps. One or more
virtual “guest” machines run on a physical “host” machine. Each virtual
machine runs its own operating system and functions separately from the
other VMs, even when they are all running on the same host. This means
that, for example, a virtual MacOS virtual machine can run on a physical
PC.
• Virtual machine technology is used for many use cases across on-premises
and cloud environments. More recently, public cloud services are using
virtual machines to provide virtual application resources to multiple users
at once, for even more cost efficient and flexible compute.
16
www.lpu.in Lovely Professional University
• What are virtual machines used for?
• Virtual machines (VMs) allow a business to run an operating system that
behaves like a completely separate computer in an app window on a
desktop.
• VMs may be deployed to accommodate different levels of processing
power needs, to run software that requires a different operating system, or
to test applications in a safe, sandboxed environment.
• Virtual machines have historically been used for server virtualization,
which enables IT teams to consolidate their computing resources and
improve efficiency.
17
www.lpu.in Lovely Professional University
• What are virtual machines used for?
Additionally, virtual machines can perform specific tasks considered too risky
to carry out in a host environment, such as accessing virus-infected data or
testing operating systems. Since the virtual machine is separated from the rest
of the system, the software inside the virtual machine cannot tamper with the
host computer.
• How do virtual machines work?
• The virtual machine runs as a process in an application window, similar to
any other application, on the operating system of the physical machine.
Key files that make up a virtual machine include a log file, NVRAM
setting file, virtual disk file and configuration file.
18
www.lpu.in Lovely Professional University
Other Shell Commands:
• ls • rmdir
• cat • mkdir
• man • rm
• cd • chmod
• touch • pwd
• cp • ps
• mv • kill
19
ls command
• The ls command is used to list files or directories in Linux and other Unix-
based operating systems.
• Use of ls command as below:
20
www.lpu.in Lovely Professional University
cat command
• Outputs the contents of a text file.
• You can use it to read brief files or to concatenate files together.
• To append file1 onto the end of file2, enter:
• cat file1 >> file2
• To view the contents of a file named myfile, enter:
• cat myfile
21
www.lpu.in Lovely Professional University
man command
• The man command is a built-in manual for using Linux commands.
• Displays the user manual of any command that we can run on the terminal.
It provides a detailed view of the command which includes NAME,
SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN
VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS.
• Basic Symbol
• option – the search result output.
• section number – the section in which to look for the man page.
• command name – the name of the command which man page you want to
see.
22
www.lpu.in Lovely Professional University
cd command
• It changes your current directory location.
• By default, your Unix login session begins in your home directory.
• To switch to a subdirectory (of the current directory) named myfiles, enter:
• cd myfiles
• To switch to a directory named /home/dvader/empire_docs, enter:
• cd /home/dvader/empire_docs
23
www.lpu.in Lovely Professional University
Touch
The touch command's
primary function is to
modify a timestamp.
24
cp
• This command copies a file, preserving the original and creating an
identical copy.
– cp -i oldfile newfile
mv
mv stands for move.
mv is used to move one or more files or directories from one place to
another in a file system like UNIX.
Use it as:
mv [Option] source destination
chmod
• This command changes the permission information associated with a
file.
25
www.lpu.in Lovely Professional University
Mkdir
• The mkdir command is used to create (or make) a directory.
• Example:
• # mkdir LPUCSE
rmdir
• The rmdir directory is used to remove directories, but only those that are
empty (i.e., contain no files or subdirectories). In order to delete a directory
with actual contents, you must use the rm -R command.
• Example
• To remove an empty directory:
• # rmdir /mike
26
www.lpu.in Lovely Professional University
Rm
Use the rm command to remove files you no longer need.
Example
Removing one file at a time
$ rm CSEA.txt
Pwd
Simply type pwd into your terminal, and the command will output the
absolute path of your print working directory.
The pwd command writes to standard output the full path name of your
current directory (from the root directory). All directories are separated by
a / (slash). The root directory is represented by the first /, and the last
directory named is your current directory.
The ps command, short for Process Status, is a command line utility that is
used to display or view information related to the processes running in a
Linux system.
27
www.lpu.in Lovely Professional University
ps
The ps command, short for Process Status, is a command line utility that is
used to display or view information related to the processes running in a
Linux system.
kill
kill command in Linux (located in /bin/kill), is a built-in command which is
used to terminate processes manually.
28
www.lpu.in Lovely Professional University
• Activity
• Execute various commands on Linux Operating System
29
www.lpu.in Lovely Professional University
Kernel and types of kernels
• A Kernel is an intermediary between applications and hardware.
• Functions of a Kernel
A Kernel in an operating system performs the following functions:
• Device Management: Processes require various peripheral devices such as
a mouse and keyboard connected to the computer to perform various tasks.
The Kernel manages the allocation of the peripheral devices.
• Resource Management: Kernel shares the resources between different
processes while ensuring that every process has uniform access to the
resources.
• Memory Management: Every process requires some memory to execute.
The Kernel allows the processes to access the memory safely.
• Access Computer Resource: A kernel can access different computer
resources such as RAM, CPU, I/O devices, and other resources. The
Kernel decides which memory each process will use, and the action is
taken if memory is unavailable.
30
www.lpu.in Lovely Professional University
More about Linux Kernel
31
www.lpu.in Lovely Professional University
More about Linux Kernel
32
www.lpu.in Lovely Professional University
Basic types of kernels
• 3 basic types of kernels as below:
• Monolithic
• Microkernel
• Hybrid
• A monolithic kernel is a type of kernel in which the complete OS runs in
the kernel space.
• A microkernel is a kernel type that implements an operating system by
providing methods, including low-level address space management, and
thread management.
• A hybrid kernel is an operating system kernel architecture that attempts to
combine aspects and benefits of microkernel and monolithic kernel
architectures used in computer operating systems.
33
www.lpu.in Lovely Professional University
Basic types of kernels
34
www.lpu.in Lovely Professional University