Skill Week 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Skill week 2

• System Booting, Boot loader.


• Configure systems to boot into a specific target automatically
• Install and update software packages from Red Hat Network, a remote repository, or
from the local file system
• Manage networking & Security: Configure IPv4 and IPv6 addresses

Boot, reboot, and shut down a system normally

Provide the commands to boot, reboot, and shut down a Linux system. Explain the difference
between the commands shutdown, reboot, and halt.

Boot
Booting a Linux system typically involves powering on the machine. This is usually done
through the physical power button on the hardware. However, if you have a virtual machine or
a remote system, the boot process may be initiated through the virtualization or remote
management tools.

Reboot
To reboot a Linux system, you can use one of the following commands:

$ sudo reboot

or

$ sudo shutdown -r now

or

$ sudo init 6

Shut Down

To shut down a Linux system, you can use one of the following commands:

$ sudo shutdown -h now

or

$ sudo poweroff

or

$ sudo halt
Difference Between shutdown, reboot, and halt

shutdown:

The shutdown command can be used to power off or reboot the system. It can schedule a
shutdown or reboot at a specific time.

Syntax for shutdown:

sudo shutdown [OPTIONS] [TIME] [MESSAGE]

-h option: halt the system (power off).

-r option: reboot the system.

Example: $ sudo shutdown -h now will halt the system immediately.

reboot:
The reboot command is a straightforward way to restart the system. It is essentially
equivalent to shutdown -r now.
It does not provide options for scheduling but directly triggers an immediate reboot.
halt:
The halt command stops all processes but does not necessarily power off the machine,
depending on the system configuration. It is often used to bring the system to a halt state.
When used without options, it can leave the system in a halted state without cutting power.
Practical Examples
Immediate Shutdown:

$ sudo shutdown -h now

This will power off the system immediately.

Scheduled Shutdown:

$ sudo shutdown -h +10 "System will shut down in 10 minutes"

This will schedule a shutdown in 10 minutes and broadcast a message to all logged-in users.

Immediate Reboot:

$ sudo reboot

This will reboot the system immediately.

Immediate Halt:

$ sudo halt

This will halt the system immediately.


Power Off System:

$ sudo poweroff

This will power off the system immediately.

These commands are essential for managing the operational state of a Linux system and are
commonly used by system administrators to ensure proper maintenance and control over the
system's uptime and performance.

Boot Loader:
In CentOS/RHEL systems, the primary bootloader used is GRUB (GRand Unified Bootloader).
GRUB is responsible for loading the Linux kernel and initializing the operating system during
the boot process. This guide covers the basic concepts of GRUB, its configuration, and
common tasks such as updating and troubleshooting.

GRUB Basics

1. Configuration File: The main configuration file for GRUB 2 is located at


/etc/default/grub.
2. GRUB Directory: Additional GRUB configuration files and modules are stored in
/boot/grub2/.
3. GRUB Command: The grub2-mkconfig command is used to generate the GRUB
configuration file.

Steps to Boot a Linux System into Rescue Mode

1. Access the Boot Menu:


o Restart your computer.
o During the boot process, access the boot menu by pressing a key (usually Esc,
F2, F10, F12, Del, or another key, depending on your system's BIOS/UEFI).
2. Select the Appropriate Boot Option:
o From the boot menu, choose the option to boot from your Linux installation
media (CD/DVD/USB). If you're using a live CD/DVD/USB, make sure it is
inserted into the computer.
3. Boot from Installation Media:
o If you are using a live CD/DVD/USB, select the "Rescue a broken system"
option. This option may vary depending on the Linux distribution. For
example, in CentOS or RHEL, it might be labeled "Troubleshooting" or
"Rescue mode."
4. Follow the On-Screen Instructions:
o The system will boot into a minimal environment. Follow the prompts to
continue. You may be asked to select a language and keyboard layout.
5. Select Rescue Mode:
o You may be presented with multiple options. Choose the one that indicates
rescue mode or troubleshooting. This will typically load a minimal root shell
with essential utilities for system repair.
6. Mount the File System:
o Once in rescue mode, you might need to manually mount the file system. This
can usually be done by selecting the appropriate option
Booting into Different Targets
Targets are used to group together sets of services and dependencies, effectively
controlling the state of the system.

Check the Current Target:

$ systemctl get-default

This command will show the default target that the system boots into.

List Available Targets:

$ systemctl list-units --type=target

List All Services:

$ systemctl list-units --type=service

List Running Services:

$ systemctl list-units --type=service --state=running

Get Detailed Information About a Service:

$ sudo systemctl show <service_name>

Check Boot Log:

$ journalctl -b

Check Logs for a Specific Service:

$ journalctl -u <service_name>

Manage Services with service Command:

Start a service:

$ sudo service <service_name> start

Stop a service:

$ sudo service <service_name> stop

Restart a service:

$ sudo service <service_name> restart

Check the status of a service:

$ sudo service <service_name> status


Install and update software packages from Red Hat
Network, a remote repository, or from the local file
system
On Red Hat-based systems (such as RHEL and CentOS), the yum and dnf package managers
are used to install, update, and manage software packages. yum is used in older versions of
RHEL/CentOS, while dnf is the default package manager in newer versions.

Using yum (for older versions of RHEL/CentOS)

Install a Package from Red Hat Network or a Remote Repository:

$ sudo yum install package_name

Example:

$ sudo dnf install httpd

Update a Package from Red Hat Network or a Remote Repository:

$ sudo yum update package_name


Example:
$ sudo dnf update httpd
Install a Package from a Local File:

$ sudo yum localinstall /path/to/package.rpm

Example:

$ sudo dnf localinstall /path/to/package.rpm

Update All Packages:

$ sudo yum update

Example:

$ sudo dnf update


Configure IPv4 and IPv6 addresses
Configuring IPv4 and IPv6 addresses on CentOS/RHEL systems can be done using the
‘nmcli’ command-line tool or by manually editing the network configuration files.
Using nmcli

List Available Network Connections:

$ nmcli con show

Configure an IPv4 Address:

nmcli con modify <connection_name> ipv4.addresses <ip_address>/<prefix>

nmcli con modify <connection_name> ipv4.gateway <gateway_ip>

nmcli con modify <connection_name> ipv4.dns <dns_ip>

nmcli con modify <connection_name> ipv4.method manual

nmcli con up <connection_name>

Example:

Using Configuration Files

Locate the Network Configuration File:

The configuration files for network interfaces are located in /etc/sysconfig/network-


scripts/.

Configure an IPv4 Address:

Open the configuration file for your network interface, for example, ifcfg-eth0.

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

Add or update the following lines:

DEVICE=eth0

BOOTPROTO=none

ONBOOT=yes

IPADDR=192.168.1.100
PREFIX=24

GATEWAY=192.168.1.1

DNS1=8.8.8.8

Configure an IPv6 Address:

Open the same configuration file for your network interface.

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

Add or update the following lines:

IPV6INIT=yes

IPV6ADDR=2001:db8::1/64

IPV6_DEFAULTGW=2001:db8::fffe

DNS1=2001:4860:4860::8888

Restart the Network Service:

$ sudo systemctl restart network

Verification

Check IPv4 Address:

$ ip addr show eth0

Check IPv6 Address:

$ ip -6 addr show eth0

By using either ‘nmcli’ or manually editing the configuration files, you can configure both IPv4 and
IPv6 addresses on CentOS/RHEL systems. The choice between these methods depends on your
preference and the specific requirements of your environment.
Tasks to be done by student in RHA Portal/ Oracle VM (CentOS)

Describe the steps and provide the command to install the httpd package
1
from the Red Hat Network using dnf.

How would you update the httpd package to the latest version available in
2
the configured remote repository using dnf? Provide the command.

You have downloaded an RPM package named example.rpm to your


3 /home/user/ directory. Describe the steps and provide the command to
install this package using dnf.

Configure an IPv4 address on a network interface using the nmcli


4
command-line tool.

Configure an IPv4 address on a network interface by editing network


5
configuration files.

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