You are on page 1of 100

Managing Software

using RPM
RPM - Red Hat Package Manager
RPM
• RPM (Red Hat Package Manager) is an default open
source and most popular package management
utility for Red Hat based systems like (RHEL, CentOS
and Fedora).
• The tool allows system administrators and users to
install, update, uninstall, query, verify and manage
system software packages in Unix/Linux operating
systems.
RPM Package
• RPM packages have file names like

xyz-1.0-1.i386.rpm
where package name (xyz),

version (1.0),

release (1) and

architecture (i386)
Some Facts about RPM
• RPM is free and released under GPL (General
Public License).

• RPM keeps the information of all the installed


packages under /var/lib/rpm database.
Basic modes for RPM command
1. Install : It is used to install any RPM package.
2. Remove : It is used to erase, remove or un-
install any RPM package.
3. Upgrade : It is used to update the existing RPM
package.
4. Query: It is used to query about different RPM
packages.
5. Verify: It is used for the verification of any RPM
package.
Where to find RPM packages ?
• http://rpmfind.net
• http://www.redhat.com
• http://freshrpms.net/
• http://rpm.pbone.net/
Installing a new package
▪ The easiest way to install a new package is to use
the –i option with rpm.
▪ For example, if you downloaded a package called
bc-1.06-10.i386.rpm and wanted to install it,
you would type:
[root@tedford /root]# rpm -i bc-1.06-10.i386.rpm
▪ if the package already existed, you would see
this message:
▪ error: package bc-1.06-10 is already installed
Upgrading a package

▪ If you need to upgrade a package that already exists,


use the –U option, like so:
▪ [root@tedford /root]# rpm -U bc-1.06-10.i386.rpm
Querying a Package
▪ Sometimes it is handy to know which packages are currently
installed and what they do. You can do that with the RPM
query options.
▪ To list all installed packages, simply type
▪ [root@tedford /root]# rpm –qa

▪ Be ready for a long list of packages! If you are looking for a


particular package name, you can use the grep command to
specify the name (or part of the name) of the package, like so:
▪ [root@tedford /root]# rpm -qa | grep -i 'bc'
▪ The –i parameter in grep tells it to make its search case-
insensitive.
Querying a Package
• If you just want to view all of the packages one screen at a
time, you can use the more command, like so:
• [root@tedford /root]# rpm -qa | more
Querying a Package
• To find out the purpose of a package that is already installed,
you must first know the name of the package (taken from the
listing in rpm –qa) and then specify it, like so:

• [root@tedford /root]# rpm -qi bc


where you can substitute any package name in place of bc.

• To find out what files are contained in a package, type

• [root@tedford /root]# rpm -ql bc


where you can replace bc with any package name you want
information about.
Verifying a Package
▪ Assume you have installed some RPM packages,
perhaps long ago, and want to check whether
any files have changed since the installation.
▪ Solution:- rpm -Va [package]
Verifying a Package
• On verification every file installed by RPM is examined. No less
than nine different attributes of each file can be checked. Here
is the list of attributes:
1. Owner
2. Group
3. Mode
4. MD5 Checksum
5. Size
6. Major Number
7. Minor Number
8. Symbolic Link String
9. Modification Time
Uninstalling a Package
• Uninstalling packages with RPM is just as easy as installing
them. In most cases, all you need to type is

• [root@tedford /root]# rpm –e packagename

• where packagename is the name of the package to be


uninstalled.
 Since Linux is a multi-user operating system,
several people may be logged in and actively
working on a given machine at the same time.
 User Administration is the process of managing
different user accounts and their respective
permissions in an operating system.
 In Linux or Unix-based operating systems, we can
create different user accounts, sort them into
groups, change their set of permissions or delete
them.
 Relevant files for user/group management:
➢ /etc/passwd (user information),
➢ /etc/shadow (encrypted passwords),
➢ /etc/group (group information)
➢ /etc/gshadow (encrypted group passwords)
➢ /etc/sudoers (configuration for sudo).
 Adding a new user, deleting an account, updating
