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

7 8 Rhcsa 16 04 2024 2

Uploaded by

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

7 8 Rhcsa 16 04 2024 2

Uploaded by

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

Redhat Version 9

RH 124
RH 134

Redhat Certified System Administrator(RHCSA)

Ex-200

210/300 duration 2 1/2 hours

RH 294

Redhat Certified Engineer (Ansible Automation)

Ex-300

210/300 duration 4 hours

1. Introduction to OS
2. Intorduction to Unix
3. Introduction Linux
4. Advantages of Linux
5. Os Insatlling

1. Introduction to OS

Operating System

Acts as an interface between user and system h/w/s/w.

2. History of Unix

Ken Thompson -B language

Dennis Ritchie -C lannguage

Unix OS -1969

Draw back of unix

1. Not an open source (paid code)

2. hardware Dependant

HP HP-ux 1984
Apple MAC oS 1984
IBM AIX 1986
Oracle solaris 1992

3. Introduction Linux

Tannenbaum -Helsinki University- MINIX operating Sytem

Torvalds - Linux-1991

Richard Stallman- GNU project


GNU(Genrally not Unix) Linux

4. Adantages of Linux

1) open Source
2) No need to pay
3) has full freedon to modify the source code an come up with own flavours
4) Handware Independant

Top Flavours of Linux

Novell SUSE linux 1992


Debian Debian 1993
Redhat RHEL/Fedora 1995
Centos Centos 1995
Kali linux Security puposes

Linux windows

free of Cost no free of cost


Developed under open source code management not developed by
open source its by microsoft
S/w and linceses were avalible free not available
free
no need to install anitivirus install virus
Developed under GPL linceses Enduser license
agreement

5. OS installing

8 GB Ram
Vm Workstation
Centos /redhat
===================================================================================
===================================================================================
===================================================================================
==============================================
Architecture of Linux

Terminal ===its a window to interact with shell.


Shell====It's a program where we can execute command ,scripted file and program
files.
Shell is an eniromment in which user can run commands, programs and scripted files.
Shell is a program that takes input or command from the keyboard and give it them
to OS.

#echo $SHELL ===command to know the default shell in linux


/bin/bash
#echo $0
-bash

Kernel==heart of the Operating system


acts as an bridge between hardware and software
Kernel makes the hardware to interact with the software to make specific task done.
Desides amount of resources used by all tasks.
.cpu
.memory
.disk
===================================================================================
===================================================================================
===================================================================================
========================================
Basic Understanding on Terminal Usage

[root@ip-172-31-83-234 ~]#

root ====> username


ip-172-31-83-234===hostname
~ =====present working directory (pwd)
#=== super user/admin user /root user

$====indicates you logged as a normal user

cd =====change directory

su - <user name> ====command to switch from one user to another user.


logout/exit === logout from the user

timedatectl ===to know the date and time on server


timedatectl list-timezones ===to list all the time zones
timedatectl set-timezone Asia/kolkata ===command to change the timezones
===================================================================================
===================================================================================
===================================================================================
=============================================================
File System Hierarchy

how files and directories are arranged in our Linux

/====parent directory.

/root===default home directory for root user.

/home ====default home directory for normal user.

/sbin===super user binary files.(commands inside this folder can be accessible only
by root user).

/bin =====noramal user binary files will be stored.

which <command name> =====to know a particular command in linux belongs to /bin
or /sbin

/tmp=====temporary files information will be stored .cache

/dev===device information will be stored. Ex hardisk

/media ====removable device information will be stroed : Ex : Pendrive

/run====temporary logs information will be stored.

/var===permananent logs information will bw stroed

/boot===bootloader information will be stored


/opt =====optional (third party packages information will be stored)

/usr=====man page infrmation(document files)

/lib===librarty files information (will be managed by os)

/proc ==all process information

/sys===system information will be stored

/mnt ===temporary mount file system

/etc ===configuration file information

redhat 7/8/9 ====default file system xfs


redhat 6 ====default file system ext4

===================================================================================
===================================================================================
===================================================================================
===================================================

#history ====command to list history of command executed so far

#date ====date and time will dispaly


#date +%R ====to know only the time
#date +%x ====to know only the date

===================================================================================
===================================================================================
===================================================================================
===================================================================================
==

Uname Command

#uname -r ====to know the current kernel version

#uname -i ====to know your hardware architecture

#uname -s ===to know your software name

# uname -o ===to know your OS

#uname -a =======to know complete information about your serer like kernel version
etc.
===================================================================================
===================================================================================
===================================================================================
===========================================
Free Command

#free -h =====to the kwnow the details about your RAM memory

===================================================================================
===================================================================================
===================================================================================
=============
Basic Commands

touch :

#touch <file Name>===to create an empty file


#touch f1 f2 f3 f4 f5 =====it create multiple empty files.
#touch redhat{1..10} ===to create multiple empty files.
#touch .<file name>===to create hidden file

===================================================================================
===================================================================================
===================================================================================
======================================================

cat command
creating a file, reading, adding and appending the content inside a file.

#cat <file name> ====to read the content in the file.


#cat ><file name>===to add content inside a file.

Note: if a file is not available , it will create automatically.

#cat >><File Name> ====to append the content inside a file.


I am Mona. Am learning linux

