0% found this document useful (0 votes)
66 views33 pages

CDAC Linux

Uploaded by

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

CDAC Linux

Uploaded by

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

Red Hat Linux Essentials &

Administration
Abrar Ali Khan Zai - Blr, Kar, IN
[email protected]
9880331503

PG-DCSF Mar 2024 (05-09 March 2024)


Join Zoom Meeting
https://us02web.zoom.us/j/89339010254?pwd=KzhqUExkMFlOQ2xaR0toSEdCOXB6QT09

Meeting ID: 37
Passcode: 370626

Linux Class Document:

https://docs.google.com/document/d/1LNAwT_IkQl2_PiBLlq6VgnexBGUgOWA_AxCc36vuxMM/edit?usp=sharing

1.
Day 1: Tue, 5 Mar. ‘24
1.

Download Links:

1. Visual C++ Redistributable for VirtualBox

https://aka.ms/vs/17/release/vc_redist.x64.exe

2. Putty SSH Client

https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.80-installer.msi
Lab Manual

1. Setup VirtualBox VM

https://docs.google.com/document/d/1X8ptyuI5p3efjkqSpxsqursNMfSbm0Pkwl7-PRibsBM/edit?
usp=sharing

2. Install RedHat Linux 9

/docs.google.com/document/d/169zigjAdYms9c3LHGoDloa4NETXSPf31csV1PreIBC8/edit?usp
=sharing
https:/

3. Working with Files


https://docs.google.com/document/d/10gyVlmczQ-maVwuSFS1EXqc8TJS4JeRCkwaJCK9EMV
I/edit?usp=sharing

Ess_LabManual_02_Organise_Files
4. Changing FIle Permissions & Ownership
https://docs.google.com/document/d/154o-PHpZiO36PZ7koh9cBVqbNz6CRxsArfOLOTd18lI/edi
t?usp=sharing

5. Logical Volume Management


https://docs.google.com/document/d/1NAgTi8sETtFVLsI_vtuhbEPNZhbqPBCFqc6ONn3C8AA/e
dit?usp=sharing

Logging in to your Linux System

When you power on your Linux system in text mode you get a login screen.

On the login screen type in a valid username and its password

eg:
student
password
Once you login to your account you get a command prompt

eg:
[student@vm1-abrar ~]$

This shows your basic account information

[student@vm1-abrar ~]$
Student is the username
vm1-abrar is the computer name
tilde ( ~ ) represent you are in your home directory ( /home/abrar/ )
The dollar symbol ( $ ) means you are a normal user not administrator