accounts, and creating and removing groups.
 These operations are performed using the following
commands:
 useradd: add a user to the system.
 userdel: delete a user account and related files.
 groupadd: add a group to the system.
 groupdel: remove a group from the system.
 usermod: modify a user account.
 groupmod : modify group settings
useradd

1. Add two user accounts John and David in your


system :
$ useradd John
$ useradd David

2. Assign each user with a password.


$ passwd John
$ passwd David

3. Create a user Tom with specific user id.


$useradd –u 1200 Tom
 The userdel command does the exact opposite of
useradd. ie. it removes existing users.
 Delete Johns account :
$ userdel John
 for userdel John, all of the entries in the
/etc/passwd and /etc/shadow files, and references
in the /etc/group file, are automatically removed.
The usermod command allows you to modify an existing
user in the system.
1.Change Tom’s userid as 1024.
$ usermod –u 1024 Tom
2. Change the main group of Ben as QA
$ usermod –g QA Ben
3. Add Ben to sales group
$ usermod –aG sales Ben
4. Lock/Unlock Tom’s account
$ usermod –L/U Tom
$ usermod –lock/-unlock Tom
 The group commands are similar to the user
commands; however, instead of working on
individual users, they work on groups listed in the
/etc/group file.
 The groupadd command adds groups to the
/etc/group file.
 Create a group sales with gid=1500
 groupadd –g 1500 sales
 groupdel command removes existing groups
specified in the /etc/group file. The only usage
information needed for this command is:
 groupdel group
 where group is the name of the group to be
removed. For example, if you wanted to remove
the research group, you would issue this
command:
 $ groupdel research
 The groupmod command allows you to modify the
parameters of an existing group. The options for this
command are:
groupmod –g gid –n group-name group
 where the –g option allows you to change the GID of the
group, and the –n option allows you to specify a new
name of a group and finally name of the existing group
as the last parameter.
 For example, if the cloud_research group wanted to
change its name to security_cloud, you would issue the
command:
$ groupmod -n security_cloud cloud_research
 gpasswd –d Ben sales
 The above command removes Ben from
sales group
 To assign super user privileges add the line at the

end of the sudoers file:

newuser ALL=(ALL) ALL

newuser can run any command (ALL) as any

user(ALL) on any host (ALL)


Linux Kernel Management
Linux Kernel Management

▪ Kernel is the main component of a computer


operating system .

▪ This provides an interface between the application


and the data processed at the hardware.
KERNEL
❖ The main purpose of a computer is to run a predefined sequence of
instructions, known as a program.

❖ A program under execution is often referred to as a process.

❖ In a general purpose computer for running many processes simultaneously,


we need a middle layer to manage the distribution of the hardware
resources of the computer efficiently and fairly among all the various
processes running on the computer. This middle layer is referred to as
the kernel.
Types of Kernel

Types of Kernel

Monolithic Micro Hybrid


Kernel kernel Kernel

To Log Out:
Monolithic Kernel
❑ The user services and the kernel services are implemented in
the same memory space

❑ i.e. different memory for user services and kernel services are
not used in this case. In monolithic approach the size of the
Kernel is increased and this, in turn, increases the size of the
Operating System.

❑ As there is no separate User Space and Kernel Space, so the


execution of the process will be faster in Monolithic Kernels.
Micro Kernel
❑ The user services and kernel services are implemented into
different spaces.

❑ i.e. we use separate User Space and Kernel Space in case of the
Microkernels. This separation of user space and kernel space, in
turn reduces the size of the Kernel and thus reduces the size
of Operating System.

❑ As we are using different spaces for user services and kernel


service, so the communication between application and services
is done with the help of message passing and this, in turn,
reduces the speed of execution.
Hybrid Kernel
❑ A Hybrid Kernel is a combination of both Monolithic Kernel and
Microkernel.

