Oracle Linux Express Guide Version 8 by Shiv Kumar, Goyal Bibis - Ir
Oracle Linux Express Guide Version 8 by Shiv Kumar, Goyal Bibis - Ir
Oracle LINUX 8
Shiv Kumar Goyal
Preface
Let us starts journey with Oracle Linux. This book covers installation, file
system structure, network, LVM, Repository Structure, NTP, Log
management and many other aspects of Oracle Linux. The structure of the
book is very simple and easy to follow.
Thanks
Oracle Linux follow middle path, it is free to use and update but support is
paid. Oracle Linux distribution is derived from source code of RedHat.
Oracle Linux is functionally and binary compatible with Red hat enterprise
Linux. Oracle Linux generally removes Red hat’s branding and artwork.
After merger of Redhat with IBM, Centos linux which was free alternative
of Redhat is no more available. Only product available from Centos is
Centos stream which is rolling release. The customers that use to prefer
Centos as free alternative of Redhat Linux now reluctant to use Centos in
production environment. Oracle provides simple script to migrate your
current Centos environment to Oracle Linux.
Platform supported.
Oracle Linux Version 8 installation images are available for following
platforms:-
Image Platform Supported
Types of images
Standard installation image is in the form of ISO image only, however, you
can also get Cloud image, Container image and Vagrant image.
Chapter 2
Support Life Cycle of oracle Linux
As mentioned earlier you can opt for support of Oracle Linux if you are
using the Oracle Linux in mission critical system, the life cycle of
Oracle Linux support is following
Premier Sustaining
General Extended
Releases Support Support
Availability Support Ends
Ends Ends
Linux 3 Oct 2003 Oct 2011 Not Available Indefinite
Linux 4 Feb 2005 Feb 2013 Not Available Indefinite
Linux 5 Jun 2007 Jun 2017 Nov 2020 Indefinite
Linux 6 Feb 2011 Mar 2021 Jun 2024 Indefinite
Linux 7 Jul 2014 Jul 2024 Not Available Indefinite
Linux 8 Jul 2019 Jul 2029 Not Available Indefinite
Type of support
Oracle provides two types of paid support for Oracle Linux. The
difference between the two type of support according to oracle site is
bellow
Feature Basic Support Premier
Support
24x7 telephone Yes Yes
and online
support
Access to Yes Yes
enhancements,
updates, and
errata
Oracle Enterprise Yes Yes
Manager for
Linux
Management
Spacewalk Yes Yes
support
High availability Yes Yes
with Oracle
Clusterware
Comprehensive Yes Yes
tracing with
DTrace
Oracle Linux Yes Yes
load balancer
Oracle Container Yes Yes
runtime for
Docker
Oracle Linux No Yes
Virtualization
Manager
Ksplice No Yes
Oracle Linux No Yes
Automation
Manager
Oracle Cloud No Yes
Native
Environment like
Kubernetes
Gluster Storage No Yes
Access to Oracle No Yes
Linux software
collections
Corosync and No Yes
Pacemaker
support
Premier No Yes
backports
Lifetime No Yes
sustaining
support
Chapter 3
Installation Media Preparation
Oracle Linux downloads are available in several forms:
Format Description
ISO images Installation Media for
x86_64 and Arm
Vagrant For Vagrant Boxes
Container images for x86_64 and Arm
GitHub Container Registry
Docker Hub Docker images
Virtual machine templates .ova format templates
Raspberry Pi 4 and for Arm
Raspberry Pi 3
In this book, we will cover only Intel platform installation. To download image
of Oracle Linux follow these steps :-
1 Go to oracle site https://yum.oracle.com/oracle-linux-isos.html
2
Select the version and platform in our case it is x86_64 under Full ISO
Verifying the download
Download the checksum file from bellow site
https://linux.oracle.com/security/gpg/
if you have downloaded the image on Microsoft windows machine. Open the
powershell prompt and give following command :-
Syntax
get-filehash path for isofile
Example
PS C:\> get-
filehash D:\Download\OracleLinux-R8-U4-x86_64-dvd.iso
Now open the checksum file and compare the output of the get-filehash
command output.
Media preparation
To prepare USB media for installation on physical machine use following
steps.
1. Download Fedora live USB creator from the Fedora Linux site.
https://getfedora.org/fmw/FedoraMediaWriter-win32-latest.exe
2. Double click the downloaded file and follow the installation steps.
3.
4. Select the downloaded ISO file of Oracle Linux and press Open.
5.
Installation Basics
Oracle Linux uses Anaconda installer for installation. Installation of Oracle
Linux can be done in following ways:-
Quick install
Customized GUI install
Kickstart automated install
Partitioning
Oracle Linux supports three type of partitioned devices
Standard partition
LVM
LVM thin
Standard Partition
For boot, BIOS boot and EFI system partition only standard partition can be
used.
LVM
LVM partition scheme allows flexibility and performance benefit. When
you choose LVM partition during the installation, if no volume group
currently exists on the system, the installation creates one automatically.
LVM thin
LVM thin uses storage pool which allows thin provisioning of the storage.
EXT2 is the standard file system used in the older versions of Linux.
Swap
It is a virtual memory present on hard disk. When system does not have
enough RAM to operate, then it transfers some portion of the memory data
in to swap space.
BIOS boot
Partition required for GPT.
EFI
Boot device for GPT on UEFI system.
Recommended partition scheme
Partition Details
/boot 1 GB and no LVM.
/ root partition recommended size 10GB.
/home 2GB minimum (optional)
/swap Equal to more than RAM in some cases it
should be double of system memory.
2. Select your
language and location. Click Continue.
3. Next screen is installation summary, which shows all installation options
with default values.
4.
From
the installation summary screen select Time & Date. Click your current
location on the map.
The system will change the date, time and time zone accordingly. Change
date, time format from 24 hours to AM/PM, if required. Press Done.
5. Select
Installation Destination. From the Local Standard Disks pane, select the
target disk. Click Done to use the default setting for Automatic partitioning.
Note: if you have specific file system requirement you can select Custom
option.
Make sure
that the Connect automatically with priority is selected.
9. Select IPV4 Settings tab to configure static IP address.
10. On the IPV4 Tab change following: -
1 Change Method to Manual from drop down menu.
2 Press Add button.
3 Provide IP address
4 Provide Net mask
5 Provide gateway.
6 Add DNS
7
Press Save.
11. Click Done to accept the changes.
12. On the
Installation Summary screen press Root Password.
13. Set root password and press Done.
14. Select User Creation on Installation Summary window.
15.
On the Create User screen, provide Full name, user name and password for
new user. Select Make user administrator if you want this user to be
administrator.
18. After
reboot, on Initial Setup Screen press Licence Information.
19. On the
Licence information screen, select I accept licence agreement. Press Done.
20. Press
Finish installation.
Write
root and press Next.
23. Provide password for root user. The same password you selected at the time
of installation. Press Sign In.
TOP BAR
The top bar has four main sections.
Activities
Application menu
Clock
System Menu
System Menu
Right corner of the bar has power, speaker network, battery and Bluetooth icons.
Click any of these icons to open System menu. System menu allows you to adjust
speaker and microphone volume. This menu also give you option to adjust network
and Bluetooth settings. You will find quick links for system settings, Lock screen
and Shutdown Menu.
Clock
In the center of the bar, there is clock and by default, it shows day of the week and
current time in 24-hour format. If you want, you can change the time format in the
system settings. Click clock to open dialog box with calendar on the right side and
any task notification on the left side.
Activities
On the left side of the top bar is the Activities button. Click on this button to open
overview screen. You can use Super key (also known as Windows key) on your
keyboard to open Activities overview. Activities Screen provides following items
Search Bar.
Search Bar
One of the main item of Activities overview screen is search bar. With search bar
you can search applications, documents, settings, calendar events etc. on your
computer. For example, if you write calculator in the search bar it will show
calculator application.
Click the icon to open the
calculator application.
Second item of Activity overview is peek view of all running applications. Click the
desired application window to switch application. To close any running application
window, hover over the window and click X button.
Workspaces
Left side of the Activities overview screen shows the list of workspaces.
Workspaces are virtual desktops for better windows management. You can create
multiple workspaces. Workspaces are meant to reduce mess on the single desktop
and make the desktop easier to navigate.
Click on the workspace to switch workspace. To move the application to different
workspace just drag the running application to new workspace.
Dash
On the left side of the desktop you will
find the Dash bar. The Dash provides access to your favourite and running
applications. Click the application icon on the dash bar to open the application. The
small dot at the bottom of icon indicates running application. Click on any running
application icon brings most recent window of the application.
Right click on the icon to open context menu. From this menu you can open new
window or pick any window of a running application. You can also add or remove
any application to favourites from this menu.
Grid
At the bottom of the dash bar there is grid icon. Click on this icon
shows the list of all and frequently used applications. The icons are in grid format,
from the bottom of the grid you can switch between all applications and frequently
used applications. The list of applications can span multiple pages, to navigate to
next page use scroll (centre) wheel of mouse or click the dots on the right side of the
grid.
Some applications in the grid are contained in the application folder. Click
application folder to list the grid of all containing applications.
Application
menu
Located beside the Activities button, application menu shows the name of the active
application. Also provides other options specific to the active application.
System settings
Click on system setting icon in the system menu
will open settings windows for system and hardware. Setting screen has two panes,
left pane shows the list of settings and right pane provides the description of the
selected setting. You can scroll the list of settings with mouse’s scroll wheel.
Suppose you want to change the background of your desktop. Click background in
the left pane and select the wallpaper from the list of available wallpapers in the
right pane.
Top bar of the system setting tool also houses search button. Search button offers
you to search anything related to settings. Suppose you want to look for date and
time settings, just press search button and write date. The system will show you list
of items related to date in the left pane.
Log out
After finishing your task, it is good practice to logout from the system. The logout
option closes all running application started by the user in the current session. To
logout as current user press user name from the system menu. From the sub menu
press Log Out. On the confirmation popup press logout again.
Lock screen
List windows
To show all the running windows just click Activities button. From the list
of windows press left button of mouse to select any window.
Switch window
You can switch the window using keyboard, press Super key + TAB to open
windows switcher. Hold Super key, release and press TAB key to cycle
between open windows.
Please
note: Super key is an alternative name for the Windows key when using
Linux.
Unmaximize window
To restore a window to its normal size grab the window title bar and drag
away from the top bar or just double click title bar of window. Press Alt +
F10 on the key board to unmaximize the windows using keyboard.
To
copy files or to compare content of two windows you can place two
windows side-by-side. In Microsoft windows, this feature is known as
windows Snap. To snap window to left side press Super + left Arrow and to
snap window right side of screen select the window, press Super + right
arrow key on the keyboard. To snap window using mouse, grab the title of
window and drag it to the left or right side until half of the screen is
highlighted.
Switch workspaces
Bash
Bourne-Again Shell, bash is Linux shell that provides interface to the user
to input commands and present output as its result. You have choice of
multiple shells on the Linux like Korn, C shell and Z shell etc, but bash is
the default shell available in the Oracle Linux. However, you can use other
shells also if required. Bash shell can be used in two ways, interactive and
in the script also known as shell script.
Shell basics
When you enter any command on the terminal it has three parts
Command option argument
Example
cp -R /test/1anty.text /home/f1/.
Here cp is command
-R is option, there can be multiple options in the same command.
Rest is the argument. there can be multiple arguments depending on the
command.
Virtual Consoles
Terminal is the device to input commands. Bash uses terminal to interact
with user. Terminal term came from Unix display devices. Oracle Linux
provides 6 virtual consoles with default installation. These terminals
provide virtually independent shell environment while working on the
server. Virtual console provides another way to access shell. You can
change virtual terminal by pressing Alt + Ctrl + function keys on your
keyboard. First terminal start at F1 key through F6 key on your keyboard.
Suppose you want change to terminal 3 press Ctrl + Alt + F3 key. If you
have installed Server with GUI, then first two Virtual consoles will be
graphical user interface available with Ctrl + Alt + F1 and Ctrl +Alt + F2
key rest of the four virtual consoles can be assessed using Ctrl + Alt keys up
to f6.
Gnome Terminal
Gnome terminal is a terminal emulator for GNOME Desktop environment.
It provides terminal environment in the GUI environment.
Tab Completion
One of the main high light of the bash shell is the tab completion. When
you press tab after partially written command system automatically
completes the command. if more than one command is available with same
string then it will show the list of commands. Not only commands it also
completes the name of files.
Example
hostna<tab>
cat /etc/grou<tab>
history
To list the previously used command
Example
history
date
Print or change the system data and time.
Syntax
date
To check date
To set date
date -s "24 feb 2017 19:00"
echo
Print text on the terminal
Syntax
echo text
Example
echo hello
Telnet
Telnet is old software that transfers data in plain format, hence it is not safe
to use. Due to safety concerns, telnet is not available by default on the
server. If you have specific requirement you can still install it and use it.
After
installation
Open up PuTTY
on your host system, and in the field for Host Name (or IP address) type the
IP address of your server and press open.
First time you will
get Security Alert , press Yes.
On the terminal screen write username and press Enter key
Provide password and press Enter key.
Save session
To save the session:-.
1 Write the IP address in the IP address input box.
2 Make sure ssh is selected
3 Write the name of session in the saved sessions input box.
4 Press Save
button.
Directory Description
/ Top directory, all other directories are sub
directories of root file system.
/bin This directory is link(shortcut) to /usr/bin
containing executable files.
/boot Files for system boot.
/drv Device driver files.
/etc Configuration files.
/home Users home directory other than root user.
/lib Libraries.
/lib64 64 bit libraries
/media Mount point for external storage devices.
/mnt Mount point for user mounts.
/opt Third party software.
/proc Temp directory for all running process.
/root Home directory of root user.
/run Temp file system used by running process.
/sbin Symbolic link to /usr/sbin directory for
system executable files.
/srv Services related data.
/sys Symbolic link to the kernel source tree.
/tmp Temporary files.
/usr Binary files of the users.
/var Variable files like logs.
What is path
Path is the location of the file or directory. Path can be relative or absolute.
Relative path
Relative path is defined as path related to the current directory. Suppose you
are in /home directory and want to change directory to /home/user1 . You
can use relative path and give command cd user1
Absolute path
An absolute path is defined as the specifying the location of a file or
directory starting from the root (/) directory. Suppose you are in /var
directory and want to change directory to /home/user1 . You can use
absolute path and give command cd /home/user1.
File and directory operations
In this section we will discuss few file and directory operation.
Create directory
mkdir directoryname
Example
mkdir /example
it will create example directory in the root directory
Change directory
Syntax
cd directory_name
Example
cd /example
Display file content
cat
Syntax
cat file_name
Example
cat abc.txt
less
Less is a program similar to more, but it allows backward and forward
movement in the file.
Syntax
less filename
Example
less /etc/hosts
head
Print the first 10 lines of a file to the standard output. You can also specify
number of line to show.
Syntax
head option file
Example
head -20 /etc/passwd
Show first 20 lines of passwd file
tail
Print the last 10 lines of a file to standard output. You can also specify
number of lines to show.
Syntax
tail option file
Example
tail -20 /var/log/logfile
it will show last 20 lines
Example
cp *.txt /home/user/.
This will copy all files with txt extension to /home/user1 directory
Copy directory
Syntax
cp -R source_dir target_dir
Example
cp -R user1 user2
copy user1 directory to user2
To remove a directory and all its contents, including any subdirectories and
files
rm -r /example
use this command very carefully, can cause data lose
Remove directory
Syntax
rmdir directory
Example
rmdir /example
Long listing
ls -l
shows list of files or directories with size, modified date, modified time and
its permission.
mv
mv command is used to move file from one location to other location. You
can also use mv command to rename the file without moving it.
To move file
Syntax
mv filename destination_directory
Example
mv a.txt /tmp/.
It will move a.txt file from current directory to /tmp directory
To rename
Syntax
mv filename newfilename
Example
mv a.txt b.txt
grep
Searches for a String from one or more files. Display each line which has
string.
Syntax
grep string file
Example
grep '127.0.0.1' /etc/hosts
diff
Compares two files.
Syntax
diff First_file Second_file
Example
diff abc.txt bbc.txt
file
Determine file type
Syntax
file file_name
Example
file bbc.txt
Linking files and directories
Link is the like short cut in Windows which point to the original file. There
are two types of links
Hard link
Soft link
Both hard and soft link are short cut to file. Soft link can exit in different
file system where as hard link can exist only in the same file system. When
you remove original file soft link will stop working whereas there will be
no effect on hard link. The reason is that, in case of hard link both original
file and hard link is pointing to same inode.
Non-IP network
Non-IP network make use of transport layers for communication. One of
the example of Non-IP network is InfiniBand.
IP Network
IP network is the network which uses IP address to communicate. Each
device which is part of IP network should have IP address. IP Network is
most common type of the network type. Home, offices and internet mostly
use IP network.
Static
Static IP address is manual mode of IP address assignment to devices. In
case of static IP addressing, IP address remain same over the time, unless
you change it. This type of IP addressing is mainly used on small networks
or shared devices like Servers, printer etc where you want same IP address
every time.
Dynamic IP Address:
Dynamic IP address configuration is an automatic configuration of
addresses. It uses DHCP server to get the IP address for your device. When
you configure DHCP server you allocate range of IP addresses to be
assigned to the clients. When you start the device it connects to the DHCP
server to get the IP address. Every time you start your device you may get
different IP address, unless you reserve an IP address based on MAC
address of the device. Dynamic IP configuration is ideal for large
organizations where it is not possible to remember the address assigned to
each device. But DHCP is not ideal solution for servers and printers where
you want same IP address every time.
Configuring Network
By default, Oracle Linux 8 uses NetworkManager to configure and manage
network connections. To use NetworkManager for configuring network
interfaces, use one of the following tools:
nmtui Text based User Interface to
manage network. This tool is very
useful in non GUI environment.
GNOME Graphical Tool for network
Networkmanager management .
nmcli Command line tool.
Device naming convention
The interface name starts with a two-character prefix based on the type of
interface:
Type of device Prefix
Ethernet en
wireless wl
wireless wide area network ww
To keep the deice name persistent the Oracle Linux uses following
convention for Ethernet devices:-
Type of device Device Name
For Onboard enoX where X is the device number
devices
For PCIe devices ensX where X is the device number
For Multi-port enpZsX where Z is the physical port
devices number and X is the device number
Traditional ethX where X is the device number
Naming
Traditional naming convention ethX was used for network devices in the
older versions of Linux. The new naming convention provides following
benefits:-
1 Stable interface names across reboots.
2 Stable interface names even after hardware addition and
removal.
nmtui
nmtui is Text Based Interface (TUI) tool for configuring networking. This
tool is very helpful in network management on the system without GUI.
To start nmtui
nmtui
3. Select the
connection profile from the list and press Edit.
4. On the Edit Connection screen, press SPACE BAR key at IPv4
configuration.
5. Select Manual.
6. Press TAB and select Show.
7. Provide IP Address, Netmask, gateway and DNS in respective
fields.
8.
nmcli
nmcli is a command-line tool for managing network. nmcli can be used to
create, display, edit, delete, activate, and deactivate network connections.
nmcli is a very useful tool to control and display network device status.
Example
Device detailed information
nmcli device show
List connections
nmcli connection show
Activate Connection
Syntax
nmcli connection up connection_name
Example
nmcli connection up ens35
Deactivate Connection
Syntax
nmcli connection down connection_name
Example
nmcli connection down ens35
Show hostname
nmcli general hostname
Wifi network management
If network is password
protected, at password prompt, provide password and press
Connect.
6. Now your network is connected and top bar will show Wi-Fi icon.
Wired network
Connecting wired network is easy, just plug the network cable to your
computer. The system will automatically configure the system for available
network. As soon as the system is connected to the wired network, system
indicator shows at the top bar.
DNS
A DNS server is a central repository that contains a database of IP addresses
and their associated hostnames. Whenever any client wants to resolve
hostname to IP address instead of using its local file it sends request to DNS
server. If IP Address of some client changes you just have to update the DNS
entry. You can have multiple DNS server in one organization. To redirect
your request for hostname resolution Oracle Linux uses /etc/resolve.conf
file. By default, NetworkManager on Oracle Linux 8 dynamically updates
the /etc/resolv.conf file. However, depending on your requirement you can
disable DNS processing by NetworkManager.
Teaming
Teaming allows you to group multiple physical Ethernet network adapters
into one logical adapter. This logical network adapter provides higher
throughput or redundancy.
ip link show
Change hostname
Syntax
hostnamectl set-hostname newname
Example
hostnamectl set-hostname myhost1
dig
DNS lookups and displays result
Syntax
dig hostname
Example
dig microsoft.com
telnet
To connect destination host:port. You can also use telnet command to test
host and port reachability.
Syntax
telnet hostname port
Example
telnet myserver1 8080
nslookup
Query Internet domain name servers.
Syntax
nslookup hostname
Example
nslookup microsoft.com
scp
Copy files from one host to other host over the network in secure manner.
Syntax
scp filename user@targetserver:/path
Example
scp ast.txt user1@server2:/home/user1
ssh
For secure login to target server.
Syntax
ssh user@targethost
Example
ssh user1@server2
nmap
Checks the opened port on the server.
Syntax
nmap hostname
Example
nmap cloudflare.com
Chapter 9
Local file systems
File system controls how data is stored and retrieved in the Operating system.
File system is way to organize data on the storage. Oracle Linux 8 supports
different type file system for local data storage. We will discuss two major
file systems.
XFS
EXT4
XFS
XFS is high performance file system developed by Silicon Graphics, Inc
(SGI) in 1993. XFS is the default file system for Oracle Linux 8. it is
journaling file system which means recovery of the file system is seamless in
case of abrupt system failure. XFS is also capable of storing large files and
big file systems. XFS can be extended and defragmented in mounted state.
EXT4
EXT file system has long history. ext4 is the fourth generation of the ext file
system family. It is also a journaling file system. Ext4 drivers can read and
write both ext3 and ext2 file system. It can support file system size up to 50
TiB. Being a legacy file system ext4 file system is supported by almost all
applications on Linux.
Commands for XFS file system management
Create XFS file system
Syntax
mkfs.xfs devicename
Example
mkfs.xfs /dev/sda01
Resize
you can expand ext4 file system while it is mounted. Shrink require ext4
file system has to be unmounted.
Syntax
Resize2fs device_name new_size
Example
Resize2fs /dev/sda01
if you do not specify size this command will extend the file system to
maximum limit of the device.
To change the file system to specific size
resize2fs /dev/sda01 5G
Chapter 10
Exploring Network File Systems
In the previous chapter we had discussed local file systems, however to
share data over the network remote file system comes in to the picture.
Network file system requires extra layer above local file system in order to
share and mount over the network. Network file system can be used by
multiple users at same time. Once mounted it behaves like local file system
on remote machine. In this chapter, we will walk through commonly used
remote file system on Oracle Linux 8.
NFS
NFS is a file sharing file system, which works on server client basis. The
file systems which are shared on server can be mounted on client over the
network. NFS File system is very popular file system sharing protocol
among Unix and Linux systems. Oracle Linux server support both NFS
Server and client. NFS on Linux is very useful for cross platform files and
folders sharing. NFS is also widely used protocol on Network Attached
Storage NAS systems also. Currently there are four versions of NFS and
each versions has further releases, like version 4 has 4.2:-
NFS V1
NFS V2
NFS V3
NFS V4
Where NFS V3 and NFS V4 are more recent version of NFS. In Oracle
Linux 8, NFS over UDP is no longer supported. NFSV4 has added
advantage of working through firewall and works on TCP. In Oracle Linux
8, the default NFS version is 4.2 which features support for Access Control
Lists (ACLs), server-side copy and sparse files. Oracle Linux 8 support
only version 3 and version 4 of NFS, version1 and version 2 is no more
supported by Oracle Linux version 8.
Installing NFS
Install packages
yum install nfs-utils
After installation, enable the service to start automatically after reboot.
systemctl enable nfs-server.service
Export directory
In this example we will create two directories and export these directory for
clients to mount .
mkdir /accounts
mkdir /hrms
Example
mount -t cifs – username=user1 //192.168.115.129/shared /mnt
Partition Table
A partition has partition table where it stores partition’s beginning and end.
It also stores the code that is used during start-up, if a partition is bootable.
You have option to setup disk as MBR (Master Boot Record) or GPT
(GUID Partition Table). In this section, we will explain what difference
between two is.
Example
(parted) mkpart primary xfs 1 5GiB
Example
parted /dev/sdb
Remove the partition with rm command and select the partition number
(parted) rm
Partition number? 2
(parted)
Create partition using fdisk
Syntax
fdisk device
Create ext4
Syntax
mkfs.ext4 /dev/sdb1
Example
mkfs.ext4 /dev/sdb1
Mount device
Mount device is the block device or remote filesystem which you want to
use for storing data.
To mount file system you can identify the mount device by following
identifiers :-
UUID UUID is the Universal Unique ID of the
device. This is the best way to mount the
device as UUID remain same. You can
use blkid command to get UUID of
device.
Device Device name is hierarchical name of the
name device it can be like /dev/sdb1
Label Volume label for example
LABEL=data1 . You can use e2label to
check or change the label of ext file
system. To set or list label of XFS file
system use xfs_admin command.
Mount point
Mount point is the link for accessing this mount device. Mount point is the
normal directory. Once mounted device becomes the part of the directory
and you can access the contents of file system under this directory.
Mount command
mount command can be used for mounting file system.
Syntax
mount -t type -o options device dir
Example
mount -t ext4 /dev/sdb1 /mnt
Automatic mounting
If you want to mount the filesystem to be mounted automatically on every
boot you can use /etc/fstab file.
fstab file has following format
first second third fourth fifty sixth
Field Description
First Block device or remote file system
Second Mount point
Third File system type
Fourth Options, atleast one ro or rw. Other options are
defaults : rw, suid, dev, exec, auto, nouser, and
async.
noauto: do not mount automatically or with
mount -a command.
user: allow a user to mount the file system.
owner: allow device owner to mount.
Fifth Dump option, default is 0 for no dump.
Sixth File system check priority for fsck.
Example
/dev/mapper/cl-root / xfs defaults 00
UUID=095af347-cb2c-4d50-99b6-xxx /boot ext4 defaults 1 2
/dev/mapper/cl-swap swap swap defaults 00
LABEL=data1 /data1 ext4 defaults 00
/dev/sdb2 /data2 xfs defaults 00
If you get “target is busy” error when you unmount a file system, use fuser
command to list all processes using fileystem.
Syntax
fuser --mount mountpoint
Example
fuser –mount /data1
Remove file system
To delete a file system, we must first unmount it
Example
umount /dev/sda2
Then we can delete the partition from the partition table using fdisk or
parted
Example
fdisk /dev/sda2
This setup has disks then partitions and above partitions there are file
systems.
LVM setup
File systems / /home /var
Logical
/dev/sda1 /dev/sda2 /dev/sda3
Volume
Volume Group Vg01
Physical
/dev/sda /dev/sdb
Volume
Physical volume
Physical Volume (PV) is underlying physical storage unit. Physical storage
is a block device such as a partition or whole disk. Use pvcreate command
to use the physical device as Physical Volume. If block device is a partition,
then use fdisk to change the partition type to 8e (Linux LVM) before using
pvcreate command.
Create PV
Syntax
pvcreate device
Example
pvcreate /dev/sdb
If device is a partition
Change partition type as LVM
fdisk /dev/sda (Refer the partition chapter to change partition type)
now create PV
pvcreate /dev/sda3
Volume Groups
One or more physical volumes combined together to make a Volume Group
(VG). Volume group is an abstract that presents underlying devices as a
unified logical device with combined storage capacity of the physical
volumes.
To create Physical Volume
Syntax
vgcreate vgname PV1 PV2 ..
Example
vgcreate vg01 /dev/sdb /dev/sdc
Logical Volume
Logical Volume is logical partitioning of the volume group. Logical volume
can be used for file system creation. In some cases, you can also use LV as
block device.
To create LV
Syntax
lvcreate -n name -L size VG_name
Example
lvcreate -n data_lv -L 5G vg01
File system
To create XFS filesystem on the LV
Syntax
mkfs.xfs lv_name
Example
mkfs.xfs /dev/vg01/data_lv
Logical extent
Mapping of PE to make up frontend of LVM. By default, one PE is
generally mapped to one LE. However, you can map more than one PE to
one LE in case of mirroring.
LVM management commands
PV management commands
List all PVs
pvs
Display attributes
Shows the attributes of PVs, like size, physical extent size, space etc.
pvdisplay
PV Resize
If PV is coming from storage or vitrtual storage you have option to change
size of virtual device or LUN. To update LVM with the new size of physical
storage.
Syntax
pvresize device
Example
pvresize /dev/sda
Remove PV
If for some reason the PV is no more used by LVM you can remove the PV
using pvremove command
Syntax
pvremove device
Example
pvremove /dev/sda
VG management commands
Display summary all VGs.
Syntax
vgs
Example
[root@Server1 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
cl 1 2 0 wz--n- <19.00g 0
Display VG properties
vgdisplay displays properties of VG such as size, extents, number of physical
volumes etc)
Syntax
vgdisplay
To view specific VG
Syntax
vgdisplay vgname
Example
vgdisplay vg01
Change VG
You can deactivate an active VG and vice versa using vgchange
command. VG in deactivated state can be used.
Syntax
vgchange -a n vgname
Example
vgchange -a n vg01
Remove VG
When vg is no more required and there is no LV on the VG you can remove
it.
Syntax
vgremove vgname
example
vgremove vg01
Rename VG
For some reason if you have to rename a VG
Syntax
vgrename vgname new_vgname
Example
vgrename vg01 vg02
Syntax
vgexport vgname
Example
vgexport vg01
Remove a LV
To remove a logical volume, make sure it is not in use anymore.
Syntax
lvremove vgname/lvname
Example
lvremove vg01/lv01
Use this command to extend the LV to use 100% free space of VG and
extend the filesystem also.
lvextend -l +100%FREE -r vg01/lv-root
YUM
Like other Linux distributions, Oracle Linux uses very comprehensive
package management system known as YUM. Yellow dog Updater
Modifier is command line tool for package management. Yum uses
repositories to fetch the correct version of a particular package compatible
for your system. Yum allows automatic updating of packages and
dependency management. When you use yum command for installation of
software, it automatically downloads package and all its dependencies from
defined repositories. Oracle Linux version 8 uses YUM v4 instead to YUM
v3 used in the earlier version. YUM v4 tool, which is based on the DNF
technology has the following advantages :
Better performance
Support for modular content (We will discuss later about modules)
Stable API for integration with tooling
In Oracle Linux 8 has three application streams, each one with its own
lifecycle:
BaseOS provides the basic operating system,
AppStream provides user applications,
CodeReady Linux Builder provides developer tools and languages.
Package management
Search package
Syntax
yum search package_name
Example
yum search httpd
Update
Update specific package
Syntax
yum update package_name
Example
yum update vsftpd
Update advisory
Update advisory is the list of packages with bug fixes.
View update advisory
yum updateinfo list
Module Profiles
To simplify installation further, modules usually classified with set of
specific set of packages for specific workload or user case. This list of
packages is known as profile. A profile name can be anything like server,
client, development, minimal install etc.
Install module
Syntax
yum module install module_name
Example
yum module install nodejs
Remove package
Syntax
rpm -ev package_name
Example
rpm -ev zsh-html
Update group
Syntax
yum group install “Group Name”
Example
yum group update “System Tools”
Example
Oracle Linux Repositories
Unlike previous versions, Oracle Linux 8 comes with two main repositories.
1 BaseOS
2 Appstream
BaseOS
BaseOS is intended to provide core set of functionality and core components
to OS independent to all types of installations. Which mean BaseOS
repository is required for all set of installation even for headless installation.
Appstream
Appstream contains additional userspace applications, languages, databases
etc. Appstream is intended for different set of workloads like http, database
or file server. Appstream gets updates more frequently than BaseOS.
Appstream is made up of rpm packages and modules.
Repository management commands
List all enabled repositories
yum repolist
open the repo file and change from enabled=0 to enabled=1. To disable any
repository, change from enabled=1 to enabled=0.
Using command
Enable any repository
Syntax
yum config-manager --set-enabled repo_name
Example
yum config-manager --set-enabled PowerTools
Disable repository
Syntax
yum config-manager --set-disabled reponame
Example
yum config-manager --set-disabled PowerTools
[InstallMedia-AppStream]
name=Oracle Linux 8 - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///local_repo/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
EPEL repository
EPEL or enterprise Linux repository is from fedora community containing
packages which are not available from Oracle official repository due to
license limitation. Most common packages are chromium, codec for audio
and videos.
To add repository
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Enable
yum config-manager --set-enabled epel
REMI
REMI is a free to use repository created and maintained by a Remi Collect.
The REMI provides the latest versions of the PHP stack and some other
software.
Install
yum -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Enable
yum config-manager --set-enabled remi
RPM Fusion
RPM Fusion provides proprietary multimedia software that the Oracle
Linux doesn’t want to ship.
Install
yum install --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-
8.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm
Note: This is single line command which will add both free and non-free
RPM Fusion repositories.
Chapter 16
Service Management System
What is service
A service is a program that runs in the background waiting to be used, or
carrying out essential tasks. When system boots, it starts many services to
achieve required state of the system. Suppose you want to start the system
in GUI mode, system has to start all the services related to Desktop
environment. Same way if you have configured the server as web server
you have to start the web services during boot process. Even to do its basic
tasks it requires many services to be running like network, date and time
etc. Unlike regular software program that is launched by the user and closes
automatically when the user log off, services can start without user
intervention and may continue to run even after the user logs off. Most of
the services runs in the background without the knowledge of users.
Software developer can develop its own software to run as service.
Introduction to SYSTEMD
Systemd is a system and service manager for most of the Linux
distributions. Oracle Linux also uses Systemd for service management.
Systemd is backward compatible with legacy SysV init scripts. The major
benefits of using Systemd for service management are:-
Easier service management
Parallelized job execution at boot time
cgroups for better resource management.
On-demand activation of daemons
Commands
systemctl is the command to manage the services in Oracle Linux 8. we
will use this command to view, start, stop, enable and disable the service.
Stops a service
Syntax
systemctl stop service_name
Example
systemctl stop httpd
Restart a service
Syntax
systemctl restart service_name
Example
systemctl restart httpd
Restart a service if it is running
Syntax
systemctl try-restart service_name
Example
systemctl try-restart httpd
Mask Service
When you mask the service it is impossible to start the service. This is very
useful in disabling dangerous and unknown services.
Syntax
systemctl mask service_name
Example
systemctl mask httpd
To reboot
systemctl reboot
or
Syntax
systemctl help service_name
Example
systemctl help httpd
Chapter 17
Users and Groups
User and group
A user is anyone who uses a computer or network service. A user can be
ether human or an account. For better management, the users are grouped
together in groups. Group is logical entity to organize users together based
on their different properties, it can be either based on same department,
same place or same work. Sometimes groups are just made to provide
certain common facilities or right to different users. When you create a user
in Oracle Linux, by default each user is given a corresponding group with
the same name known as User Private Group (UPG). For user and group
management you can use both command line and GUI mode.
Group provides following benefits: -
Easy user management
To share same resource with a number of users.
Easy permission and right assignment.
Modify user
Syntax
usermod
Example
usermod -c finance acct1
Delete user
Syntax
userdel
Example
userdel acct1
Delete group
Syntax
groupdel option groupname
Example
groupdel finance
Modify group
Syntax
groupmod options groupname
Example
groupmod -n finance1 finance
in this example change the group name of finance to finance1
/etc/passwd file
/etc/passwd file hold the list of all users on the system both system users and normal
users. The format of the file is that each line represents a user. The fields in each line are
separated by : (colons). The fields have following information
1 User Name
2 The encrypted password (show x, actual location of encrypted password is
/etc/shadow file)
3 User ID number (UID)
4 Group ID of user (GID)
5 User full name
6 Home directory
7
Login shell
/etc/group file
/etc/group is a file that defines the groups of each user. Multiple users can
belong to same group. Each user name in the same group is separated with
commas. The fields have following information: -
1 Name of the group.
2 Password: Generally, password is not used, hence it is
empty/blank. If it is not blank, then stores encrypted password.
This is useful in implementing privileged groups.
3 Group ID (GID)
4 Users list separated by commas.
Chapter 18
Exploring SU and SUDO
To elevate the privilege assigned to the current user you can either use su or
sudo.
SU
The su command is used to switch to another user. If executed without a
username, it will login as root user by default. su requires the password of
the target account.
To login as specific
Syntax
su username
Example
su oracle
when used with a hyphen (su -) assume the user environment of the target
user.
Example
For root user
su -
For other user
su - oracle
sudo
sudo allows users to run programs with the security privileges of another
user, by default, it uses administrator’s privileges to run commands. It is
mechanism by which you can assign some administrator task to less
privileged users without sharing administrator password. Unlike su which
requires the password of the target account, sudo requires the password of
the current user. Precede command with sudo to execute any administrative
command.
Example to run privilege command which changes system configuration
sudo yum install gzip
or change hostname
sudo hostnamectl set-hostname host2021
Wheel group
Oracle Linux comes with default administrator group known as wheel group
if you want to assign all administrator rights to a user without sharing root
password you can add that user in wheel group. But before that make sure
the line in /etc/sudoer file it is not commented out.
Note: The main difference between SU and SUDO is that in case of SU you
seek root permission through switching to superuser or root user, where as in
case of SUDO you seek root permission through a single command.
Chapter 19
Exploring File and Directory Permissions
Linux is a multi-user operating system which can be accessed by many
users simultaneously. Therefore, it becomes utter necessary that users do
not touch each other’s data. For security and sanity of the data and system
files, the operating systems deploys different type of security system. Linux
divides authorization into 2 levels.
Ownership
Permission
Ownership
Ownership defines who can access the file or directory. To represent the
ownership Linux uses following symbols:
Symbol Description
u User (owner)
By default user who creates the file or directory
becomes the owner of the file or directory.
g Group
o Other, Grants permissions to other users.
Practically, it means everybody else.
Permission
Permission defines action allowed on the file or directory. These actions are
read write and execute. There are two ways to represent the permissions:-
1 Symbol
2 Numbers
Symbols
To represent the file permissions following symbols are used:
Symbol Permission
r Read
w Write
x Execute
Execute permission for directory allows user to access the content of the
directory.
Now let’s see how we use them practically. This is the output of ls -l
command :-
Other object types
In the above command output you can see other objects like
Mask
Umask or user mask is the assigned default permissions when we create
new file or directory.
Check umask value
umask
To calculate the umask value just subtract the desired permissions from the
default one:
777-755 = 022
To set permanently use /etc/profile file for all users. For individual user
change ~/.profile or ~/.bashrc file.
Permissions command
chmod is the command to manage permissions
Add permission
Syntax
chmod +permssions filename
Example
chmod +x para.sh
Remove permissions
Syntax
chmod -permssions filename
Example
chmod -x para.sh
Like you can add and remove permissions for group and others at same
time.
chmod go-xw para.sh
The main configuration file is /etc/chrony.conf . Edit this file and add
bellow parameters.
server Ip_of_the_stratum
Example
server 192.20.3.1
You can restrict the usage of NTP server for a host or network
Syntax
allow network/hostIP
Example
allow 192.116.1.0/24
Save the file
On the client
Install chrony package
yum install chrony
Configure ntpdate
The purpose of the ntpdate service is to set the clock during system boot.
Edit /etc/ntp/step-tickers
Add entries of server IP
Example
192.116.1.123
Enable ntpdate and start
systemctl enable ntpdate
systemctl start ntpdate
Verify
chronyc sources
Chapter 21
Exploring Secure Shell - SSH
SSH is secure protocol for login to remote network. SSH works on server
client basis on the server sshd daemon is running and on client it connects
using ssh client. Openssh is an implementation of ssh on most of the Linux
distribution. Oracle Linux 8 also supports openssh as ssh server.
After the modification in the configuration file stop and start the sshd
service.
systemctl stop sshd
systemctl start sshd
On the client
ssh login@server_ip
Example
ssh [email protected]
Rule Duration
In firewalld, rules can be designated as
Permanent
Runtime.
Rule types
You can configure rules for specific
Program
Port
Predefined services: those service which are in the database of
firewall for allowing and blocking rules.
Custom
Install and Enable Your Firewall service
yum install firewalld
Start
systemctl start firewalld
Enable
systemctl enable firewalld
Allow service
First check if this service is in the list of predefined services
firewall-cmd --get-services
List the current configuration and see list of allowed services
firewall-cmd --list-services
Add
Syntax
firewall-cmd --add-service=service_name
Example
firewall-cmd --add-service=ssh
Add port
Syntax
firewall-cmd --add-port=port_no/port_type
Example
firewall-cmd --add-port=1191/tcp
Use
Press
Activities then in the search bar write firewall and click firewall icon
The interface is self-explanatory
Changing the Firewall Settings
Changing Configuration
Configuring services
Firewall-config tool provides interface to enable and disable predefined or
custom services. First, select the zone for which, service you want to
configure. Next is to select or deselect the service check box. Selected
check boxes are for enabled services and cleared (un-selected) check-boxes
are of blocked services.
Chapter 23
Exploring Cockpit
Cockpit is a Web based server management tool available for Oracle Linux
8. It is default server management tool. Cockpit is a very useful Web based
GUI tool with which you can monitor and manage multiple Linux servers.
Cockpit also allows you to manage networking, storage on servers,
containers, virtual machines. Logs management is quite easy with cockpit.
Installation.
If Cockpit is not already installed on the system then you can install it using
following command.
yum install -y cockpit
Access Cockpit
Open web browser on your PC or on the server and type url :
https://<Your_serever_IP>:9090
Example
https://192.168.1.128:9090
If you are opening on the same server, you can use also use localhost
instead IP address.
Chapter 24
Logs management
Logs are very important part of any operating system. logs are very helpful
in troubleshooting and auditing of system. Oracle Linux keeps it most of the
logs in central location /var/log directory. One of the important file is
/var/log/messages where Oracle Linux logs the kernel / core system logs.
Journalctl
Journald is the service used for collecting and storing the logs data in the
Oracle Linux. This service is used to manage the system log which includes
boot messages, kernel logs, syslog messages, service messages and system
error messages etc. By default, it keeps all logs in the memory and store
logs only in a small ring-buffer in /run/log/journal directory. if persistent
log configuration is enabled then it start storing logs under
/var/log/journal directory.
Configuration file
The main configuration file for journald is /etc/systemd/journald.conf.
Rsyslog
Rocket-fast Syslog Server or rsyslog is the very popular and old processing
system used by most the Linux distributions. The log files contain messages
about the system, kernel, services, and applications. Oracle Linux 8 uses
Rsyslog as default logging service. Journald forwards all logs to rsyslog.
Rsyslog stores all logs forwarded by journald in plain text format files
under /var/log/ directory. The main configuration file of Rsyslog is
/etc/rsyslog.conf . Configuration file contains rule lines to store log
messages. It has following parameters: -
Facility
Priority
Actions
Facility Facility is process or application generating
message, Using * means all facilities.
Priority Priority is type of log message, codes are emerg
for emergency, alert, crit for critical errors, err
all errors, warn for warnings, notice, info,
debug. Using * means all priority levels.
Action Action decides what action must be taken for
the matched rule.
In the bellow example Facility is mail, Priority is all errors and Action is
log messages to mail.err file
Rsyslog can also be used for log forwarding to central log server.
Chapter 25
Understanding Processes
Any program executed by the user or system starts process or processes to
accomplish the task. Each process has its own process ID. The process ID is
always unique during the lifetime of the process. There are two type of
processes: -
Daemons
These are the special processes which runs in the background and generally
not effected by user login and logout. There are two types of daemons one
which starts with system start others which gets triggered by process or
command.
These above two commands show detailed information about the processes
which includes process id and parent process ID.
Top
Top is another command to list the processes, process id and resource
utilization summary.
top
To stop
Syntax
kill PID
Example
kill 234
Only root user can change the nice value of other user’s processes and
system processes.
Chapter 26
Monitoring Your System
System monitoring is vital task for system administration. System monitoring
avoid the abrupt system failure and denial of services
Top command is multipurpose monitoring tool also can be used for processes
monitoring
top
To display memory in GB
free -g
Display the list of currently mounted file systems with usage information
df
List detailed information about all USB device present in the system
lsusb -v
List all pcmcia devices
lspcmcia
Display more information about PCMCIA devices
lspcmcia -v
Display hostname
hostname
Display Oracle Linux version
cat /etc/oracle-release
Hardware monitoring
Monitor all hardware resources like CPU, Memory and network in one screen
top command is the most used command with summary of all hardware
resources information
top
CPU monitoring
To monitor CPU over committing you can use
SAR
sar command is system activity reporting tool.
Install sar command
yum install sysstat
sar 2 3
Monitor memory
vmstat command can be used to view the memory and swap space usage.
Syntax
vmstat delay count
Example
vmstat 2 3
This command will take 3 samples each after 2 seconds.
To monitor IO devices
iostat
tcpdump
tcpdump command mostly used as network packet analyser or packets
sniffer program for TCP/IP. This command analyse all network traffic pass
through your computer. To use this command, you should have thorough
knowledge of tcpip protocol.
Syntax
tcpdump -i interface_name
Example
tcpdump -i eth0
ss
SS utility show the network socket related information
To display all listening ports
ss -l
Display the uptime (how long the Oracle Linux system has been
running)
uptime
NFS statistics
nfsstat
to view only server side statistics
nfsstat -s
Process Tab
Shows all running processes of the system with their CPU usage, memory
usage, disk usage etc. Right click the process to manipulate the selected
process.
Resource Tab
Shows all the hardware resource usage and history in graphical format.
Filesystem Tab
Shows mounted file system and their percentage of usage.
Chapter 27
Automating your System
Automation of system makes job of administrator easy and reduces the
number of mistakes during repeated tasks. Linux offers scheduler for
handling regular jobs.
Cron is a time-based job scheduler available in Oracle Linux to run
commands at given times of intervals. Other than system wide cron table,
each user can have separate cron table to execute schedules jobs.
The system wide cron table file is /etc/crontab. /var/spool/cron/ directory
contains cron table files for each user.
root user can change the crontab of other users, using -u parameter
Example
crontab -u user2 -l
At
Unlike cron, which let you run a task on a regular basis at specified date and time,
at command is mostly used for scheduling adhoc jobs. The at command is
controlled by atd daemon. To use at command scheduling atd daemon should be
in running state.
Install
yum install at
Look for line starting with Linux and move the cursor to end of the line
using Ctrl+e and write rd.break .
3 Press Ctrl + x key.
4 It will give prompt with read only root file system.
5 Remount the file system to Read into write mode
mount -o remount,rw /sysroot
6 Change the root directory
chroot /sysroot
7 Change password
passwd
8 Create file autorelabel to enable the SELinux relabeling process on the
next boot.
touch /.autorelabel
9 Write exit and press enter.
10
Write exit and press ENTER again to start the system in normal
mode.