[root@vm1-abrar ~]#
The pound symbol ( # ) means you are a privileged user or administrator
Be very careful in the root account; any accidental errors can impact all users on the system.
You have been warned.

Basic Linux Commands to try out on your new Linux Server


whoami Shows your user name
pwd Shows the present working directory
hostname Shows the Server name
date Shows the current date and time
ls Lists files in the current directory
rmdir -v Music Removes an existing empty directory
mkdir -v Audio Makes a new empty directory
cd Audio Changes into the specified directory
touch advice.mp3 Creates an empty file with the
specified file name
ls -l advice.mp3 Shows details or long-lists the
specified file
cd Changes to the home directory
ls Audio/ Lists files in the specified directory
ls -a .bash* Lists hidden files starting with the
letters “.bash”
history Shows the command history
clear clears the screen
poweroff Powers Off the Virtual Machine!

13 whatis mkdir
14 man mkdir
15 mkdir os
16 ll
17 mkdir hardware
18 ll
19 mkdir software
20 ll
21 mkdir firmware
22 mkdir ransomware
23 ll
24 man rmdir
25 rmdir ransomware/
26 ll
27 rmdir firmware/
33 cd os
34 pwd
35 ll
36 mkdir unix
37 ll
38 cd unix
39 pwd
40 mkdir solaris
41 ll
42 cd solaris
43 pwd
44 cd
45 pwd
46 ll
47 ll os
48 ll os/unix
49 ll os/unix/solaris
50 pwd
51 touch linux
52 ll
53 touch dos
54 ll
55 touch unix
56 ll
57 touch MacOS
58 ll
59 mkdir Operating System
60 ll
61 mkdir -v my_os
62 ll
63 mkdir your-os
64 ll
65 mkdir -v their.os
66 ll
67 mkdir -v "my work"
68 ll
69 rm dos
70 ll
71 rm unix
72 ll
73 rm -v linux
74 ll
75 rm macos
76 rm -v MacOS
77 ll
78 rmdir myos
79 rmdir my_os
80 ll
81 rmdir your-os
82 ll
83 rmdir -v their.os
84 ll
85 ll os
86 rmdir -v os
87 rm -v os
88 rm -rv os
89 ll
90 mkdir -v grandpa
91 mkdir -v grandpa/father
92 mkdir -v grandpa/father/son
93 mkdir -v grandpa/father/son/grandson
94 ls
95 ls -R grandpa
96 rm -rv grandpa
97 history
98 mkdir -pv grandma/mother/daughter/son
99 ls -R grandma
100 whatis nano
101 man nano
102 which nano
103 which tree
104 whoami
105 su - root
106 whatis touch
107 whatis tree
108 whatis nano
109 which tree
110 which nano
111 ll
112 tree grandma
113 tree
114 nano basic-commands.txt
115 ll
116 cat basic-commands.txt
117 ls -a
118 cat .bashrc
119 ls -a
120 cat .bash_profile
121 ls -a
122 cat .bash_logout
123 cat basic-commands.txt
124 history
cat .bashrc
22 cat -n .bashrc
23 cat -n .bash_profile
24 cat -n .bash_logout
25 whatis wc
26 wc -l .bashrc
27 wc -w .bashrc
28 wc -c .bashrc
29 wc -lwc .bashrc
30 cat .bashrc
31 head .bashrc
32 tail .bashrc
33 head -n 3 .bashrc
34 head -n 7 .bashrc
35 tail -n 7 .bashrc
36 tail -n 17 .bashrc
37 tail -n 1 .bashrc
38 ls -a
39 cat .bashrc
40 whatis grep
41 grep function .bashrc
42 grep bin .bashrc
43 grep path .bashrc
44 grep -i path .bashrc
45 ll /etc/group
46 cat -n /etc/group
47 grep 10 /etc/group
48 grep body /etc/group
49 history
9 whatis mv
10 mv -v wednesday wed
11 ll
12 mv -v weekdays week
13 ll
14 touch fri
15 mkdir -v end
16 ll
17 mv -v fri friday
18 mv -v end weekend
19 ll
20 mkdir -v linux
21 touch redhat rocky centos
22 ll
23 mv -v centos linux
24 ll
25 mv -v redhat linux
26 ll
27 mv -v rocky linux
28 ll
29 tree linux
30 mkdir -v unix
31 touch solaris aix hpux
32 ll
33 mv -v aix hpux solaris unix
34 ll
35 tree unix
36 history
45 mkdir -v planets
46 touch mercury venus earth mars
47 ll -tr
48 mv -v venus mercury planets
49 cp -v mars earth planets
50 ll -tr
51 tree planets
52 mkdir march
53 touch feb
54 rmdir march
55 rm feb
56 mkdir 2024
57 touch 2024/march
58 rm -rv 2024
59 mkdir april
60 touch april/wise
61 touch april/fool
62 tree april
63 # -i means interactive; this applies to cp mv rm
64 rm -ivr april
65 tree april
66 mkdir microsoft
67 touch microsoft/dos
68 touch microsoft/windows
69 tree microsoft
70 rm -ivr microsoft
71 tree microsoft
72 history
4 whatis useradd
5 useradd user1
6 ll /home
7 useradd user2
8 ll /home
9 tail /etc/passwd
10 useradd user3
11 tail /etc/passwd
12 passwd user1
13 tail /etc/shadow
14 passwd user2
15 tail /etc/shadow
16 passwd user3
17 tail /etc/shadow
18 su - user1
19 whoami
20 history

Install a 2nd VM with these changes:

Name: Rocky Linux 9 VM2


RAM: 1024
CPUs: 2
Disk: 10 GB
Network
Adapter 1 - NAT - Port 2222
Adapter 2 - Anable & Bridged
Mouse Pointer: USB MT Touchscreen & Touchpad
hostname: vm2-yourname.example.com
Ensure Adapter 2 is enabGUI
Username:
your name eg: abrar
password:vm2
your password eg: secret

after installation upgrade your system to GUI mode:

From the root account run:

dnf groupinstall ‘Server with GUI’

systemctl set-default graphical.target

Text Processing Commands

file determine type of file file .bashrc


file /etc

cat -n show text file with line numbers cat -n /etc/passwd

head -n 7 shows first few lines of text file head -n 7 /etc/passwd

tail -n 3 show last few lines of text file tail-n 3 /etc/passwd

wc -lwc counts lines, words, characters in wc -lwc /etc/passwd


text file

grep text filename shows lines containing specified grep body /etc/passwd
word in text file
File operations

mv -v src dest/ move a file from one directory to


another

cp -v src dest/ copy a file from one directory to


another

rm -v <filename> Remove a file

rm -rv <dir-ame> Remove a directory recursively

rm -iv <filename> Remove a file interactively

Important Directories under the root filesystem ( / )

/bin binaries or commands

/sbin system binaries or privileged commands

/boot files needed to start the OS

/dev device files

/etc configuration files

/home a directory for every user

/media removable media like USB, DVD

/mnt extra disks

/opt optional 3rd party application like Oracle DB

/proc Process related information

/root root user’s home directory


/tmp temporary data

/var variable data like log files

/usr system installed applications


5 whatis useradd
6 useradd user1
7 tail /etc/passwd
8 passwd user1
9 tail /etc/shadow
10 useradd user2
11 passwd user2
12 tail /etc/passwd
13 tail /etc/shadow
14 su - user1
15 useradd pupil
16 tail /etc/passwd
17 passwd pupil
18 tail /etc/shadow
19 su - pupil
20 whoami
21 whatis groupadd
22 groupadd developers
23 tail /etc/group
24 groupadd class
25 tail /etc/group
26 useradd -G class student1
27 tail /etc/group
28 useradd -G class student2
29 tail /etc/group
30 useradd -G developers dev1
31 useradd -G developers dev2
32 useradd -G developers dev3
33 tail /etc/group
34 tail /etc/shadow
35 passwd student1
36 passwd student2
37 passwd dev1
38 passwd dev2
39 passwd dev3
40 tail /etc/shadow
41 su - student1
42 whatis userdel
43 userdel -r student2
44 tail /etc/passwd
45 ll
46 ll /home
47 userdel -r dev3
48 ll /home
49 tail /etc/passwd
50 whatis groupdel
51 groupadd staff
52 tail /etc/group
53 useradd -G staff member1
54 tail /etc/group
55 groupdel staff
56 tail /etc/group
57 history

User and group management

add a user useradd username

modify a user a user usermod <options> username

delete a user userdel -r username

add a group groupadd groupname

modify a group groupmod <options> groupname

delete a group groupdel groupname

set a password passwd username

change password aging chage <options> username


information

72 useradd sales
73 tail /etc.passwd
74 tail /etc/passwd
75 whatis usermod
76 usermod -u 1234 sales
77 tail /etc/passwd
78 usermod -c 'sales account' sales
79 tail /etc/passwd
80 group buisness
81 groupadd buisness
82 usermod -G buisness sales
83 whatis chage
84 chage -l sales
85 passwd sales
86 chage -l sales
87 chage -M 60 sales
88 chage -l sales
89 chage -W 5 sales
90 chage -l sales
91 chage --help
92 man chage
93 useradd ceo
94 passwd ceo
95 chage -l ceo
96 chage -E 2025-11-30 -W 5 -M 120 ceo
97 chage -l ceo
98 tail /etc/shadow
99 history

Standard Input, Output & Pipes

Data Redirection & Pipes

> redirect output to a file cal > this-month

2> redirect errors to a file ls -R /tmp 2> tmp-errors


>> append output to an existing file who >> this-month
without overwriting

2>> append errors to an existing file ls -R /home 2>> tmp-errors


without overwriting

| send output of one command to cat /etc/passwd | wc -l


another command

5 date
6 date > today
7 ll -tr
8 cat today
9 who
10 who > loggers
11 ll
12 cat loggers
13 ls /
14 ls / > main-dirs
15 ll
16 cat main-dirs
17 whoami
18 ls -R /tmp
19 ls -R /tmp 2> tmp-err
20 ll
21 cat tmp-err
22 ls -R /boot
23 ls -R /boot > boot-out
24 ls -R /boot > boot-out 2> boot-err
25 ll
26 head boot-err boot-out
27 history

1 whoami
2 id -u
3 pwd
4 ll -a
5 id student
6 date
7 date > >
8 date > today
9 ll -tr
10 cat today
11 who
12 who > loggers
13 ll -tr
14 cat loggers
15 ls /
16 ls / > main-dirs
17 ll
18 cat main-dirs
19 whoami
20 ls
21 ls -R /tmp
22 ls -R /tmp 2> tmp-err
23 tmp err
24 ll
25 ls -R /boot
26 ls -R /boot > boot-out
27 ls -R /boot > boot-out 2> boot-err
28 ll
29 head boot-err boot-out
30 history
31 ls -R /etc
32 ls -R /etc &> etc-both
33 cat etc-both
34 grep -i permission etc-both
35 ls -R /home
36 ls -R /home &> home-errs
37 ll
38 cat home-errs

44 history | wc
45 history | head
46 history | tail
47 history | tail -n 15
48 history | grep cat
49 history | grep id
50 history | grep cp
51 who
52 who | wc -l
53 cal 2024
54 cal 2024 | head -n 15
55 cal 2024 | tail -n 15
56 ll /
57 ll / | grep bin
58 ll / | grep lib
59 ll / | grep tmp

5 date
6 date > today
7 ll -tr
8 cat today
9 who
10 who > loggers
11 ll
12 cat loggers
13 ls /
14 ls / > main-dirs
15 ll
16 cat main-dirs
17 whoami
18 ls -R /tmp
19 ls -R /tmp 2> tmp-err
20 ll
21 cat tmp-err
22 ls -R /boot
23 ls -R /boot > boot-out
24 ls -R /boot > boot-out 2> boot-err
25 ll
26 head boot-err boot-out
27 history

5 date
6 date > today
7 ll -tr
8 cat today
9 who
10 who > loggers
11 ll
12 cat loggers
13 ls /
14 ls / > main-dirs
15 ll
16 cat main-dirs
17 whoami
18 ls -R /tmp
19 ls -R /tmp 2> tmp-err
20 ll
21 cat tmp-err
22 ls -R /boot
23 ls -R /boot > boot-out
24 ls -R /boot > boot-out 2> boot-err
25 ll
26 head boot-err boot-out
27 history

5 date
6 date > today
7 ll -tr
8 cat today
9 who
10 who > loggers
11 ll
12 cat loggers
13 ls /
14 ls / > main-dirs
15 ll
16 cat main-dirs
17 whoami
18 ls -R /tmp
19 ls -R /tmp 2> tmp-err
20 ll
21 cat tmp-err
22 ls -R /boot
23 ls -R /boot > boot-out
24 ls -R /boot > boot-out 2> boot-err
25 ll
26 head boot-err boot-out
27 history

File Permissions & Ownership

When a user creates a file or directory it automatically belong to it.

Users can be part of larger groups


Group information is in the /etc/group file
Liunx has 3 levels of access on a file or directory.

1. User or owner level access


2. Group level access
3. Other or World level access.

When we use the ls -l command we can see the file permissions and ownership

eg:

rwx r- - - - - abrar
mail filename

To change file permissions or access mode we use the chmod command.

In the symbolic method the symbols in the below table are used

FIle Permissions

user u

group g

other o
all a

read r

write w

execute x

not set -

add +

remove -

assign absolutely =

39 mkdir access
40 ll
41 cd access
42 ll
43 touch file-{a,e,i,o,u}
44 ll
45 grep student /etc/passwd
46 grep student /etc/group
47 ll
48 mkdir dir-{A..E}
49 ll
50 chmod -v g+w dir-A
51 chmod -v o-rx dir-B
52 chmod -v g+w,o-rx dir-C
53 chmod -v ugo+x file-a
54 chmod -v u+x,g+w,o-r file-e
55 chmod -v a+x file-i
56 chmod -v ugo=r file-o
57 chmod -v u=rwx,g=r,o=--- file-u
58 ll
Changing FIle ownership and Group ownership

To change file ownership use the chown command as root

eg:

chown -v abrar filename

To change group ownership use the chgrp command as root

chgrp -v developers dirname

86 mkdir project
87 cd project
88 touch task-{1..5}
89 ll
90 id student
91 chown -v student task-1
92 id pupil
93 chown -v pupil task-2
94 grep developers /etc/group
95 lid -g developers
96 ll
97 chgrp -v developers task-3
98 grep wheel /etc/group
99 chgrp -v wheel task-4
100 ll
101 chown -v student:mail task-5
102 ll
103 mkdir notebook
104 touch notebook/page-{1..7}
105 ll
106 ll notebook
107 ll
108 chown -v student notebook
109 ll
110 ll notebook
111 chown -vR student notebook
112 ll notebook
113 chgrp -v mail notebook
114 ll
115 ll notebook
116 chgrp -vR mail notebook
117 ll notebook
118 ll
119 chmod -v o-rx notebook
120 ll
121 ll notebook
122 chmod -vR o-rx notebook
123 cd

Changing file Permissions using the Numeric Method

Symbolic Permission Numeric Permission

read= r, 4 write= w, 2 execute= x, 1

r-- r-- r-- 4+0+0 4+0+0 4+0+0 444

rw- rw- rw- 4+2 4+2 4+2 666

rwx rwx rwx 4+2+1 4+2+1 4+2=1 777

rwx r-x - - - 750

rwx r- - - - - 740

rw- rw- r- - 664

1 ll .bashrc
2 mkdir sample
3 cd sample
4 touch sample-{1..7}
5 ll
6 chmod -v 777 sample-1
7 chmod -v 775 sample-2
8 chmod -v 755 sample-3
9 chmod -v 700 sample-4
10 chmod -v 711 sample-5
11 chmod -v 666 sample-6
12 chmod -v 640 sample-7
13 ll
14 history

Day 3: Thu, 7 Mar. ‘24

Managing Processes

A command in a running state is called a process


Every process has a unique number assigned by the kernel called a Process ID (PID)

To view process information use the command

ps

ps a

ps au

ps aux

ps -ef

etc.

To monitor processes in real time use the top command


To kill unneeded processes use the kill command

kill -l show all the supported kill signals

kill -15 <PID> kill a process gracefully; this is the recommended approach

kill -9 <PID> kills a process abruptly; this should be used only when signal 15 is not taking
effect.

4 ps au|head
5 ps aux | head
6 ps aux | wc -l
7 ps aux | grep bash
8 ps aux | grep cron
9 ps aux | grep ssh
10 sleep 3
11 sleep 60 &
12 ps aux | grep sleep
13 whatis kill
14 sleep 200 &
15 ps aux | grep sleep
16 kill -15 3350
17 sleep 100 &
18 ps aux | grep sleep
19 kill -15 3365
20 ps aux | grep sleep
21 cd /proc
22 ls
23 s basleep 50 &
24 ls
25 cd 3377
26 ls
27 cat comm
28 cd
29 sleep 200 &
30 kill -9 3394
31 ps aux | grep sleep
32 ps aux
33 whatis top
34 top
35 sleep 30 &
36 top
37 dd if=/dev/zero of=/dev/null &
38* ps aux | grep
39 ps aux | grep -w dd
40 top
41 dd if=/dev/zero of=/dev/null &
42 top
43 history

hist

The vi Editor

To create and edit text files in Linux we have gedit, nano and vi.

Vi is a feature-rich text editor installed on all UNIX/LInux flavors by default.

vi works in 3 modes

1. command mode
2. insert mode
3. extended mode

In command mode we can navigate the file (up, down, right, left) etc

In insert mode we insert or change text

In extended mode we do file operations like saving, quitting, saving and quitting, quitting
without saving etc
Some Vi command ( in command mode)

j go down

k go up

l go right

h go left

gg go to 1st line

G go to last line

w go forward a word

b go back a word

yy copy a line

dd delete or cut a line

p paste or put copied or cut line

ESC

Commands in Extended Mode

:q quit file

:q! quit without saving

:wq save and quit

:x save and quit


102 whatis vi
103 whatis vim
104 vi my_editor
105 cat my_editor
106 vi my_editor
107 cat my_editor
108 vi my_editor
109 cat my_editor
110 vi my_editor
111 cat my_editor
112 history

vi is a modal editor
we have 4 modes:
command mode
insert mode
extended mode
visual mode

to get into insert mode press i


to leave insert mode press esc

Managing Services

When a Linux servers boots up many service daemons start up


like HTTPd for web servers
mariadb for Database Servers
Postfix for Mail Servers
named for DNS Servers
dhcpd for DHCP Server

and also for some local services like:


NetworkManager, crond, atd, etc

To view all service units installed sun:

systemctl
systemctl | grep <service-name>

eg:

systemctl | grep crond


systemctl | grep sshd

Control Services

systemctl List all service unit

systemctl is-active <service-name> Shows if a service is currently active or running

systemctl is-enabled <service-name> Shows if a service is enabled upon boot

systemctl status <service-name> Shows details of service

systemctl stop <service-name> Stops a service immediately (not permanently)

systemct start <service-name> Start a service immediately (not permanently)

systemctl restart <service-name> Stop and again start a service

systemctl disable <service-name> Permanently turn off a service from coming up


after reboot

systemctl enable <service-name> Permanently turn on a service to come up after


reboot

15 systemctl
16 history
17 systemctl is-active crond
18 systemctl is-active sshd
19 systemctl is-active atd
20 systemctl is-enabled atd
21 systemctl is-enabled sshd
22 systemctl is-enabled crond
23 systemctl stop crond
24 systemctl is-active crond
25 systemctl stop atd
26 systemctl is-active atd
27 systemctl start atd
28 systemctl is-active atd
29 systemctl start crond
30 systemctl is-active crond
31 systemctl restart sshd
32 systemctl status crond
33 systemctl status sshd
34 history

Setup a Basic Web Server

A web server is a system that holds web pages to be shown to users asking for them through
web browsers.

In RedHat, the Web Server is Apache HTTPD Server.

Package: httpd
Service: httpd
Port: 80/tcp
Configuration FIle: /etc/httpd/conf/httpd.conf

The directory where we keep web pages is called the DocumentRoot which is /var/www/html/
by default.

Web server processes are owned by the system user apache.


Web pages should belong to user and group apache and should have read permissions for
‘others’
To access a website on a webserver you can use its IP Address or Domain Name if setup on
the DNS server.

ping 8.8.8.8 -c3


7 yum install httpd
8 ll /var/www/html
9 cd /var/www/html
10 pwd
11 vi index.html
12 systemctl status httpd
13 systemctl start httpd
14 systemctl status httpd
15 vi /etc/hosts
16 ip addr show enp0s8 | grep -w inet
17 vi /etc/hosts
18 curl vm1-priyanka.example.com
19 cd
20 wget vm1-priyanka.example.com
21 yum install wget
22 wget vm1-priyanka.example.com
23 ll
24 history

Managing Disks & Partitions

We store data on Hard Disks


Hard Disks are of various types

Virtual Disks (/dev/vda, /dev/vdb, /dev/vdc etc)


SATA Disks (/dev/sda, /dev/sdb, /dev/sdc etc)

To keep important parts of a file system isolated we partition disks.


Partitioning can make disk performance better and improves data security.

To view the disks we have we can run:

lsblk
fdisk -l

To partition disks we can use fdisk <disk-name>

eg: fdisk /dev/sdb

Creating a Standard Partition

Add a new disk if needed Virtualbox > storage …..

Check new disk name lsblk

Create new partition in new disk fdisk /dev/sdb

p - print partition table


n - create new partition
p - create primary partition
enter - accept 1st sector boundary
+512M - specify size of partition to create
p - print partition table to verify your work
w - save partition table to disk and exit

Format the newly created partition mkfs.xfs /dev/sdb1


Create a mount point to mount new partition mkdir -v /mnt/-new-data

Mount the formatted drive on new mount point mount -v /dev/sdb1 /mnt/new-data

Check if the device has got mounted correctly findmnt | grep sdb1

mount | grep sdb1

df -hT | grep sdb1

Store some data to new partition to test cp -rv /boot /var/log /mnt/new-data

241 lsblk /dev/sdb


242 mkfs.xfs /dev/sdb1
243 mkdir -v /mnt/new_data
244 whatis mount
245 history
246 mount /dev/sdb1 /mnt/new_data
247 mount
248 history
249 df
250 df -h
251 df -hT
252 df -hT /mnt/new_data
253 ll /mnt/new_data
254 cp -r /etc /mnt/new_data
255 df -hT /mnt/new_data
256 cp -r /usr/share/sbin /mnt/new_data
257 cp -r /usr/sbin /mnt/new_data
258 history

Logical Volume Management

Standard partition have some major limitations

1. Their size is fixed and its difficult to resize


2. They cannot be resized when in use
3. The capacity of the partition depends on the disk capacity in the market

Components of a LVM Setup

Physical Volume Normal disk or partition like


/dev/sdb, /dev/sdb1 etc

Volume Group It's a combination of multiple


physical volumes

Logical Volume Is a part of a Volume Group.


The logical volume if formatted
and mount

Create a new logical volume

1. Create 2 new partitions with fdisk

2. Convert the newly created partitions in Physical Volumes

pvcreate /dev/sdb2
pvcreate /dev/sdb3

3. Merge the Physical Volumes into one Volume Group

vgcreate /dev/newvg /dev/sdb

You might also like