❑ It makes the use of the speed of Monolithic Kernel and the


modularity of Microkernel.

❑ Hybrid kernels are micro kernels that have some "non-essential"


code such as network stack or file system in kernel-space in
order for the code to run more quickly than it would be in user-
space.
Linux Kernel Management – Basic Functions
Resource Allocation

Kernel manages and permits resources of a computer

Process Management

Kernel permits the execution of the applications and enables them


with hardware abstraction.

Memory Management

Kernel permits secured access to the memory when required.


Linux Kernel Management – Basic Functions

I/O Device Management

A kernel maintains the available devices.

Inter Process Communication


Kernel supports with the methods for synchronization and communication
between the various processes

Scheduling
The kernel uses Scheduling Algorithms to determine which process is running next
and how much time it will be given
Linux Kernel Management – Basic Functions

System calls and interrupt handling


The mechanism used by the application program to request a service from the
operating system.

Security or protection management

Protection from the error and malicious behaviour is done by the kernel
Installing a kernel in Linux
There are two methods to install a kernel :

1. Installation from the source


2. generic method
Installation of kernel from the source
• The procedure to build (compile) and install the latest Linux kernel from source is
as follows:

➢Grab the latest kernel from kernel.org

➢Verify kernel

➢Untar the kernel tarball

➢Copy existing Linux kernel config file

➢Compile and build Linux kernel (latest version)

➢Install Linux kernel and modules (drivers)

➢Update Grub configuration

➢Reboot the system


Generic Method
• To find out your current version of Linux kernel, run:
root@rhel8 ~]# uname -r
4.18.0-147.el8.x86_64
• To check if latest kernel update is available:
root@rhel8 ~]# yum check-update kernel
1. Manually install the .rpm kernel package
To manually install a kernel using rpm, the best practice is to use the – i option and
not the – U option. The reason is that the –U option will update the kernel and not
keep the old kernel.
2. Using the “yum install” or “yum update” command
The kernel can also be updated using the “yum update” command and the old kernel
will not be overwritten.
LINUX BOOT LOADERS
• A boot loader is a small program that places the OS of a computer into
memory.

• When a computer is powered-up or restarted, the basic input/output system


(BIOS) performs some initial tests, and then transfers control to the Master
Boot Record (MBR) where the boot loader resides.

• For Linux, the two most common boot loaders are known as LILO (LInux
LOader) and LOADLIN (LOAD LINux). An alternative boot loader, called GRUB
(GRand Unified Bootloader), is used with Red Hat Linux.

• LILO is the most popular boot loader among computer users that employ
Linux as the main, or only, operating system.
Linux Booting process
1. BIOS : BIOS stands for Basic Input/Output System
• BIOS, in full Basic Input/Output System, computer program that is typically stored in EPROM and
used by the CPU to perform start-up procedures when the computer is turned on.

• BIOS performs a power-on self-test (POST), it is a set of routines performed by firmware or


software immediately after a computer is powered on, to determine if the hardware is working as
expected. The process would proceed further only if the required hardware is working correctly,
else the BIOS(Basic Input Output Software) would issue an error message.

• Once the boot loader program is detected and loaded into the memory, BIOS gives the control to
it. So, in simple terms BIOS loads and executes the MBR boot loader.
2. MBR : MBR stands for Master Boot Record.

• It is located in the 1st sector of the bootable disk. Typically /dev/hda,


or /dev/sda. MBR is less than 512 bytes in size. This has three
components
a. primary boot loader info in 1st 446 bytes
b. partition table info in next 64 bytes
c. mbr validation check in last 2 bytes.

• It contains information about GRUB (or LILO in old systems).


