LINUX Short Notes For Beginners
LINUX Short Notes For Beginners
____________________________________________________________________________
# Operating System :-
Operating system is a platform between Application & Hardware.
It is an interface between Application and hardware. And it will manage the Hardware resources for
application. It is a collection of programs.
A
# Linux :-
Linux is an open source operating system.
● Kernel is the heart of the application manager for all resources.
● Applications run in shall → kernel provide resources .
R
D
N
JE
A
• Customizable.
• Secure after customization.
1
LINUX
____________________________________________________________________________
A
R
DIRECTORIES OF / :
● /bin/ => binary file => store general commands D
● /sbin/ => system binary file => store system related files
● /etc/ => it store system configuration files (it is like a control panel of windows)
N
● /dev/ => device driver => it contains device files
● /var/ => variable type data => it stores that directories which size is not fix
Example: /var/spool/mail/ => store users files
JE
● /root/ => it is the home directory of the superuser (also known as the “Administrator”) of the
system.
● /run/ => /run is another new directory. System processes use it to store temporary data for
their own nefarious reasons.
● /srv/ => The /srv directory contains data for servers. If you are running a web server from
your Linux box, your HTML files for your sites would go into /srv/http (or /srv/www). If you were
running an FTP server, your files would go into /srv/ftp.
● /sys/ => /sys is another virtual directory like /proc and /dev and also contains information
from devices connected to your computer.
2
LINUX
____________________________________________________________________________
● /tmp/ => /tmp contains temporary files, usually placed there by applications that you are
running.
For detailed notes of linux file system please visit this links :
● https://www.linux.com/training-tutorials/linux-filesystem-explained/ (linux.com)
● https://www.geeksforgeeks.org/linux-file-hierarchy-structure/ (geeksforgeeks)
A
R
D
N
JE
Linux commands:-
GUI —---> TERMINAL —-----> COMMAND LINE SHALL —----> EXECUTE COMMAND
Terminal : it is an application that will help you to provide a command line shall .
A
3
LINUX
____________________________________________________________________________
A
SYNTAX FOR APPLY COMMAND :
command -[options] argument
Ctrl + shift + (+) => increase font size.
R
Ctrl + shift + (-) => decrease font size.
Ctrl + Alt + Enter => full screen
●
whoami => for show user name list
● cal (year) => for show calendar of whole year which you enter
● wc (file name) => for show the list of lines , words & characters of entered file
4
LINUX
____________________________________________________________________________
● cat => for enter any input { cat redirection = cat > (path) }
(for stop insert in cat , press ctrl +c )
● !(history list number) => for open file from history list
● head <file name> => for show 10 upper lines of entered file
● head -n (no. Of lines) (file name) => for show upper entered no. of lines of entered file
A
● tail (file name) => for show 10 lower lines of entered file
● tail -n (no. Of file) (file name) => for show lower (from end) entered no. of lines of
entered file
R
● clear (ctrl+l) => for clear all screen content
●
D
mkdir (folder name) => to create a new folder.
● command --help => for help for use the given command
● man command => for read the manual of given command for help about that
q for quit manual
● less (file name ) => for read any file without using graphical interface (use with
pgup / pgDn key)
5
LINUX
____________________________________________________________________________
● more (file name ) => for read any file without using graphical interface (use with
Enter key)
Syntax :
cp -[options] source_path destination_path : To copy file from
source_path to destination_path
When we paste any file at the destination , we can rename that file name.
Options :
-r (recursive) -> for copy any directory
A
-v (verberose) -> for list the process of copy
❖ cp (any character)* destionation_path => to copy all the files from pwd which
starts from a given character and paste that at destination.
R
Example : cp d* /home/gt => to copy all the files from pwd which starts from d and
paste that at /home/gt.
D
❖ cp -rv (any character)* destionation_path => to copy all the files & folders from
pwd which starts from a given character and paste that at destination with show the process.
Syntax:
mv -[options] source_path destination_path : To cut file/folder
from source_path & paste that at destination
Options :
-v (verberose) -> for list the process of move
A
ASSIGNMENT - 1
1. Display your current directory.
pwd
6
LINUX
____________________________________________________________________________
3. Now change to your home directory using only three key presses.
cd (and the enter key)
A
7. List the contents of the pwd.
ls
R
8. List a long listing of the root directory.
ls -l
12. List all the files (including hidden files ) in your home directory.
ls -al ~
15. Change to the /etc directory , stay here and create directory newdir in your home
directory.
cd /etc ; mkdir ~/newdir
G
16. Create in a command the directories ~/dir1/dir2/dir3 (dir3 is a subdirectory from dir2 and
dir2 is a subdirectory from dir1.)
mkdir -p ~/dir1/dir2/dir3
7
LINUX
____________________________________________________________________________
Path:-
A
R
(~) means login user with home directory.
● For go to b directory
path=> /root/proj/b/
A
End at destination.
( . ) means current directory.
( .. ) means parent directory.
Examples:-
● pwd= Test & dest. = Game
path => .. /Game/
8
LINUX
____________________________________________________________________________
A
R
Vim Editor:-
D
" Vi " is the graphical editor in linux. And its latest version is " vim ".
1.) Insert mode [ESC +i ] => editing mode ( used for edit file content)
2.) command mode [ESC + : ]
3.) Execute mode [ESC] => Default mode
vim (file name) + (line no.) => to open the file in vim editor with the cursor position at the given line.
G
command mode:-
● Esc + : => first come in command mode then apply these commands.
9
LINUX
____________________________________________________________________________
● %s/( Search word)/ ( replace word)/g => for find word and replace any word in whole file
A
Execute mode:-
R
Esc => to come in execute mode first then apply these commands.
●
D
np = > paste the copied line n no. Of times (n=1, 2,3,4,5….)
nyy => for copy n no. Of lines from the cursor (n=1, 2,3,4,5……)
N
● dd => for delete single line
10
LINUX
____________________________________________________________________________
Process:-
● touch (filename) = to create a new file in pwd
Example : touch bac
Command filename
● ls -li = for long list of for inode no. of any file
example:- 135003728 -rw-r--r--. 1 root root 0 Dec 19 04:18 bac
Inode no. permissions owner group file date time file name
● State (filename) = is used to list the metadata of inode ( info about file in inode )
Example :
File: bac
Size: 0 Blocks: 0 IO Block: 4096(size of one block in bytes) regular
empty file
Device: 10303h/66307d Inode: 135003728 Links: 1
A
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
(permissions)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2021-12-19 04:18:14.175701739 -0800 (last acces info)
R
Modify: 2021-12-19 04:18:14.175701739 -0800 (last edit info.)
Change: 2021-12-19 04:18:14.175701739 -0800 (last changes details)
Birth: -
absolute path
D
For creating the link always use absolute path relative path is not used
Command file path whose you want to create a link new link file name with
N
● ln {file path} { destination path}
JE
Ex ln root/file root/rinku/file 1
USER PART:-
CUM centralised user management : different multiple accounts working on
different things active directory with help of cum.
TYPES OF ACCOUNTS :
1. Administrator user account (root)
2. Regular user account
3. system / application / service account
11
LINUX
____________________________________________________________________________
DIRECTORES :
Administrator → /root
User regular → /home/
Application → application working directory
A
R
D
N
Command syntax : useradd -[option] user_name
JE
12
LINUX
____________________________________________________________________________
useradd renu:-
A
● /etc/passwd (it stores the information of user account)
renu : x : 1001 : 1001 : hii : /home/renu : /bin/bash
login_name: link for password: UID : GID : comment : home_dir : shell
R
/etc/shadow (it stores the password related information)
D
/etc/group (it stores the information of group account)
SHELL : 1 bash → in this user can login and run the programs
N
Location : /bin/bash/
NOLOGIN SHELL : it cannot access and do not run any command in system
Location : /sbin/nologin
JE
13
LINUX
____________________________________________________________________________
A
R
D
N
JE
A
G
14
LINUX
____________________________________________________________________________
A
● passwd (username) => for set password , change password of any user
● gpasswd (group name) => for set password , change password of any group
R
● (command) --help => for help for use any command / to see all options of any command
● man (command) => see relative all options of any command / manual of any command
●
D
Like age of password, age of account expiration date , change password day, warnings days etc
● userdel -[options] user name => It use to delete user and dir etc
A
ASSIGNMENT - 2
1. Add a group account database with group id 2001.
Ans : groupadd -g 2001 database
G
15
LINUX
____________________________________________________________________________
A
Ans : - chage arpit
- chage -l arpit
R
Ans : - usermod -u 1001 arpit
13. Check the database and ibm both are supplementary group for user shivani (user option
-a -G ).
Ans : usermod -a -G database shivani
16
LINUX
____________________________________________________________________________
PERMISSIONS:-
There are two types of permission:-
1.) Authentication :- who can enter the machine.
2.) Authorization :- Once a person enters a machine, what can they do?
A
● Execution mode of the program is called process.
● Files always have permissions for users.
User -------> program (command) -------> process ---------------> resources (files / directory
R
Examples (how it work) :-
Sachin (user) ----> cat (command for read file) ---> process (cat) ---> file1
(sachin owner)
D (check permission for sachin user)
Kushal -----> cd (command for change directory) -----> process (cd) kushal ----> directory
(check permission for kushal
N
user)
Read r 4
Write w 2
A
Execute x 1
Role of r, w, x on file/directory:-
G
Directory:-
r -------> user can list the content of the directory.
w ------> user can create or delete file / directory inside it.
x -------> user can switch inside directory.
Rt
17
LINUX
____________________________________________________________________________
● Directory must have the execute permission for read and write.
● File must have the read permission for write.
● By default execute permission is not given in the file. It is not necessary for the file because it
may be risky for the machine (for security purposes).
A
Tata - chif
Local —>
Root
Ll
R
commands used in permissions:-
●
D
ls -l (file name) => to check the permission of the file.
● chown (owner name) ( file/dir. Name) => to change the owner of the file.
● chgrp (group name) (file/dir. Name) => to change the group of files.
● chown (owner name) :(group name) (file/dir.name) => for changing the owner & group both
of file/dir.
18
LINUX
____________________________________________________________________________
● chmod (permission) (file/directory) => to change the permission / to modify the permission.
A
● = (for assign permissions)
R
Directory 1
Examples Commands:-
rwx r-x
D (permissions on categories)
● chmod ugo+rx Dir. 1 => for add read and execute permission for owner,
group, other all from dir. 1
● chmod a-w Dir. 1 => to remove the write perm. For all categories (ugo) .
Numeric way:- [ugo => format] In this way assign all three values . Same time.
Permissions Numeric Representation
Read [r] 4
A
Write [w] 2
Execute [x] 1
G
rwx 4+2+1= 7
r-x 4+1=5
-wx 2+1=3
rw- 4+2=6
Ugo = 777
Examples Commands:-
● chmod 750 Dir1 => to assign rwx-for u ; r-x- for g ; --- for o.
● chmod 664 dir. 1 => to assign rw- for u ; rw- for g ; r-- for o.
19
LINUX
____________________________________________________________________________
Important points:-
● All users have all permission in /.
● File owner has permission to read any file at home.
● Any user does not have permission to read any file in the root directory.
A
R
D
N
Sticky bit / o+t / 1 : it will apply to the directory.
JE
20
LINUX
____________________________________________________________________________
If we enter the wrong path or location of a fine that time itself, make a new file there and save the given
data in those.
A
R
D
N
Mode of redirection :
> ( overwrite)
>> ( append)
JE
Types of Redirection :
1.) Input redirection :
Example : cat > /var/stat => to enter any input in the stat file . (for stop input writing press
Ctrl + c )
2.) Output Redirection :
G
21
LINUX
____________________________________________________________________________
GREP COMMAND :
A
Globally search for regular expression and print .
It searches only a given pattern , not the location of any file .
R
Command :
● Grep -[option] pattern file1 file2 file3 => to search any pattern in
different files.
Some options of grep :
D
-i (ignore case)
-v (invert)
-w (word)
N
-c (count)
-n (line number)
JE
Example :
Pwd = root
● touch arya => to make an arya named file in pwd(root).
● vim arya => for edit arya file open vim editor
● Esc + i => to open insert mode in editor.
Type something there…………(like : hii grass , it is a company…… etc.
A
● cat arya => to read arya file (what you write in them)
● grep grass arya /etc/passwd => to search grass in arya and passwd file
( which is in /etc) (case sensitive)
● grep -i grass arya => for search all response related to grass (it is not
case sensitive)
● grep -iv grass arya => it will show all lines without containing grass
pattern related response.
● grep -ic grass arya => to print no. of lines in which grass response
founded.
● grep -c grass arya => to print no. of lines in which grass pattern is found.
22
LINUX
____________________________________________________________________________
● grep -in grass arya => to show line no. with grass response lines.
● grep -inw grass arya => to search only grass words.
PIPELINE (|) :
It will contain two or more than two commands.
A
Format :
command1 | command2 | command3
Output —--> input
Output —--->input
R
Output —--> show on screen.
Example :
● history | less => to show historyD
● history | grep -i useradd | less => to show useradd related
response lines.
N
BACKUP :
JE
For large data files we create archive files via compression method .
A
G
COMPRESSION :
1.) Lossy compression
2.) Lossless compression
1. Lossy compression :
Data —----> compression —------> data loss
23
LINUX
____________________________________________________________________________
2. Lossless compression :
Data —----> compression —---> archive file —--> extract —--> data
Example : documents
DATA TRANSFER :
Process of data transfer in normal whatsapp:
Data (50mb) —-------> network —------->
A
Whatsapp1 —-------> network —-------> whatsapp2
Image —------> reduce size —----> network —--------> image (in reduced size)
Document —----> compress —----> network —----> extract —-----> document (actual size)
R
Lossless compression :
Create an archive file by tar (compress in min. size) , tar.gzip
(compress in min. Size compared to tar ) , tar.bzip2 (compress in min. Size compared to
tar.gzip ). D
Latest method in linux for compress file is tar.bzip2
N
Command :
● tar -[options] (filename or location where you want to create new
archive file) (location of file which you want to create an archive file)
JE
Example :
● tar -cvf /home/backup.tar /mnt => for create a backup.tar
(compressed) file of /mnt folder
● du -h (file name) => to show file/folder size
● tar -tvf /home/backup.tar | grep passwd => to list backup.tar file data
(without extract) and search passwd pattern in that .
FOR EXTRACT :
● tar -xvf /home/backup.tar.bz2 -C /mnt
24
LINUX
____________________________________________________________________________
ASSIGNMENT -3
1. Display the first 12 lines of /etc/services.
Ans : head -12 /etc/services
A
3. Use cat to create a file named count.txt that looks like this:
Ans : cat > count.txt
One
R
Two
Three
Four
Five (followed by Ctrl+d)
D
4. Use cp to make a backup of this file to cnt.txt.
Ans : cp count.txt cnt.txt
N
5. Use cat to make a backup of this file to catcnt.txt.
Ans : cat count.txt > catcnt.txt
JE
6. Display catcnt.txt ,but with all lines in reverse order ( the last line first).
Ans : tac catcnt.txt
10. Open two terminal windows (or tabs) and make sure you are in the same directory in
both. Type echo this is the first line > tailing.txt in the first terminal , then
issue tail -f tailing.txt in the second terminal. Now go back to the first terminal
and type echo This is another line >> tailing.txt (note the double >>) , verify
that the tail -f in the second terminal shows both lines. Stop the tail-f with Ctrl+C.
Ans :
25
LINUX
____________________________________________________________________________
11. Use cat to create a file named tailing.txt that contains the contents of tailing.txt
followed by the contents of /etc/passwd.
Ans : cat /etc/passwd >> tailing.txt
12. Use cat to create a file named tailing.txt that contains the contents of tailing.txt
preceded by the contents of /etc/passwd.
Ans : mv tailing.txt tmp.txt ; cat /etc/passwd tmp.txt > tailing.txt
A
PASSWORD CRACK MECHANISM : (in linux)
For crack the root password follow these steps -
R
➢ First of all, restart the machine.
➢ Then click the cursor in shown screen
➢ Press PgDn ↓ key
➢ Select first row through take cursor there
➢ Press e
➢ Go at initrd and press ←
➢ Type : rd.break
D
N
JE
➢ Press ctrl+x
➢ mount (for check file system)
A
G
26
LINUX
____________________________________________________________________________
➢ mount
➢ chroot /sysroot
➢ ls
➢ passwd
➢ Enter new password
➢ touch /.autorelabel
➢ exit
A
➢ exit
R
D
N
JE
A
G
27
LINUX
____________________________________________________________________________
BOOTING PROCESS :
A
R
D
N
JE
A
G
➢ Power on
28
LINUX
____________________________________________________________________________
➢ SMPS
➢ BIOS {Post (Power on self test)} / {USEP(More Secure)}
➢ Bootable device (Check)
➢ Bootable order 1. cd/dvd
2 .harddisk
3. pendrive
4. pxe.boot
➢ In hard drive
MBR(Master boot Recorder)
size = 512 kb
446 Byte is information of BOOT loader
A
64 byte information of Partition
2 byte information of MBR validation Check
➢ MBR >>> Bootloader
➢ Three BOOT LOADER
R
1.LILO (work on rhel <6)
2.GRUB (Linux and windows both )
3. GRUB2
➢
➢
D
Bootloader >>> Kernel >>extract>>initramfs>>extract>>initrd
kernel>>systemd{First program Start on Operating system )
systemd>>Default target >>Login Screen
init 0-6 (7 Targets)
N
➢ poweroff.target 0
➢ resuce.target 1
➢ emergency.target 2
➢ multiuser.target 3
JE
➢ Future Reserved 4
➢ Graphical.target 5
➢ reboot 6
29
LINUX
____________________________________________________________________________
A
R
D
N
JE
A
G
TYPES OF PROCESS :
➢ User process
➢ Kernel process
➢ Daemon process
1. USER PROCESS : (work : run the commands)
30
LINUX
____________________________________________________________________________
● Started by user
● End at task completion
● Foreground
● We can decide their behaviour at run time
● User space
● We can control and monitor
2. KERNEL PROCESS :
Kernel manages hardware resources of the operating system. It is the
heart of the OS.
● Started at boot time
● End at power off
A
● Background
● We cannot change their behaviour at run time
● Kernel space
● We cannot control and monitor this
R
3. DAEMON PROCESS :
● Also known as ghost process
● Started at host time
● End at power off
● Background D
● We can control their behaviour via config file
● We can control and monitor
N
JE
A
G
31
LINUX
____________________________________________________________________________
A
R
D
N
JE
A
Command :
● systemctl => to control daemon
● free -h => to check ram in machine (ram memory status)
G
➢ TTY —-----> TERMINAL ( terminal is a physical console from which a task is executed.)
➢ There are 7 types of physical terminals .
32
LINUX
____________________________________________________________________________
PROCESS MONITORING :
COMMANDS:
● ps =>check process run in current console
Here , PID = process id
A
TTY = console info.
TIME = running time of process
CMD = bash , pd ->process
R
● ps -aux => to listed every process in standard sequence
Here , VSI = virtual size (physical memory + swap memory)
MEM = memory
? ->means background process
start= staring time D
● ps -ef => list every process in bsd syntax.
Here , PPID = parent process id
C = CPU count
N
● pstree => to show process in tree syntax
● top => it gives the live output of process (it refresh within every 3 seconds)
In this command , shift + m => sort in memory shifting
JE
it called jobs )
● jobs => to list background commands / jobs
● fg %(jobs id) => to take the job in foreground
G
33
LINUX
____________________________________________________________________________
A
Many file systems are automatically mounted as part of the boot process.
If you have only worked with Microsoft Windows drive letters, this is a fundamentally different concept.
It is somewhat similar to the NTFS mounted folders feature.
R
File Systems, Storage, and Block Devices :
Low-level access to storage devices in Linux is provided by a special type of file called a block device
These block devices must be formatted with a file system before they can be mounted.
Block device files are stored in the /dev directory, along with other device files. Device files are created
D
automatically by the operating system. In Red Hat Enterprise Linux, the first SATA/PATA, SAS, SCSI, or
USB hard drive detected is called /dev/sda, the second is /dev/sdb, and so on. These names represent
the entire hard drive.
Other types of storage will have other forms of naming
N
Disk Partitions :
Normally, you do not make the entire storage device into one file system. Storage devices are typically
divided up into smaller chunks called partitions.
JE
Partitions allow you to compartmentalize a disk: the various partitions can be formatted with different
file systems or used for different purposes. For example, one partition can contain user home
directories while another can contain system data and logs. If a user fills up the home directory partition
with data, the system partition may still have space available.
Partitions are block devices in their own right. On SATA-attached storage, the first partition on the first
disk is /dev/sda1. The third partition on the second disk is /dev/sdb3, and so on. Paravirtualized storage
A
PARTITION :
Some basic commands:
● fdisk -l => to check partitions
● df -f => to show partition of linuX
● cat /proc/swaps
● cat /proc/partitions => to show all partitions
34
LINUX
____________________________________________________________________________
A
R
Letus take a example for make partition: D
● First we create an extra space hard disk in our machine by
● For better understanding please visit this link of practical video :
https://drive.google.com/file/d/1fPD5Ll7taBVOLzlYROWCyxHEGV_dT4EY/view?usp=shari
N
ng
● follow the following steps through photos
a. First go on machine name right click on mouse the go to setting then click on
JE
setting
A
G
b.
35
LINUX
____________________________________________________________________________
A
R
d.
D
e. Click on add for add new an extra hard disk than follow the instructions
N
JE
A
G
36
LINUX
____________________________________________________________________________
A
R
g. Than you can increase the hard disk size and Click on next
D
N
JE
A
G
37
LINUX
____________________________________________________________________________
A
R
D
2. Than create a partition so first type lsblk
N
JE
A
G
● fdisk /dev/sdb
● In that /dev/sdb type n for new partition
● Press e for extended partition
● Than press enter , than enter then type the size of new partition like +5G
● Then create a one more partition by pressing n
● Then press e
● Than press enter enter enter
● Than wq & enter like this:
38
LINUX
____________________________________________________________________________
A
R
D
N
● Than type lsblk for check hardware details and partitions also
● Like the partitions are Sda
↳sda1
JE
↳sda5
● mkfs.xfs /dev/sda5 => to format the partition sda5 like this
A
G
39
LINUX
____________________________________________________________________________
● mkdir gt
A
R
QUERY : When i create an extra partition by adding an extra hardware SATA drive then after
restart my machine this is reinstalling so what to do??
ANS: this time we should set default NVM harddrive from it’s booting setting for this please
visit this link and watch this video :
D
https://drive.google.com/file/d/1QVbMHODCJQfMXVmD2qxUmtTxNxeA76jg/view?usp=sharing
N
SWAP PARTITION :
JE
● For swap partition repeat the partition process AND when when we make a partition by
command fdisk /dev/sda that time in this
● we have to type l for the list of partition Hex code
● then press t for give partition type
● than enter then give the Hex code [ for swap partition the type the code 82 ]
● Than type command mkfs.xfs /dev/sda6
A
40
LINUX
____________________________________________________________________________
A
and the file system allowing file systems to be :
– resized and moved easily and online without requiring a system-wide outage.
– Using discontinuous space on disk
R
– meaningful names to volumes, rather than the usual cryptic device names.
– span multiple physical disks
D
N
JE
A
41
LINUX
____________________________________________________________________________
– VGs are made up of PVs, which in turn are made up of physical extents (PEs).
The size of PE can differe in different VGs and is defined at the time of creating VG.
– The default size of PE is 4MB, but you can change it to the value you want at the
A
time of VG creation.
– Generally, larger the PE size, better the performance (though less granular control
of LV).
R
Logical Volume (LV)
D
A Logical Volume is the conceptual equivalent of a disk partition in a non-LVM
system. Logical volumes are block devices which are created from the physical
extents present in the same volume group. You can use command lvcreate to create
N
a logical volume in an existing volume group.
File system
JE
File systems are built on top of logical volumes. The command mkfs can be used to create file
system on top of a logical volume. Once the file system is created we can mount the logical
volume as per our need.
A
2. /dev/pv3
3. Create a Volume group from these PVs (/dev/vg3).
4. Create a Logical Volume in this VG (/dev/vg3/lv3).
5. Create a File system on this LV and mount it (/data).
42
LINUX
____________________________________________________________________________
A
Steps for create lvm :
1. lsblk
2. fdisk /dev/sda
R
3. Than create 2 partitions and in last press t and thant type the Hex code 8e for
lvm
4. Than save it and quit it by wq
5. lsblk
6. fdisk -l
D
7. pvcreate /dev/sda5 => to create a pv(physical volume) partition
8. pvdisplay => to display created pv
N
9. vgcreate vg3 /dev/sda5 => to create a vg( volume group) partition
10. vgdisplay => to display created vg
11. lvcreate -L +2G -n lv3 vg3 => to create a lv(logical volume) partition of 2GB
JE
that
18. dd if=/dev/zero of=hi count=1000 bs=1M => copy the junk file hi in mnt
19. ll
20. dd if=/dev/zero of=hi1 count=2000 bs=1M
G
21. ll
22. lvextend -L +2G /dev/vg3/lv3 => after filling full space we extend the lv3 with
2GB size so now the size of lv3 is 4GB
23. lvdisplay
24. lsblk
43
LINUX
____________________________________________________________________________
YUM :
YELLOW DOG UPDATER & MODIFIER
YUM is the primary package management tool for installing, updating, removing, and
managing software packages in Red Hat Enterprise Linux. YUM performs
dependency resolution when installing, updating, and removing software packages.
YUM can manage packages from installed repositories in the system or from .
It is a helping tool which works on RPM .
It works on Repositories (collection of data) .
A
For full detailed notes please visit this link:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_admini
strators_guide/ch-yum
R
YUM commands :
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_g
uide/s1-yum-useful-commands
D
Some important commands of yum which are basically used :
● yum help => to Show yum subcommands and options
● yum list => displays installed and available packages.
N
● yum info PACKAGENAME => it used for detailed information about a package, including the
disk space needed for installation.
● yum install PACKAGENAME => obtains and installs a software package, including any
dependencies.
JE
● yum update PACKAGENAME => obtains and installs a newer version of the specified package,
including any dependencies.
● yum remove PACKAGENAME => removes an installed software package, including any
supported packages.
● yum list all => to List installed and available packages
● yum list installed => to List all installed packages.
A
● yum clean all => to Clean out all packages and meta data from cache.
● yum list updates => for check updates of repositories
● yum repolist all => command to list all repositories on the system
G
44
LINUX
____________________________________________________________________________
A
● Than we create a repository in /etc/yum.repos.d/ ,let i create a file repo g.repo
● vim /etc/yum.repos.d/g.repo
R
● Than add AppStream and BaseOS in that file with base url like this
● cp /s/g.repo /etc/yum.repos.d/
● Than install any package like i install httpd package
● yum install httpd
A
G
45
LINUX
____________________________________________________________________________
A
R
D
N
JE
A
In the new repository file we use gpgcheck . This gpgcheck is the command which is used to
G
verify the signature of a package's repository of a company for privacy or security purposes.
If we write gpgcheck=0 means it is un-enabled and means that it does not verify the sign.
If we write gpgcheck=1 that means it is enabled or at that time we have required a gpgkey
which is provided in public by the company . so we have to give the path of that key also.
The gpgkey of centOS is
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY.centosofficial
46
LINUX
____________________________________________________________________________
A
R
D
N
JE
A
G
47
LINUX
____________________________________________________________________________
A
R
D
N
JE
A
G
NETWORKING :
Network is a system of interconnected devices that can
communicate, share information and resources, such as files, printers, applications, and
Internet connection. Each of these devices has a unique Internet Protocol (IP) address to send
and receive messages between two or more devices using a set of rules called protocol.
48
LINUX
____________________________________________________________________________
A
OSI MODEL
( Open System Interconnection model )
R
D
N
JE
A
Physical layer :
It also defined the topologies , medium (what type of cabling we are
G
49
LINUX
____________________________________________________________________________
A
Internet → public network
Intranet → private network
There are 2 versions declared of IP that are = ipv4 & ipv6
R
Ipv6 is the new version .
We study about ipv4.
Ipv4 has 32 bit length
Ipv6 has 128 bit length.
● 1 bit have 2 unique address (0,1) D
● 2 bit have 4 unique address (00 , 01 , 10 , 11)
● 32 bits have 2^32 = 4294967296 unique addresses
N
IP ADDRESS :
JE
127.0.0.0
0.0.0.0
8 bit . 8 bit. 8 bit. 8 bit
0-255 . 0-255 .0-255. 0-255
G
50
LINUX
____________________________________________________________________________
A
R
D
N
IP address have 2 address : 1) network address
JE
2) host address
One network address have more / multiple host address
Network address may be same of machines but host address are different of every machine
A
G
51
LINUX
____________________________________________________________________________
We can’t use ip of one class in another class , to solve this limitation we use a concept which is called
CIDR (Classless Internet Domain Routing).
In this we can use IP of any range whether it is of any class.
Subnet :
It is used to divide ip address into network address and host address.
Ex : 255 . 255 . 0 . 0
A
R
which have mini. Values that show hosts add.
Example : 1.) 10.10.1.0 / 255.255.0.0
D
The obtact or sets of subnets which have max. Values are denoted network add. And the sets
N
Here 10.10 is the network add. And 1.0 is the host add. Of IP
2.) 10 . 0.1.0 / 255.0.0.0
Here 10 is the network add. And 0.1.0 is the host add.
JE
172.168.1.0 / 255.255.0.0
172.169.2.3 / 255.255.0.0 (or 16 )
Ans : both ip has different network address
5.) Do these two ip addresses have the same network/host address?
G
172.168.1.0 / 16
172.169.1.0 /16
Ans : both ip has different network address but same host address
255.0.0.0 = 8
255.255.0.0 = 16
255.255.255.0 = 24
52
LINUX
____________________________________________________________________________
A
R
D
N
JE
A
COMMANDS :
G
● For windows = ipconfig => to check how many interfaces we have available on
our machine. (it run in windows power shell or terminal)
● For linux = ifconfig => to check how many interfaces we have available on our
machine.
ip a s => to check how many interfaces we have available on our machine.
IMCP ( inter message control protocol ) => to send a message / to receive a message
We use IMCP by using ping command
ping => used for sending a request to check the connection.
Ex: ping www.google.com
53
LINUX
____________________________________________________________________________
ping 127.0.0.1
Q.1 : Who will build the network (or allocate the address)?
Ans : DHCP (Dynamic Host Control Protocol )
It is an application which is running on some particular device that provides the service
of the network.
This will create a network and assign a useful address to whatever device is connected to it.
We can set up different DHCP for different networks. DHCP configure everywhere.
DHCP → router , switch , machine
A
DHCP working process is called the DORA process .
R
FIREWALL :
● systemctl status firewalld.service
●
●
●
D
224 systemctl stop firewalld.service
225 systemctl start firewalld.service
226 firewall-cmd --list-all
N
● 227 firewall-cmd --add-port=2254/tcp
● 228 firewall-cmd --list-all
● 229 netstat -tulpn
● 230 firewall-cmd --list-all
JE
54
LINUX
____________________________________________________________________________
A
Commands:
● ip a show => for show the ip address of machine
● ssh (username)@(ipaddress) => for take remote control through ssh of any machine to
R
other machine
Ex: ssh [email protected]
D
N
JE
A
G
55