cntrl+d =====save and exit the file.


===================================================================================
===================================================================================
===================================================================================
=================================================
Copy

#cp <SF> <DF> ====copy the file

Move:

#mv <SF> <DF> ====move the file.

hidden file to normal file and normal to hidden file.

#mv .<file name> <file name>


#mv <file name> .<file name>

Renaming a file

#mv <SF> <DF>===to ranme your file

to remove a file

#rm <file name>

#rm -f f1 f2 f3 f4

#rm -f redhat{4..6}
===================================================================================
===================================================================================
===================================================================================
==========================================================================
Directories:

make directory command:

#mkdir <directory name> to create empty directory

#mkdir d1 d2 d3 d4 ===to create multiple empty directory

#mkdir folder{1..10} ===to create multiple directories at a same time.

#mkdir .<directory name> ==to create empty hidden directory

#mkdir /testdir ===to create a directory under parent.

#mkdir testdir1 ====to create a dir under pwd

#mkdir -p /redhat/rhcsa/rhce/devops/ansible/docker ====to create multiple sub


directories in linux

Path:

unique location to the file or directories in your file system.

1. Absolute path

cd /redhat/rhcsa/anisble/devops/rhel

2. Relative path

#cd /redhat
#ls
#cd /rhcsa

cd ..=====to goto previous working directory


cd ../..====to goto previous to previous working directory

Copy a dir:

#cp -rf <SD> <DD> ===to copy a directory


r=recursive

Move a dir:

#mv <SD> <DD> ===to move a directory

hidden dir to normal dir and normal to hidden

#mv .<dir name> <dir name>

#mv <dir name> .<dir name>

Renaming a Dir

#mv <SD> <DD> ===to rename a directory.

Remove Directory

#rm -rf <directory name> ===to remove a directory


===================================================================================
===================================================================================
===================================================================================
============================================================
ls listing command

#ls ====to list all f/d under pwd


#ls <directory name> ==to list all the f/d under any specific directory
#ls -l==== to list all the files/directories along with its permissions.
#ls -l <dir> ====to list all f/d along with its permission in a specfic directory.
#l.======to know the hidden f/d details under pwd.
# l -a =======to know the hidden/normal f/d details under pwd.
#ls -i========to know inode number for f/d
#ls -R <directory >=====to list the directories in tree structure.
#ls -lt===to list all f/d along with its permissions along with time details in
ascending order.
#ls -ltr====to list all f/d along with its permissions along with time details in
descending order.
# ls -lh =====to list all f/d along with its permissions along with time details
with size in a human readbale format
===================================================================================
===================================================================================
===================================================================================
==========================================================================

Inode Number

1st part : conatins complete information about a file and directory like owner,
permissions, size
2nd part : block number where f/d resides
#ls -i <file name /dirctory name>
===================================================================================
===================================================================================
===================================================================================
====================================================

df command

disk free space to know the file system along with its size details.

#df ===to know the list of files system along with its size details
#df -h===to know the list of files system along with its size details in human
readable language
#df -Th====to know the list of files system along with its size details with type
of file system
#df -i=====to the inode numbder details in your file system.

===================================================================================
===================================================================================
===================================================================================
======================================================================
du command
disk usage details of an y file or directories will be identified.

#du -s <f/d>=====to know the disk usage of any f/d


#du -sh <f/d>===to know the disk usage of any f/d un hunam readable format
===================================================================================
===================================================================================
===================================================================================
==============================================================================
VIM Editor

Visual editor improved

Edditor =====to edit a file

CLI Command Line Interface Vim


GUI Graphical USer Interface gedit (ex: notepad in windows)

VIM :

1. Insert Mode
2. Command Mode
3. collon Mode

Insert Mode:

#cat /etc/passwd
#vim /etc/passwd

i =====to go to insert mode


Esc ===to come back to normal mode from any mode

shift+4 ====to goto end of the line


shift+6====to go to begining of the line.

Command Mode:

G===to go to bottom of the file


gg==to go to top of the file
o===to create a new empty line next to your cursor position.
O===to create a new wmpty line before to your cursor position.
yw ===to copy word from CP.
p===to paste the word next to the CP.
P===to paste the word beofre to the CP.
dd===to delete the single line from the CP.
u====undo the changes
cntrl+r ===redo the changes
dw====to delete a word from the CP.

Collon Mode

shift+Esc+:===to go to the collon mode


:/<keyword>====to search for a specific key word in a file
n to jump to next searched word location in clock wise
N anti-clockwise
:set nu ====to set the line numbers in a file
:set nonu ====to remoe line numbers in a file
:10 co 20 ====to copy and paste single line
:10,11 co 39====to copy and paste multiple lines
:40d ===to delete single line
:39,40d ===to dlete multiple lines
:q ====quit without saving the file
:q!=====forecfull quit and exit from the file
:w ===save the file
:wq ===save and exit
:wq!====save and quit forcefully.
===================================================================================
===================================================================================
===================================================================================
===================================================================================
======
User and Group Management

User?

the one who uses the system is called user.


each and every user will be having user name and UID

username ----human refernce


UID Kernel refernce
By default (0-999) id will be reserved for kernel.

Main configuration File : vim /etc/login.defs

#vim /etc/passwd======complete user informations will be stored