3. GRUB
• GRUB stands for Grand Unified Bootloader.
• If you have multiple kernel images installed on your system, you can
choose which one to be executed. GRUB displays a splash screen,
waits for few seconds, if you don’t enter anything, it loads the default
kernel image as specified in the grub configuration file.
• GRUB therefore loads and executes Kernel and initrd images.
• Installing grub : Run the grub-install command to install grub. The
command requires a destination for overwriting the boot sector or
mbr.
$# grub-install /dev/hda1
4. Kernel
• Mounts the root file system as specified in the “root=” in grub.conf. Kernel

executes the /sbin/init program. Since init is the 1st program to be executed by

Linux Kernel, it has the process id (PID) of 1. initrd stands for Initial RAM Disk.

• initrd is used by kernel as temporary root file system until kernel is booted and

the real root file system is mounted. It also contains necessary drivers compiled

inside, which helps it to access the hard drive partitions, and other hardware.
5. init
• It looks at the /etc/inittab file to decide the Linux run level. Following are the
available run levels
a. Run level 0 is matched by poweroff.target (Halt)
b. Run level 1 is matched by rescue.target (Single user mode)
c. Run level 2 is emulated by multi-user.target (Multi-user mode without
networking)
d. Run level 3 is emulated by multi-user.target (Multi-user mode with
networking)
e. Run level 4 is unused. (user definable)
f. Run level 5 is emulated by graphical.target
g. Run level 6 is emulated by reboot.target (Reboot)
Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run
level. Typically the default run level is set to either 3 or 5.
6. Run-level Programs
• When the Linux system is booting up, various services can be seen getting
started. For example, it might say “starting sendmail …. OK”. Those are
the runlevel programs, executed from the run level directory as defined
by your run level. Depending on the default init level setting, the system
will execute the programs from one of the following directories.
1. Run level 0 – /etc/rc.d/rc0.d/
2. Run level 1 – /etc/rc.d/rc1.d/
3. Run level 2 – /etc/rc.d/rc2.d/
4. Run level 3 – /etc/rc.d/rc3.d/
5. Run level 4 – /etc/rc.d/rc4.d/
6. Run level 5 – /etc/rc.d/rc5.d/
7. Run level 6 – /etc/rc.d/rc6.d/
MODULE IV
NETWORKING IN LINUX
Network Interfaces
❑ lo (Loopback) : Loopback address – 127.0.0.1

❑ eth0 (Ethernet) : Local network

❑ wlan0 (wifi)
Network Manager
❑ The default networking service is provided by NetworkManager, which is a dynamic network
control and configuration daemon to keep network devices and connections up and active when
they are available.

❑ NetworkManager is installed by default on Red Hat Enterprise Linux. If it is not, enter as root:
# yum install NetworkManager

❑ To check whether NetworkManager is running:

~]$ systemctl status NetworkManager

❑ To start NetworkManager:

~]# systemctl start NetworkManager

❑ To enable NetworkManager automatically at boot time:

~]# systemctl enable NetworkManager


Using network scripts

❑ The term network scripts refers to the script /etc/init.d/network

❑ Although NetworkManager provides the default networking service,


scripts and NetworkManager can run in parallel and work together.

❑ To bring up all networking:

# /etc/init.d/network start

❑ To shut down all networking:

# /etc/init.d/network stop
Configuring IP Networking with ip commands
➢ We can configure a network interface using the ip command, but changes are not
persistent across reboots; when you reboot, you will lose any change.

➢ To bring an interface up/down:

ip link set ifname up/down Eg. ip link set eth0 up

➢ The ip utility can be used to assign IP addresses to an interface with the following form:

ip addr [ add | del ] address dev ifname

➢ To assign an IP address to interface enp1s0:

~]# ip address add 192.168.12.30 dev enp1s0

➢ You can view the address assignment of a specific device:

~]# ip addr show dev enp1s0


