Linux Unit 1
Linux Unit 1
FYCS SEMESTER-II
2 Operating System
Intelligence Output
Softwar
e Platform
OS
Hardware
Processing Power
3 Operating System
Instructions are
passed to User
kernel for
execution. User
space
Output is
returned back to
Kernel the user
space
12
Red Hat Linux RHL-3, ...,
RHL-9 (2.4)
Linux
RHEL - 3 (2.6)
RHEL - 4 (2.6)
RHEL - 5 (2.6)
RHEL - 6 (2.6)
RHEL - 7
(3.10)
RHEL – 8
(4.18)
RHEL – 9
(5.14)
13 Red Hat Linux Kernel
Kernel Version is always an even number like 2.2, 2.4, 2.6, 3.10 etc.
Major no. 2 . 0. Minor no
How do we access storage devices in Linux?
14 Storage devices are physical devices for e.g. hard
Mount drives
Storage OS
Point They cannot be accessed physically. We can
access them logically.
OS provides mount point to access storage
devices.
F:\ C:\
300GB 200GB
In Windows OS, drive letters like C:\ , D:\ are
1 mount points.
TB Mount points provide access to storage.
200GB 300GB
D:\
E:\
How do we access storage devices on
15 Linux?
Linux does not use drive letters.
In Linux storage can be accessed through
folders(directories).
Applications Song
200GB 200GB s In the diagram, songs and movies are the
mount points to access 200gb and 300gb
1 storage space respectively.
TB
300GB 300GB
In Linux, when we connect pen drive, we
will create a folder called usb. This folder
Movies Work will act as a mount point to pen drive. Now
we can access pen drive through folder
usb.
Windows file system starts from C, whereas Linux file system starts from
/.
Entire windows os is installed on a single partition.
Every directory in a linux can become mount point of a partition.
We can spread os onto multiple partitions by making every system
directory a mount point to different partition.
18 Our scenario
swap 4 GB
/boot
30 GB Hard Drive 500
MB
2 GB RAM 30
500 MB - /boot 4 GB GB
20 GB
20 GB - /
/home
4 GB - /home /
4 GB – swap
Space borrowed by RAM from Hard Drive to balance the overload of the
processes
Swap is a partition dedicated to work as virtual memory for RAM.
Size of swap should be double than that of RAM.
Basics of Linux:
20 Core OS:
GUI – input using pointer (desktop)
CLI – input using cursor (command line)
Terminal : Login screen
GUI and CLI
Provides multiple terminals: Total 6 terminals
If graphics is ON – 1 GUI & 5 CLI GUI – F1
Ctrl + Alt + F1 – GUI CLIs – F2-F6
Ctrl + Alt + F2-F6 – CLI
Multi User OS: multiple users can login simultaneously or single user can have multiple login instances
Command: it is the name of a program that we want to run
Shell: To communicate commands to the operating system kernel, an interface is needed that sits between
the kernel and the end user issuing these commands. This interface is known as the shell. Several shells are
available on RHEL.
tcsh A shell with a scripting language that works like the C programming language. It is very popular with C
programmers.
zsh A shell that is compatible with Bash but offers even more features.
sash This stands for stand-alone shell. This is a minimal-feature shell that runs in almost all environments.
Therefore, it is very well suited for system troubleshooting.
SH shell
KSH korn shell
Bash (short for the Bourne Again Shell) is the default shell in Red Hat linux. Most advanced & user friendly.
Features of bash shell: auto complete of commands & syntax arguments, history of commands is stored for
every user, compact syntax
21 Linux Architecture
The Linux system works basically on 4 layers. The diagram below shows
the architecture of a Linux System.
Hardware − Hardware consists of all physical devices attached to the
System. For example: Hard disk drive, RAM, Motherboard, CPU etc.
Kernel − Kernel is the core component for any (Linux) operating system
which directly interacts with the hardware.
Shell − Shell is the command interpreter. Shell is the interface which
takes input from Users and sends instructions to the Kernel, Also takes
the output from Kernel and send the result back to output shell.
Applications − These are the utility programs which runs on Shell. This
can be any application like Your web browser, media player, text editor
etc.
Linux Architecture
22
Linux File System / Linux Directory
23 Structure
/
usr boot dev etc home lib media mnt opt proc root tmp var
bin
sbin
/lib: Where the libraries of the installed packages located since libraries
shared among all packages. Kernel modules.
/media: Empty. Here is the external devices like DVDs and USB can be
mounted and you can access their files from here.
/mnt: Empty. Where you mount external devices USB or DVD.
/opt: Some optional packages are located here and this is managed by
the package manager.
26 Absolute path
1. cd desktop …….wrong
cd Desktop …….. right
2. cd conf ……. Wrong
cd /etc/httpd/conf ……. Right
3. cd /usr/bin
4. cd /usr …..right
cd .. ……. Best
5. cd /local/sbin ……….. Wrong
cd local/sbin …………right
6. cd ~
Absolute path will not always starts with /. If path starts with / then that / is / directory.
29 Boot Process 29
CMOS
& BIOS
CHIP
ROM MBR
MP
446 BYTES 64 BYTES 2 BYTES
BOOT SECTOR PARTITION MAGIC
BOOT LOADER TABLE NUMBER
(GRUB)
512 BYTES
30 Boot Process
SMPS – ELECTRICAL SIGNAL - MOTHERBOARD – PROCESSOR - BIOS
BIOS (BASIC INPUT OUTPUT SYSTEM) PROGRAM RUNS ITSELF – INT 19H – POST (POWER ON
SELF TEST)
POST DETECTS CONNECTED HARDWARE – CREATES THEIR LIST
BIOS WILL SEARCH FOR BOOTABLE DEVICE – THERE CAN BE MULTIPLE BOOTABLE DEVICES –
BOOT SEQUENCE
CMOS
CMOS 1ST BOOTABLE DEVICE IS HARD DRIVE
BIOS - INT 13H – GO TO THE HARD DRIVE – TO GET OS
FOR BIOS – HARD DRIVE CYLINDERS, HEADS & SECTORS (CHS)
13H -> 1ST SECTOR – MBR (MASTER BOOT RECORD) – BRINGS FIRST FILE FOUND ON RAM
FIRST FILE BOOT LOADER – EXECUTES ITSELF CHS OF KERNEL
13H WILL GO THE GIVEN CHS – BRING KERNEL ON RAM
KERNEL WILL EXECUTE ITSELF – WILL TAKE OVER THE BOOT PROCESS
BIOS’s TASK IS DONE – KERNEL WILL START BOOTING THE OS
31 Runlevels
A runlevel is a bundle of service.
Runlevel instructs the OS what services to run and what not to run.
RHEL 7 can be booted into one of a number of runlevels. There are total 7
runlevels through 0 to 6 except 4 in RHEL 7.
Runlevel 0 - The halt runlevel. This is the runlevel at which the system shuts
down.
Runlevel 1 – Causes the system to start up in a single user mode under which
only the root user can log in. In this mode the system does not start any
networking, graphics or multi-user services. This run level is ideal for system
administrators to perform system maintenance or repair activities.
Runlevel 2 - Boots the system into a multi-user mode with command line. This
runlevel does not, however, start the network. No GUI.
Runlevel 3 - Similar to runlevel 2 except that networking services are started.
This is the most common runlevel for server based systems that do not require
any kind of graphical desktop environment.
32 Runlevels
Runlevel 4 - Undefined runlevel.
Runlevel 5 - Boots the system into a networked, multi-user state with X Window
System capability. By default the graphical desktop environment will start at the
end of the boot process. This is the most common run level for desktop or
workstation use.
Runlevel 6 - Reboots the system.
To check current run level:
# runlevel it will show two entries. 1st is previous runlevel and 2nd is current
runlevel.
options – Shutdown options such as halt, power-off (the default option) or reboot the system.
time – The time argument specifies when to perform the shutdown process.
message – The message argument specifies a message which will be broadcast to all users.
Options
-h/H: halt
-k: Only send out the warning messages and disable logins, do not actually bring the system down.
-P: Poweroff
Shutdown Process
34
How to use shutdown
In it’s simplest form when used without any argument, shutdown will power off the
machine.
#shutdown