#vim /etc/shadow=====complete user password related information will be stored.

Types of user and information is shared in group in excel sheet

1. Super user/Admin User/root user


2. Normal user
3. Sudo User
4. Network user

Commands for users:

#useradd <UN> ===to create a new user

#id <UN> or vim /etc/passwd or getent passwd <UN> ===to know wether the user is
created or not

#passwd <UN> ====to assign the password to the user.


===================================================================================
===================================================================================
===================================================================================
===================================================================================
===============
From root we can login to any user without password.
From normal user we cant able to login to any user without password

#su - <UN> ===to login to specific user


#exit or logout ====to logout from the user

What are the Enivronmental files for users?

.bash_logout === exit or logout


.bash_profile =======su -<UN>
.bashrc ===umask value details will be there
.bash_history====command history details will be saved.
===================================================================================
===================================================================================
===================================================================================
===================================================================================
=============
# usermod -u <new user id> <UN> ===to change the UID of user

#usermod -g <new group id > <UN> ====to change the GID of User

#usermod -c <new comment> <UN>===to add the comments for the user.

usermod -m -d <new home directory> <UN> to change the home directory of the user.

#usermod -s <new shell> <UN> ===to cahnge the new shell

#usermod -l <new name> <UN> ===to rename the user name

#userdel -r <UN> ===to delete the user.


===================================================================================
===================================================================================
===================================================================================
===================================================================================
=============================
Explaination for /etc/passwd file

pranay:x:1002:1002::/home/pranay:/bin/bash

Pranay ===user name


x ===== lint to etc/shadow file
1002 ====user id (u)
1002 ====group id (g)
::======GECOS area General Electric Comphrensie OS (Comment Section) (c)
/home/pranay ====default home directory (d)
/bin/bash===default shell (s)

===================================================================================
===================================================================================
===================================================================================
===================================================================================
=========================================
Group

Collection of users is called group. Each and every group will be having GID and
group name.

Group name is for human refernce


Group ID for Kernel Refernce
By default (0-999) id will be reserved for kernel.

Two types of Groups:

1) primary group
whenever we are creating an user with same name one group also will be created
because each and every user needs to be part of a primary group.
2) Secondary group
It will not create automatically as a admin we need to create and we can add any
number of users into the group.

Config File:

vim /etc/group ===complete group infomations will be stored


vim /etc/gshadow===group password information will be stored.
Commands

#groupadd <GN> ===command to create a group

#vim /etc/group or getent group <GN> ===to know wether the group created or not

#gpasswd <GN> ====to assign the password for your group

#groupmod -g <new GID> <GN> ====to chnage the group ID

#groupmod - n <new group name> <old group name>===to rename the group name

#gpasswd -a <UN> <GN> ===to add the single use into group

#gpasswd -M u1,u2,u3,u4,u5 <GN> ===to add the multiple users in to a group

#gpasswd -A <UN> <GN> ===to assign the admin access to a specific user in a group

how to validate admin previllage

#su - <UN>
#newgrp <GN> ===to login to the group
#gpasswd -a <UN> <GN>
#gpasswd -d <UN> <GN>

#gpasswd -d <UN> <GN> ===to remove single user from a group

#groupdel <GN> ===to dlete the group.


===================================================================================
===================================================================================
===================================================================================
===================================================================================
===========================================================
Explaination for /etc/group

group1:x:1002:u1,u2,u3,u4

group1 ===group name


x ===link to etc/gshadoww file
1002 ===group id (g)
u1,u2,u3,u4 ====user details
===================================================================================
===================================================================================
===================================================================================
=============================================================================

Explaination for /etc/gshadow

group1:$6$QyvOwjER/KWGs7p3$76M1wboFZ1nkTX52bZURdfRqvtPM9yVlZJMDnnKv8s/
aozg8iTSV2jujlCqcAPWeP2bPish7dnIn0FLNxfVm11::u1,u2,u3,karthik (not assigned admin
previllage)

group1:$6$QyvOwjER/KWGs7p3$76M1wboFZ1nkTX52bZURdfRqvtPM9yVlZJMDnnKv8s/
aozg8iTSV2jujlCqcAPWeP2bPish7dnIn0FLNxfVm11:karthik:u1,u2,u3,karthik(assigned admin
previllage)

group1 ==group name


$6$QyvOwjER/KWGs7p3$76M1wboFZ1nkTX52bZURdfRqvtPM9yVlZJMDnnKv8s/
aozg8iTSV2jujlCqcAPWeP2bPish7dnIn0FLNxfVm11 ======groups encypted password
: : === username will display incase if you have assigned admin previllage
u1,u2,u3,karthik ===user details
===================================================================================
===================================================================================
===================================================================================
===================================================================================
===============
Explaination for etc/shadow

u1:$6$MUtfcPn.GxQqfUNs$kwYbt6QP5CJpJTT88YDK/
jcqQqEIXTRV80BSuHel32dHdgiQbGM4T7cwmV7EP54YvokxgS50UDTLNLNly/IYh/
$6$MUtfcPn.GxQqfUNs$kwYbt6QP5CJpJTT88YDK/
jcqQqEIXTRV80BSuHel32dHdgiQbGM4T7cwmV7EP54YvokxgS50UDTLNLNly/
IYh/:19842:0:90:7:40:20:

u1===user name

$6$MU ====encryted password

19842 === last password chnage date(these dates are calculated from unix origin
date (01/01/1970)

0=====minimum number of days we need to wait for changing the password to the user

90====maximum number of days before that we must and should need to change the
password to the user

7=== warning days

40===inactive days

20===expire days

#chage <UN> to see all the password aging parameters to th user.

Minimum Password Age [0]: 1


Maximum Password Age [99999]: 90
Last Password Change (YYYY-MM-DD) [2024-04-29]:
Password Expiration Warning [7]: 10
Password Inactive [-1]: 2
Account Expiration Date (YYYY-MM-DD) [-1]: 2024-09-29

#chage <UN> (to check the updated details)

Minimum Password Age [1]:


Maximum Password Age [90]:
Last Password Change (YYYY-MM-DD) [2024-04-29]:
Password Expiration Warning [10]:
Password Inactive [2]:
Account Expiration Date (YYYY-MM-DD) [2024-09-29]: -1

===================================================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
Umask ====User Mask Value
to protect our file and directories
#umask ====command to know the mask value

File Directory
read r 4 #cat <FN>
#vim <FN> #ls
write w 2 # cat ><FN> #cat >>FN #touch #mkdir
execute x 1 by defualt file wont have execute permissions #cd
Script file

The maximum permsision for a file is 666.


The maximum permission for a directory is 777.

The default umask value for the root user is 022.


The default umask value for the normal user is 002.

The default permission of a file is 644


The default permission of a directory is 755.

How to change the umask value?

temorary

#umask 044
#umask

permanent(reboot required)

#vim /etc/proifle (globally chnages will be applicable for all the normal users)

: 60 normal user
: 62 root user

#wq!

#source /etc/profile without reboot to change the value

How to change the umask value for a dpecific user

#su - <UN>
#vim .bashrc
umask 033
:wq!

#source .bashrc
===================================================================================
===================================================================================
===================================================================================
===================================================================================
====================================================================

chmod

changing modifications (permissions) to file and directories.

1. Absolute mode Numerics

2. Symoblic Mode --alphabets and special characters


Absolute mode

r=4
w=2
x=1

#touch f1
-rw-r--r--

#chmod 666 f1
-rw-rw-rw-

How to validate?

1. Login to any normal user #su -<UN>


2. Change to the directory where file located #cd /
3. check wether you have desired permission on to the file or not
*to check read # cat <FN>
*to check write # cat >><FN>

# mkdir /newdir7
# ls -ld /newdir7
drwxr-xr-x

#chmod 757 /newdir7


# ls -ld /newdir7
drwxr-xrwx

1. Login to any normal user su - UN


2. change to the directory # cd /newdir7
3. check whether you have desired permission on to the directory or not
* ls command to check read permission in a directory
* touch/mkdir to check whether write permission is there or not
* cd to check execute permission is there or not

Symbolic mode

read(r),write(w),execute(x)
user(u),group(g),others(o)
add(+),remove(-),exact set(=)

#chmod g+w,o-r /dir11

#chmod u+w,o-w /file10

#chmod u=rwx,g=rw,o=r /f/d

===================================================================================
===================================================================================
===================================================================================
=================================================================
Access Control List

used for providing customized permssion to a specific user and group.

#getfacl <f/d> ===to know the default ACL permsision of a file/directory

#setfacl -m u:<UN>:<permission>,u:<UN>:<permission> <file name>


#setfacl -m g:<GN>:<permission>g:<GN>:<permission> <file name>

#setfacl -m o::<permission> <file name>

setfacl ====settting file access control list

getfacl ===getting file access control list

m==modify

#getfacl <f/d> ===to know the default ACL permsision of a file/directory

#setfacl -R -m u:<UN>:<permission>,u:<UN>:<permission> <directory name>

#setfacl -R -m g:<GN>:<permission>g:<GN>:<permission> <directory name>

#setfacl -R -m o::<permission> <directory name>

#setfacl -x u:<UN>,g:<GN> <f/d> ==to remove the acl permission from a particular
user or groupon a file or directory

#setfacl -b <f/d> ===to remove complete acl permission for f/d.


===================================================================================
===================================================================================
===================================================================================
===================================================================================
============================================
Changing Ownership and groupownership

#touch file1

#ls -l file1

-rw-r--r-- root root


karthik
#chown <new owner name> <file name> ====to change the owner of the file

#ls -l file1

-rw-r--r-- karthik root

#mkdir dir1

#ls -ld dir1

-rw-r--r-- root root


karthik
#chown <new owner name> <directory name> ====to change the owner of the directory

#ls -l file1

drwxr-xr-x karthik root

Changing the group ownership


sales
#groupadd <GN>
#useradd u1
#useradd u2
#useradd u3
#gpasswd -M u1,u2,u3 <GN>

#mkdir dir10
#ls -ld /dir10
drwxr-xr-x root root

#chgrp -R <sales> /dir10 ===to chnage group owner of the dir

#ls -ld /dir10

drwxr-xr-x root sales

#chmod g+w sales


#ls -ld /dir10

drwxrwxr-x root sales

===================================================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
==========================
Sudo Users

normal user with root priviliges.that normal user can do everything as lokie root
user he can access all the commands from /sbin folder as well.

#vim /etc/sudoers
line 100

pranay ALL(ALL) ALL === assign sudo permssion with password


vipin ALL=(ALL) NOPASSWD: ALL ===assign sudo permssion without asking for the
password
madhura ALL=(ALL0 NOPASSWD: /sbin/useradd,/sbin/groupadd ===to assign specfic
root user cammands
%groupname ALL=(ALL) ALL ===entier group will have access to root user commands
%groupname ALL=(ALL) NOPASSWD: /sbin/groupadd ===allowing group to access one
sing command of root user

#sudo useradd <UN> ===to create a user

wheel ====group where we can add the list of users to get the suod priviliges.

===================================================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
====
Special permission

1. suid ===setting user id


2. guid ====setting group id
3.. sticky bit

suid:
if we plan to allow all the users to execute the root command then we need to go
for suid. it is apllicable only for files.

sudo ===one normal user where we applying sudo previliges can able to access all
the root user commands.

suid =====one root user command can be accessed by all.


useradd(suid) ---this useradd command will be executed by all normal users.

#chmod u+s /sbin/useradd


#ls -l /sbn/useradd

-rwsrw-r-- root root /sbin/useradd

#chmod u-s /sbin/useradd

-rw-rw-r-- root root /sbin/useradd

s indicates suid has been successfully applied.

sgid

if we plan to allow all the users of the group to get the complete group ownership
permissions then we need to apply sgid.It will be appplicable directories.

#mkdir folder1

#ls -ld folder1

drwxrwsr-x

#chmod g+s /folder1 ===to assign the special permission for a folder
#chmod g-s /folder1 ===to remove the special permisssion for a folder

Sticky bit

it protects the data from other users when all the users are having full
permissions on one directory.

#chmod o+t /folder1 === to apply the sticky bit


t ==indicates sticky bit is applied

#chmod o-t /folder1 ===to remove the sticky bit

Task
1. create a folder name "accounts
2. create a group called "sales"
3. you need to create 5 users , userA userB userC userD
4. add these 4 users under sales group
5. apply sgid to accounts directory
6. you need to apply sticky bit to acounts directory
7. userA has to create a file under acounts directoy -file1
8. userB has to create a file under acounts directoy -file2
9. UserD had to enter the content inside a file1 under accounts directory
10.UserE has to append the content inside a file2.
===================================================================================
===================================================================================
===========================================================================
Partitions

What is partition?

diving one hard disk drive into multiple logical drives is called partition.

why we need to create partion?

1. orgnaizing the data is much easier


2. your data is less likely to be affected
3. increased performance
4. opportuning to use multiple os.

Types of Disk.

hda/hdb ===IDE integrated Disk Elctronics, PATA Parallel added Technology


Attachment
sda/sdb ====SATA Serial added technolgy attachment
vda/vdb==== virtual hard disk

#fsdisk -l to see the of available devices along its space details.

#lsblk ======to list all the available block devices.

#fdisk /dev/nvme0n2

:m help
:n new partition
:p or e enter for the default
:1 to 4 enter default
:1st sector eneter for default
:last sector +500M or +1G
:p print the part table
:w save and exit

#partprobe or udevadm settle ===to update the kernel about the part table changes.

File System:

1 block ===4096 bytes


1 block ===8 sectors
each sector =512 bytes

The method of storing the data in to the disk and retriving the data out from the
disk is called file system. After assinging the file system your kernel will start
performing the read and write operations.

disk without file system is called as raw device


disk with file system is called as block device.

xfs /de/nvme0n2p1
#mkfs -t <file system type> <device name> ====to assing the file system

Mounting:

attaching the partition to a directory under root is called mounting


Temprorary Mounting

1st we will create one directory and mount the partition on the directory.But this
type of mounting will last till system reboot.

#mkdir /mount =====local moint point

#mount <device name> <local mount point name>

#blkid ====to know the UUID for the parttions

UUID ====universal unique identifier

Permenanet Mounting

1st we will create on directory and mount the partition on the directory. This type
of mounting will be available after reboot.

#vim /etc/fstab

UUID or /dev/device name <local mount point> <file system type> <mount options>
<file system dump> <file system check>
/dev/nvme0n2p2 /mount xfs defaults
0/1 0/1/2

:wq!

#mount -a ===to mount all the entries in fstab

#partprobe

File System check:

to convert the file system from inconsistent state to consistent stae we will use
file systm check.

redhat 6 ===ext4
redhat 7,8,9 ===xfs

Disk Operating System :MBR partition table will be used and using it we can create
4 partitions

3 primary
1 extented ======11 logical partitions

if we are used MBR as a partition table we can create maximum 15 parttions

Primary ===its a partition MBR will recognize at the time of booting. OS will
files will be stored here.

Extended partition ===its container for your logical paartitions.MBR will not
recognize the os files stored in it.

last sector :enter for default


only then remaining complete available space will be allocated from extended
partition.
how to delete partition?

1. umount the file system

#umount <mount point options>

2. remove the entries from fstab

#vim /etc/fstab

#fdisk /dev/nvme0n2

:p print the part table


:d dlete the partition
:1 to 4
: 1 ist part will be deleted
:w save and exit

#udevadmm settle or partprobe ====to update the kernel


===================================================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
==
Swap Partition

#fdsik -l ===to see th list of aailable devices along its space details.
#lsblk ===to list all the available block devices

#fdisk /dev/nvme0n2

:m help
:n new partition
:p or e enter for the default
:1 to 4 eneter for the default
:1st sector enter for the default
:last sector +4G or +500M
:t chnage the partition system ID
:L hex code 82 is for swap
:p prin the part table
:w save and exit

#partprobe or udevadm settle ===to update the kernel about the part table chnages.

Assinging the file system

#mkswap /dev/nvme0n2p1

Mounting

#vim /etc/fstab

/dev/nvem0np1 swap swap defaults


1 1
<device name> or UUID <local mount point> <file system type> <mount options> <file
system dump> <file system check>
:wq!

#swapon -a ===to activate all the swap partitions


#swapon -s ===to see the swap space details
#free -h =====RAM and SWAP memory space it display

How to delete the swap partition:

1.#swapoff -a ====to deactivate complete swap partition


1.#swapoff -a /dev/nvme0np1 ===to deactiate specific swap partition
2. delete the entry from fstab
3. #fdisk /dev/nvme0n2
:p print the partition table
:d delete the partition
:1 to 4
:1 1st part will be deleted
:w save and exit

#partprobe or udevadm settle ===to update the kernel about the part table changes.

===================================================================================
===================================================================================
===================================================================================
======

LVM
Logical Volume Manager

What is LVM?

The combination of one more phyiscal volume in order to form a big disck is called
LVM.

Main objectives of LVM

1. to increase the size of the file system on demand


2. to decrease the size of the file system on demand
3. to increase the file system performance.
4. to increase the file system availbilty.

Components of LVM:

1. Physical Volume ---PV

whenever a normal linux partition is coming under the control of LVM is called PV.
Each and Every Pv will be having UUID and LVM lable

2. volume Group ----VG

Collection of phisical volume is called volume group. If you want to create a


volume group minimum 1 physical volume is required. Same p cannot be a part of
multiple vg.

3. Logical volume ===LV

device created using free space available from one or more physical volumes.LVM
size cam be resized
4. Extent

it is the smallest area where we can store the data in to groups.

a. physical Extent --PE

every pv is equllay divided in to multiple sub partitions is called PE. the defaut
size of your PE is 4MB

b.Logical Extent -LE

every logical volume is equllay divided into multilpe no of sub partitions is


called LE. The default size of the logical extent is depends on the PE.

Steps for creating LVM partitions:

1. three normal linux partitions

2. Crete PV
#pvcreate <device name> <device name> <device name> ====to create physical volume

#pvs ===to check pv created or not

#pvdisplay== to check the complete details of pv

3.create the Vg

# vgcreate <vgname> <pv details> <pv details> ===to create vg

#vgs ===to check vg created or not

#vgdisplay ====to check the complete details of vg

#vgextend <vgname> <pv details> ===to extend the vg

#vgreduce <vg name> <pv details> === to reduce the size of vg

4. Create LV
+400M
#lvcreate -n <name of lv> -L <size of LV> <vg name> =====to create lv by using
size

100
#lvcraete -n <name of the lv> -l <no of extents> <vg name> ===to create lv by using
extents

#lvs ===to knw wether the lv is created or not

#lvdisplay ====to know more info about lvm

5. assign file system


ext4 /dev/vg1/lv1
# mkfs -t <file system type> <lv path> ===== to assign the file
system
6. create local mount point
# mkdir /lvm
7. mounting in /etc/fstab file
# vim /etc/fstab
<device name> <local mount name> <file system type> <mount
options> file system dump at the time of rebooting file system
check
/dev/vg1/lv1 /lvm ext4 defaults 1
1
:wq!
# mount -a === to mount all the entries in fstab.
8. how to increase the LVM size
grow in # lvextend --resizefs -L +400M /dev/vg1/lv1 === to extend the lv by using
growin method
growby # lvextend --resizefs -L 800M /dev/vg1/lv1 -====to extend the lv by using
growby method
# resize2fs /dev/vg1/lv1 if ext4 f/s
# xfs_growfs /dev/vg1/lv1 if xfs f/s

Task
9. how to decrease the LVM size. Assign the system

shrin in -200M
shrink by 600M

10. how to delete LVM Partition

1. umount the file system

#umount /lvm

2. remove the entry from fstab

#vim /etc/fstab

3. remove lv

#lvremove <lv path>

4. vg remove

#vgremove <vgname>

5. pvremove

#pvremove <device name> <deice name> <device name>

6. Remove the parttitions

#fdisk /dev/device name


:p print the part table
:d delete the parttion
:1 to 4
:1 1st part will be delete
:w save and exit

#pratprobe

===================================================================================
===================================================================================
===================================================================================
=================================================
Port Numbers

HTTP 80
FTP (for connection) 21
POP3 110
SSH 22
NTP 123
Telnet 23
LDAP 389
Send mail or postfix 25
Log Server 514
DNS 53
DHCP (for server) 67
DHCP (for client) 68
NFS 2049
MySQL 3306
===================================================================================
===================================================================================
===================================================================================
============================================================================

Booting Process

RH-342 Ex 342

MBR parititon table 3 p 1 e

SMPS Switch Mode Power Supply


for regulating voltage supply
|
|
BIOS Basic Input/Output System
it will pick the os files
|
|
POST Power On Self Test
to test all the hardware functionalities(like keyboard,
mouse, RAM , HDD etc)
|
|
MBR Master Boot Record
Primary Boot Loader
size of the MBR 512bytes 446B--- primary bootloader information(os
files), 64B -partition information and 2B - MBR validation check
|
|
GRUB2 Grand Unified Bootloader - Secondary Boot Loader
/etc/grub2.cfg or /boot/grub2/grub.cfg
|
|
initrd initial ram disk//// initramfs - initial RAM file
system
sysroot ===temporary root filesystem(read only operation)
in this stage your root file system will be temporarily mounted on
sysroot with read only operation
|
|
kernel
it will permanently mount root file system under / with rw
operation
|
|
systemd 1st process starting in your server
it will look into /etc/fstab file and mount all the file system
after executing file system check
then it will look into /etc/systemd/system/default.target to
select the default target (to know whether the system to start in GUI or CLI)
|
|
starts the services
|
|
Login Prompt

To check the error and troubleshoot

#journalctl -p err
===================================================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
====
Services or Daemon:

Serive or deamon is program that states at background and continuously run in the
background.

Daemon ===the process which is running in the back ground is called daemon.

Services ====collection of process.

Process systemd PID 1.

temp:

#service <service name> start /stop/restart ===service will continously run till
the machine reboots/after reboot service will gointo inactive mode.Stopped
state.again if need

#systemctl start <service name> ====temp we need to start it manually.

#systemctl enable <Service Name> ==perm

Permananently

#chkconfig <service name> on ====serice will automatically starts on every reboot


becuase we are start serice permanently.

#chkconfig <service name> off

#vim /etc/init.d ===is the loaction for all the services.

#cd /usr/lib/systemd/system ---is the loaction for all the services.

yum install httpd -y ===to install the httpd service


#systemctl status <service name> ====to know the status of service

How to launch a simple website

1.# cd /var/www/html
2.# cat >>index.html
"Welcome to apache Webserver"

3. systemctl restart <service name> ===to restart the service


#systemctl status <service name> ====to know the status of service it will active
and running.

4. paste your ip in the brwoser and check if the website is launched


or
5. curl loacl host or #curl -v http://ipaddress

#firewall-cmd --permanent --add-port=80/tcp

#firewall-cmd --reload

#systemctl enable service name ====to start the service permanently

#systemctl list-units --type=service --state=inactive ===to list all the ervices


which is inactive state
#systemctl list-units --type=service --state=active ===to list all the ervices
which is active state

# systemctl start <service name> === to start the service temp


# systemctl enable <service name> === to start the service permanently
# systemctl restart <service name> ==== to restart the service
# systemctl stop <service name> ==== to stop the service
# systemctl status <service name> === to know the stattus of the service
# systemctl list-units --type=service === to list all the services

Ex:
1. yum install httpd -y
2. systemctl start httpd
3. systemctl status httpd running
4. do server reboot
5. systemctl status httpd inactive dead
7. systemctl start httpd
8. systemctl enable httpd running
9. do server reboot
10. systemctl status httpd running

===================================================================================
===================================================================================
===================================================================================
===================================================================================
==================================================================

Targets

System State

#systemctl get-default ===to know the default target

temproray
#systemctl isloate graphical.target ===to change the target from CLI to GUI

#systemctl isloate multi-user.target ===to change the target from CLI to GUI

Permanent

#systemctl set-default graphical.target ==to change the target from CLI to GUI

#systemctl set-default multi-user.target===to change the target from CLI to GUI

Note: permanent changes will work only after reboot

#systemctl isolate reboot.target ===to reboot the server


#systemctl isloate poweroff.target ===to shutdown the server

#who -r =====to know which run level we are using

#vim /etc/inittab ===runlevel configuration file

runlevel 0 init 0 shutdown


runlevel 1 init 1 single usermode
runlevel 2 init 2 multi user mode without network
runlevel 3 init 3 multi user mode with networking CLI
runlevel 4 init 4 not detremined
runlevel 5 init 5 multi user mode in GUI
runlevel 6 init 6 reboot
===================================================================================
===================================================================================
===================================================================================
===================================================================================
===============
Package Management

what is software?
Software is a collection of programs to perform some tasks or manage systems,
applications, databases ,...etc.,

what is package?
collection of software

what is package management?


Package management means installing, updating, querying, repairing and removing
packages.

two types of tools in linux


1. RPM Redhat Package Manager
2. YUM YellowDog Update Manager

RPM
1. it will not resolve dependencies automatically.
2. whenever we need to install any package we need to give complete location
where the package downloaded.
3. no configuration file.
httpd
# rpm -ivh <package name> --nodeps === to install the package
i == install
v == verbose
h == hashcode
# rpm -q <package name> == to know whether package is installed or not
# rpm -qa = to list all the installed packagaes
# rpm -qa | wc -l = count of packages installed
# rpm -e <PN> --nodeps = to remove the package
# rpm -qR <PN> == to know the dependencies required for installing a package.

YUM:
1. Packages are downloaded from collections called repositories, which may
be online, on a network and or on installation media(iso).
2. it will resolve dependencies autoamtically
3. no need to give complete path for installing packages.

# vim /etc/yum.conf = main configuration file for yum


# cd /etc/yum.repos.d ==directory that contains repo configuration file.
# vim <anyname>.repo == yum repository config file.
# vim /var/log/yum.log ====yum log file location.

1. # cd /etc/yum.repos.d

2. # vim AppStream.repo
[appstream] = repo id (name should not contain any special character only alphabets
and numbers are allowed
name = appstream repo
enabled = 1 1=repo will be enabled 0=repo will be disabled
gpgcheck = 1 0==key check will be disabled 1=key check will be enabled
baseurl = file:///iso/AppStream

[baseos] = repo id (name should not contain any special character only alphabets
and numbers are allowed
name = baseos repo
enabled = 1 1=repo will be enabled 0=repo will be disabled
gpgcheck = 0 0==key check will be disabled 1=key check will be enabled
gpgurl=? if required
baseurl = file:///iso/BaseOS

:wq!

# yum clean all === to clear yum cache


# yum repolist = to list only the active repo
# yum repolist all == to list all the repo's

https://access.redhat.com/solutions/10021

# yum install <PN> -y ==== to install the package


# yum info <PN> === to know whether the package is installed or not
# yum list installed | grep <PN> === to list all the installed packages
# yum search <PN> === to know whether the specific package present in a repo or not
# yum erase/remove <pn> -y === to remove the package.
# yum history === to list recently installed packages
# yum history info <id> === to display info about that id
# yum update <PN> ==== to update a specific package
# yum downgrade <pn> === to downgrade the package to previous version
# yum update ==== to update complete repo.?

===================================================================================
===================================================================================
===================================================================================
===================================================================================
==================================
Job Scheduling

The process of creating the jobs and make them occur on the sytem repeatedly
hourly, weekly, daily,monthly and yearly is called job scheduling.

in linux and other Unix systems this process is handled by the cron serice and
deamon called crod and atd jobs deamon which can be used to schedule the tasks(also
called jobs)

1. at job

1) at jobs are executes only once


2)Here also we cannot get the information if the job is failed and it is laos do
not execute the failed jobs automatially.

2. cron job

1)Cron jobs are scheduling jobs automatically at a particalur time, day, month and
year.
2)the job may be afile or filesystem
3) we caannot get the information if the job is failed and it is laos do not
execute the failed jobs automatially.