Accessing Remote Systems
A remote computer is a computer that a user has no access to
physically, but may be able to access it remotely via a network link
from another computer.
Accessing Remote Systems
telnet
▪ telnet protocol is used to log in remotely to another system on a network
$ telnet garnet.berkdey.edu
Connected to garnet
login:
▪ Once connected, follow the login procedure for the system. ie. Login name &
password. telnet prompt will look like :
telnet > commands
▪ You can quit telnet using :
telnet > quit
Accessing remote systems : Secure Shell
 Secure Shell is a network communication protocol that enables
two computers to communicate and share data. An inherent
feature of ssh is that the communication between the two
computers is encrypted meaning that it is suitable for use on
insecure networks.
Secure Shell(SSH)
 The ssh protocol is secure in two ways. Firstly the connection is
encrypted and secondly the connection is authenticated both
ways.
 Then authentication takes place (using user id/password or
public/private keys) and communication can begin over the
encrypted connection.
 The ssh protocol will remember the servers it connected to (and
warn you in case something suspicious happened).
 Ssh by default uses the port no. 22
/etc/ssh/
▪ Configuration of ssh client and server is done in the
/etc/ssh/sshd-config file
public and private keys
The ssh protocol uses the well known system of public and
private keys.
➢ Imagine Alice and Bob, two people that like to communicate with
each other. Using public and private keys they can communicate with
encryption and with authentication.
➢ When Alice wants to send an encrypted message to Bob, she uses
the public key of Bob. Bob shares his public key with Alice, but keeps
his private key private! Since Bob is the only one to have Bob's
private key, Alice is sure that Bob is the only one that can read the
encrypted message.
Logging into a remote server
The following command shows how to use ssh to log in to a
remote computer running Linux. The local user is named paul
and he is logging in as a user admin42 on the remote system.
ssh remoteusername@remotehost
To logout : exit

paul@ubu1204:~$ ssh admin42@192.168.1.30


Executing a command in remote
This screenshot shows how to execute the pwd command on the
remote server.

paul@ubu1204:~$ ssh admin42@192.168.1.30 pwd


admin42@192.168.1.30's password:
/home/admin42
paul@ubu1204:~$
Setting up passwordless ssh
To set up passwordless ssh authentication through
public/private keys, use ssh-keygen to generate a key pair
without a passphrase, and then copy your public key to the
destination server.
ssh keygen –t rsa
ssh keygen –t dsa
~/.ssh
While ssh-keygen generates a public and a private key, it will also create a
hidden .ssh directory with proper permissions.

[alice@RHEL5 ~]$ ls -ld .ssh


drwx------ 2 alice alice 4096 May 1 07:38 .ssh
[alice@RHEL5 ~]$
id_rsa and id_rsa.pub
The ssh-keygen command generate two keys in .ssh. The public
key is named ~/.ssh/id_rsa.pub. The private key is named
~/.ssh/id_rsa.

[alice@RHEL5 ~]$ ls -l .ssh/


total 16
-rw------- 1 alice alice 1671 May 1 07:38 id_rsa
-rw-r--r-- 1 alice alice 393 May 1 07:38 id_rsa.pub
authorized_keys
In your ~/.ssh directory, you can create a file called authorized_keys.
This file can contain one or more public keys from people you trust.
Those trusted people can use their private keys to prove their identity
and gain access to your account via ssh (without password).
sshd
The ssh server is called sshd and is provided by the openssh-
server package.
sshd keys
The public keys used by the sshd server are located in
/etc/ssh directory and are world readable. The private keys are
only readable by root.
Transferring files : scp (Secure Copy)
❖ scp (secure copy) command in Linux system is used to copy
file(s) between servers in a secure way.
❖ The SCP command or secure copy allows the secure
transferring of files between the local host and the remote host
or between two remote hosts.
❖ It uses the same authentication and security as it is used in the
Secure Shell (SSH) protocol.

paul@ubu1204:~$ scp admin42@192.168.1.30:/etc/hosts


/home/paul/serverhosts
admin42@192.168.1.30's password:
hosts 100% 809 0.8KB/s 00:00
Backing up data using rsync
rsync is a fast and versatile command-line utility for synchronizing
files and directories between two locations over a remote shell, or
from/to a remote rsync daemon.
 rsync example for backing up / copying from remote server to local
Linux computer:
rsync -arv user01@server01.comentum.com:/home/user01/
/home/bob/user01backup/
 (/home/bob/user01backup/ is a local Linux folder path)
 Here a-archive means it preserves permissions, links etc.
 r – recursive (copies directories and subdirectories) , v-verbose
LINUX NETWORK
SERVICES
Linux Networking Services
• File Services
• Print Services
• Firewall Services
• Web Services
• Security Services
• E-mail Services
Networking Services
• A service (also called a daemon process) is software that runs on a
computer, generally in the background. For eg. network service runs at
the application layer to provide some form of service over a network.

• To start a given service, use: $ sudo systemctl start <service>

• To stop a given service, use: $ sudo systemctl stop <service>

• To find out whether a service is running, inactive, enabled, disabled, or has


exited, use: $ sudo systemctl status <service>
File Services
• File services is a solution where files can be stored, managed,
tracked, and shared with users across the network.

• Eg. Network File System (NFS)

• The Network File System (NFS) is a mechanism for storing files on a


network. It is a distributed file system that allows users to access
files and directories located on remote computers and treat those
files and directories as if they were local.
Print Services
• A print server allows printers to be shared by everyone on the network.

• The advantages of printer sharing are:


• Fewer printers are needed
• Reduced maintenance.
• Access to special printers. Very high-quality color printers and very high-speed
printers are expensive and needed only occasionally. Sharing these printers makes
the best use of expensive resources.

• There are two techniques commonly used for sharing printers on a corporate
network. One technique is to use the sharing services provided by Samba. The
other approach is to use the traditional Unix lpr command and an lpd server or
Common Unix Printing Service (CUPS) for setting up shared printers.
Firewall Services
• A Firewall is a network security device that monitors and filters
incoming and outgoing network traffic based on an
organization's previously established security policies.

Eg. iptables (Kernel-based firewall) in Linux.


Web Services
• Web service is a standardized medium to propagate
communication between the client and server applications on
the WWW (World Wide Web).

• It is a method of communication between two electronic devices


over a network.

• Web servers are also known as HTTP servers, as they use


the hypertext transport protocol (HTTP).

• Eg. APACHE web server


Security Services
• The System Security Services Daemon (SSSD) provides a set
of daemons to manage access to remote directories and
authentication mechanisms.

• The global security database is used for access to files,


directories, printers, user account information. Such services
can be supported with LDAP or Network Information
Service(NIS)
Email Services
• A mail server also known as a mail transfer agent, or MTA; mail
transport agent is an application that receives incoming email
from local users and remote senders and forwards outgoing
messages for delivery. A computer dedicated to running these
applications is also called a mail server.

• Eg. Sendmail, Postfix


LINUX ADMINISTRATION
MODULE - IV
CONFIGURING DISK DEVICES
•Data is normally stored on magnetic or optical disk platters.
•Data is written in concentric circles called tracks.
•Tracks are divided into sectors where each sector can store
512 bytes of data.
•In the Linux Operating System we need to create one or more
partitions.
•The fdisk utility is used to create and delete partitions
CONFIGURING DISK DEVICES
• As with all Linux-like operating systems Linux uses device files
to access all hardware (including disk drives). Under Linux,
the device files for disk drives appear in the /dev/
directory. The important points are as follows:
1. Device type
2. Unit
3. Partition
CONFIGURING DISK DEVICES
Device Type
The first two letters of the device file name refer to the
specific type of device. For disk drives, there are two device
types that are most common:
• sd — The device is SCSI-based
• hd — The device is ATA-based
CONFIGURING DISK DEVICES
Unit
▪Following the two-letter device type are one or two
letters denoting the specific unit.
▪The unit designator starts with “a” for the first unit, “b”
for the second, and so on.
▪ Therefore,the first hard drive on your system may
appear as hda or sda.
CONFIGURING DISK DEVICES
Partition
• The final part of the device file name is a number representing a
specific partition on the device, starting with “1.” The number may be
one or two digits in length, depending on the number of partitions
written to the specific device.
• Here are some examples:
/dev/hda1 — The first partition on the first ATA drive
/dev/sdb12 — The twelfth partition on the second SCSI drive
WHOLE DEVICE ACCESS
There are instances where it is necessary to access the entire device and not just a specific partition.
This is normally done when the device is not partitioned or does not support standard partitions
(such as a CD-ROM drive). In these cases, the partition number is omitted:
/dev/hdc — The entire third ATA device
/dev/sdb — The entire second SCSI device
Examples of basic naming scheme:
• The first floppy drive is named /dev/fd0 whereas the second floppy drive is named /dev/fd1.
• The first hard disk detected is named /dev/sda , the second hard disk detected is named
/dev/sdb, and so on.
• The first SCSI CD-ROM is named /dev/scd0, also known as /dev/sr0.
OVERVIEW OF PARTITIONING

❖Partitioning is the process of creating logical boundaries on a


storage device.

❖Common examples of storage devices include hard disk drives


(HDDs), solid-state drives (SSDs), USB flash drives, and SD cards.

❖Creating a partition on a drive logically separates it from other


partitions. This logical separation can be useful for a variety of
scenarios, including limiting the growth of a filesystem and installing
multiple operating systems on a single drive.
TYPES OF PARTITION

➢PRIMARY PARTITION
➢EXTENDED PARTITION
➢LOGICAL PARTITION
Initially, a hard disk drive could be divided in to two partitions called the primary
partition and extended partition. Information about the partitions in a computer is
included in the Partition table, which is located in the Master Boot Record.
TYPES OF PARTITION

➢PRIMARY PARTITION
A disk drive can contain a maximum of four primary partitions or three
primary partitions and a single extended partition. A primary partition
can be used to boot an Operating System. Boot files should be located
in a primary partition.
TYPES OF PARTITION

➢EXTENDED PARTITION
• Only a single extended partition can be contained in a hard disk. But the
extended partition could be subdivided in to several partitions called logical
partitions.

• Extended partition acts as a container for logical partitions.


• The structure of the extended partition (about the logical partitions contained
within the extended partition) is described in the Extended Boot Record (EBR).

• Extended partition can be used for storing user data. (files, images, video etc)
PRIMARY V/S EXTENDED PARTITION

▪Primary partition is a bootable partition and it contains the


operating system/s of the computer, while extended partition is
a partition that is not bootable.
▪Extended partition typically contains multiple logical partitions
and it is used to store data.
▪A disk drive can contain multiple primary partitions, but it can
contain only a single extended partition. Dual boot systems can
be created using several primary partitions.
PARTITIONING NEW DISKS -PARTITIONING TOOL IN LINUX

• fdisk is a command-line utility for disk partitioning.


• For this sample run, assume that you want to partition the
/dev/hdb device, a 340MB IDE hard disk. You begin by
running fdisk with the /dev/hdb parameter:
• [root@tedford /root]# fdisk /dev/hdb
which outputs a simple prompt:
• Command (m for help):
COMMAND (M FOR HELP): M
a - toggle a bootable flag p - print the partition table

b - edit bsd disklabel q - quit without saving changes

c - toggle the dos compatibility flag s - create a new empty Sun disklabel

d - delete a partition t - change a partition's system id

l - list known partition types u - change display/entry units

m - print this menu v - verify the partition table

n - add a new partition w - write table to disk and exit

o - create a new empty DOS partition table x - extra functionality (experts only)
Creating and Managing File Systems
File System

▪ A file system is a method of organizing files on the partition.

▪ File systems has the control over process like including


directories and access control, and contain meta information
about files like access times, modification times and file
ownership etc.
Types of Linux File System

Linux offers many file systems such as Ext, Ext2, Ext3, Ext4, JFS, XFS and swap etc..
1. Ext, Ext2, Ext3 and Ext4 file system
❑ The file system Ext stands for Extended File System. The Ext file system is an older version, and
is no longer used due to some limitations.
❑ Ext2 (Second extended file system) is the first Linux file system that allows managing two
terabytes of data.
❑ Ext3 (Third extended file system) is an upgraded version of Ext2 and contains backward
compatibility. This file system does not support file recovery and disk snapshot.
❑ Ext4 (Fourth extended file system) is the faster file system among all the Ext file systems. It is
the default file system in Linux distribution.
Types of Linux File System
JFS stands for Journaled File System Journaling file systems keep a log called the
journal, that keeps track of the changes made to a file but not yet permanently
committed to the disk so that in case of a system failure the lost changes can be
brought back.
XFS File System : XFS file system was considered as high-speed JFS, which is
developed for parallel I/O processing. NASA is still using this file system with its
high storage server (300+ Terabyte server).
Swap File System : The swap file system is used for memory paging in Linux
operating system.
Mounting
• Mounting is a process by which the operating system makes files and directories on a storage
device (such as hard drive, CD-ROM, or network share) available for users to access via the
computer's file system.
• All files accessible in Unix/Linux, are arranged in one big tree: the file hierarchy, rooted at /
• The mount command attaches a file system, located on some device or other, to the file tree.
Conversely, the umount command will detach it again.
 The standard form of the mount command is:
 mount -t type device dir
• This tells the kernel to attach the filesystem found on device (which is of type type) at the
directory dir.
Eg. mount /dev/sdb1 /mnt/media (This mounts the /dev/sdb1 file system into the
/mnt/media directory)
/etc/fstab

▪ The /etc/fstab file is one of the most important files in a Linux-based system, since it stores
static information about filesystems, their mountpoints and mount options.

▪ It is a system configuration file that contains all available disks, disk partitions and their
options. Each file system is described on a separate line.

▪ The /etc/fstab file is used by the mount command, which reads the file to determine which
options should be used when mounting the specified device.
umount command

To unmount a file system, use the umount command. The command format is :
umount [-f] directory
where directory is the directory to be unmounted. –f : force an unmount
For example:
[root@rhel] # umount /mnt/media
unmounts the partition mounted on the /mnt/media directory.
The umount command detaches the specified file system(s) from the file
hierarchy.
Symbolic Links and Hard Links

 A link in UNIX is a pointer to a file. Like pointers in any programming languages, links in
UNIX are pointers pointing to a file or a directory. Creating links is a kind of shortcuts to
access a file. Links allow more than one file name to refer to the same file, elsewhere.
 There are two types of links :
 Soft Link or Symbolic links - A soft link is a short pointer file that links a filename to a
pathname. It's nothing more than a shortcut to the original file, much like the Windows OS's
shortcut option. The soft link serves as a pointer to another file without the file's actual
contents. It allows the users to delete or the soft links without affecting the original file's
contents.
 Hard Links – It is a copy of the original file that serves as a pointer to the same file, allowing
it to be accessed even if the original file is deleted or relocated.
 The "ln" command is used to make a hard link in Linux. On the other hand, the command for a
soft link is "ln -s".
Symbolic Links and Hard Links

 A symbolic or soft link is an actual link to the original file, whereas a hard link is a mirror copy
of the original file. If you delete the original file, the soft link has no value, because it points to
a non-existent file.
 But in the case of hard link, it is entirely opposite. Even if you delete the original file, the hard
link still has the data of the original file. This is because hard link acts as a mirror copy of the
original file.
 ln -s sourcefile softlinkfile
//above command creates a soft link of sourcefile
 ln sourcefile hardlinkfile
//above command creates a hardlink of sourcefile

You might also like