7 8 Rhcsa 16 04 2024 2
7 8 Rhcsa 16 04 2024 2
RH 124
RH 134
Ex-200
RH 294
Ex-300
1. Introduction to OS
2. Intorduction to Unix
3. Introduction Linux
4. Advantages of Linux
5. Os Insatlling
1. Introduction to OS
Operating System
2. History of Unix
Unix OS -1969
2. hardware Dependant
HP HP-ux 1984
Apple MAC oS 1984
IBM AIX 1986
Oracle solaris 1992
3. Introduction Linux
Torvalds - Linux-1991
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
Linux windows
5. OS installing
8 GB Ram
Vm Workstation
Centos /redhat
===================================================================================
===================================================================================
===================================================================================
==============================================
Architecture of Linux
[root@ip-172-31-83-234 ~]#
cd =====change directory
/====parent directory.
/sbin===super user binary files.(commands inside this folder can be accessible only
by root user).
which <command name> =====to know a particular command in linux belongs to /bin
or /sbin
===================================================================================
===================================================================================
===================================================================================
===================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
==
Uname Command
#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 :
===================================================================================
===================================================================================
===================================================================================
======================================================
cat command
creating a file, reading, adding and appending the content inside a file.
Move:
Renaming a file
to remove a file
#rm -f f1 f2 f3 f4
#rm -f redhat{4..6}
===================================================================================
===================================================================================
===================================================================================
==========================================================================
Directories:
Path:
1. Absolute path
cd /redhat/rhcsa/anisble/devops/rhel
2. Relative path
#cd /redhat
#ls
#cd /rhcsa
Copy a dir:
Move a dir:
Renaming a Dir
Remove Directory
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.
VIM :
1. Insert Mode
2. Command Mode
3. collon Mode
Insert Mode:
#cat /etc/passwd
#vim /etc/passwd
Command Mode:
Collon Mode
User?
#id <UN> or vim /etc/passwd or getent passwd <UN> ===to know wether the user is
created or not
#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.
pranay:x:1002:1002::/home/pranay:/bin/bash
===================================================================================
===================================================================================
===================================================================================
===================================================================================
=========================================
Group
Collection of users is called group. Each and every group will be having GID and
group name.
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 or getent group <GN> ===to know wether the group created or not
#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 -A <UN> <GN> ===to assign the admin access to a specific user in a group
#su - <UN>
#newgrp <GN> ===to login to the group
#gpasswd -a <UN> <GN>
#gpasswd -d <UN> <GN>
group1:x:1002:u1,u2,u3,u4
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)
u1:$6$MUtfcPn.GxQqfUNs$kwYbt6QP5CJpJTT88YDK/
jcqQqEIXTRV80BSuHel32dHdgiQbGM4T7cwmV7EP54YvokxgS50UDTLNLNly/IYh/
$6$MUtfcPn.GxQqfUNs$kwYbt6QP5CJpJTT88YDK/
jcqQqEIXTRV80BSuHel32dHdgiQbGM4T7cwmV7EP54YvokxgS50UDTLNLNly/
IYh/:19842:0:90:7:40:20:
u1===user name
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
40===inactive days
20===expire days
===================================================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
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
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!
#su - <UN>
#vim .bashrc
umask 033
:wq!
#source .bashrc
===================================================================================
===================================================================================
===================================================================================
===================================================================================
====================================================================
chmod
r=4
w=2
x=1
#touch f1
-rw-r--r--
#chmod 666 f1
-rw-rw-rw-
How to validate?
# mkdir /newdir7
# ls -ld /newdir7
drwxr-xr-x
Symbolic mode
read(r),write(w),execute(x)
user(u),group(g),others(o)
add(+),remove(-),exact set(=)
===================================================================================
===================================================================================
===================================================================================
=================================================================
Access Control List
m==modify
#setfacl -x u:<UN>,g:<GN> <f/d> ==to remove the acl permission from a particular
user or groupon a file or directory
#touch file1
#ls -l file1
#ls -l file1
#mkdir dir1
#ls -l file1
#mkdir dir10
#ls -ld /dir10
drwxr-xr-x root root
===================================================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
==========================
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
wheel ====group where we can add the list of users to get the suod priviliges.
===================================================================================
===================================================================================
===================================================================================
===================================================================================
===================================================================================
====
Special permission
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.
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
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.
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.
Types of Disk.
#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:
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.
xfs /de/nvme0n2p1
#mkfs -t <file system type> <device name> ====to assing the file system
Mounting:
1st we will create one directory and mount the partition on the directory.But this
type of mounting will last till system reboot.
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!
#partprobe
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
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.
#vim /etc/fstab
#fdisk /dev/nvme0n2
#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.
#mkswap /dev/nvme0n2p1
Mounting
#vim /etc/fstab
#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.
Components of LVM:
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
device created using free space available from one or more physical volumes.LVM
size cam be resized
4. Extent
every pv is equllay divided in to multiple sub partitions is called PE. the defaut
size of your PE is 4MB
2. Crete PV
#pvcreate <device name> <device name> <device name> ====to create physical volume
3.create the 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
Task
9. how to decrease the LVM size. Assign the system
shrin in -200M
shrink by 600M
#umount /lvm
#vim /etc/fstab
3. remove lv
4. vg remove
#vgremove <vgname>
5. pvremove
#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
#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.
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
Permananently
1.# cd /var/www/html
2.# cat >>index.html
"Welcome to apache Webserver"
#firewall-cmd --reload
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
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
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
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.
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!
https://access.redhat.com/solutions/10021
===================================================================================
===================================================================================
===================================================================================
===================================================================================
==================================
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
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:
#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
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
#vim /etc/cron.allow
#vim /etc/cron.deny
===================================================================================
===================================================================================
===================================================================================
===============================================================================
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