two tyes:

1)at job
2)cron job

at:

1. at job executes only once.


2. no repetation of jobs is possible
3. we cannot get the information as a log file if the job is failed to execute
and, when it was failed cannot execute the failed jobs automatially.
4. no log file
5. cannot modify the scheduled job

#at now ======to make a job to run immediatley


#at noon ===to schedule a job at afternoon 12
#at midnight ====to schedule a job at night 12 am
#at 06 :30 Am ====specific
#at teatime ====at 4pm
#at Jul 15 2024 ======specific date
#at 23:10Pm Dec 31 2024 ===specfic time and date
#at -l ======to list all the at jobs
#atrm <job id> ====to remove at job

how to allow or deny the users from scheduling the at jobs.

#vim /etc/at.allow
#vim /etc/at.deny

Cron:

1. creating the jobs and make them occur on the sytem repeatedly hourly, weekly,
daily,monthly and yearly
2. the job may be file or file system
3. we cannot get the information as a log file if the job is failed to execute and,
when it was failed cannot execute the failed jobs automatially.
4. log files is available
5. we can modify the scheduled jobs

#vim /etc/crontab ====main config file hwich stores all the cronjobs
#vim /var/log/cron ====log file location

Service :crond

#crontab -e ===to schedule a new corn job

mins hours day of the month month of the year day of the week
task to be executed
(0-59) (0-23) (1-31) (1-12) (0-7)
touch file{1..10}
20 08 31 5 5
mkdir /test
10,20 08,09 25,31 1,12 * tar
cvf etc.tar
10-30 11-20 10-15 1-12 *
tar cvf etc.tar
*/2 */1 */10 */12 */4
tar cvf etc.tar
* * * * *
tar cvf etc.tar
4 special characters

*asterik
/ division
- hyphan
, comma

how to allow or deny the users from scheduling the at jobs.

#vim /etc/cron.allow
#vim /etc/cron.deny

===================================================================================
===================================================================================
===================================================================================
===============================================================================

Backup and Archive


What is backup and what is purpose of the backup?

Copying files from local disk to any removable media is called backup.
In information technology, a backup or the process of backing up is making copies
of data which may
be used to restore the original after an event of data loss. Backup has two
distinct purposes.
The primary purpose is to recover data after its loss due to deletion or
corruption. Data loss is very
common in IT industry.
The second purpose of backup is to recover data from an earlier time.
Backup is the most important job of a system administrator, as a system admin it is
our duty to take
backup of the data every day. Most companies have gone out of the market because of
poor backup planning
or policy.
2. What is recovery or restore?
Copying files from any removable media to local disk is called recovery or restore.
Backup will be
helped in hardware failure or software failure or system crashed.

Types of backup
1. Full backup
2. incremental backup
3. differential backupBackup and Archive

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy