You are on page 1of 91

1

COMPTIA
LINUX+
STUDY
NOTES

Copyright 2023+ Cyber Life All Rights Reserved


2

These study notes are owned and


distributed by Cyber Life. You may not
copy or redistribute these notes in a
commercial capacity or via social media
or any other electronic/physical format
without the express written consent
of Cyber Life.

CompTIA is a registered trademark of CompTIA. Linux+ is formerly a registered


trademark of CompTIA, but the trademark has expired. You can learn more about
CompTIA trademarks on the USPTO trademark search (TESS) website.

Copyright 2023+ Cyber Life All Rights Reserved


3

Table of Contents
Performing Basic Linux Tasks ...................................................................................................... 6
Identify the Linux Design Philosophy ........................................................................................ 6
Enter Shell Commands ............................................................................................................. 7
Get Help with Linux ................................................................................................................... 9
Managing Users and Groups ...................................................................................................... 10
Assume Superuser Privileges ................................................................................................. 10
Create, Modify, and Delete Users ........................................................................................... 11
Create, Modify, and Delete Groups ......................................................................................... 12
Query Users and Groups ........................................................................................................ 13
Configure Account Profiles ...................................................................................................... 14
Managing Permissions and Ownership ...................................................................................... 15
Modify File and Directory Permissions .................................................................................... 15
Modify File and Directory Ownership ...................................................................................... 16
Configure Special Permissions and Attributes ........................................................................ 16
Troubleshoot Permissions Issues ........................................................................................... 17
Managing Storage ....................................................................................................................... 18
Create Partitions ...................................................................................................................... 18
Manage Logical Volumes ........................................................................................................ 19
Mount File Systems ................................................................................................................. 20
Manage File Systems .............................................................................................................. 21
Navigate the Linux Directory Structure .................................................................................... 22
Troubleshoot Storage Issues .................................................................................................. 23
Managing Files and Directories .................................................................................................. 26
Create and Edit Text Files ....................................................................................................... 26
Search for Files ....................................................................................................................... 27
Perform Operations on Files and Directories .......................................................................... 28
Process Text Files ................................................................................................................... 29
Manipulate File Output ............................................................................................................ 30
Managing Kernel Modules .......................................................................................................... 32
Explore the Linux Kernel ......................................................................................................... 32
Install and Configure Kernel Modules ..................................................................................... 33
Monitor Kernel Modules .......................................................................................................... 34

Copyright 2023+ Cyber Life All Rights Reserved


4

Managing the Linux Boot Process .............................................................................................. 35


Configure Linux Boot Components ......................................................................................... 35
Configure GRUB 2 .................................................................................................................. 37
Managing System Components .................................................................................................. 39
Configure Localization Options ............................................................................................... 39
Configure GUIs ........................................................................................................................ 40
Manage Services ..................................................................................................................... 41
Troubleshoot Process Issues .................................................................................................. 43
Troubleshoot CPU and Memory Issues .................................................................................. 45
Managing Devices ...................................................................................................................... 47
Identify the Types of Linux Devices ......................................................................................... 47
Configure Devices ................................................................................................................... 48
Monitor Devices ....................................................................................................................... 49
Troubleshoot Hardware Issues ............................................................................................... 50
Managing Networking ................................................................................................................. 52
Identify TCP/IP Fundamentals ................................................................................................ 52
Identify Linux Server Roles ..................................................................................................... 54
Connect to a Network .............................................................................................................. 56
Configure DHCP and DNS Client Services ............................................................................. 57
Configure Cloud and Virtualization Technologies ................................................................... 59
Troubleshoot Networking Issues ............................................................................................. 61
Managing Packages and Software ............................................................................................. 62
Identify Package Managers ..................................................................................................... 62
Manage RPM Packages with YUM ......................................................................................... 63
Manage Debian Packages with APT ....................................................................................... 64
Configure Repositories ............................................................................................................ 65
Acquire Software ..................................................................................................................... 66
Build Software from Source Code ........................................................................................... 67
Troubleshoot Software Dependency Issues ............................................................................ 68
Securing Linux Systems ............................................................................................................. 70
Implement Cybersecurity Best Practices ................................................................................. 70
Implement Identity and Access Management Methods ........................................................... 71
Configure SELinux or AppArmor ............................................................................................. 73

Copyright 2023+ Cyber Life All Rights Reserved


5

Configure Firewalls .................................................................................................................. 74


Implement Logging Services ................................................................................................... 75
Back Up, Restore, and Verify Data ......................................................................................... 76
Working with Bash Scripts .......................................................................................................... 78
Customize the Bash Shell Environment .................................................................................. 78
Identify Scripting and Programming Fundamentals ................................................................ 80
Write and Execute a Simple Bash Script ................................................................................. 81
Incorporate Control Statements in Bash Scripts ..................................................................... 82
Automating Tasks ....................................................................................................................... 84
Schedule Jobs ......................................................................................................................... 84
Implement Version Control Using Git ...................................................................................... 85
Identify Orchestration Concepts .............................................................................................. 88
Installing Linux ............................................................................................................................ 89
Prepare for Linux Installation ................................................................................................... 89
Perform the Installation ........................................................................................................... 90

Copyright 2023+ Cyber Life All Rights Reserved


6

Performing Basic Linux Tasks

Identify the Linux Design Philosophy


Linux Design Philosophy

● Linux's history is guided by a philosophy of openness and transparency.


● Open-source software (OSS) is at the core of Linux's design philosophy.
● OSS grants users the right to view, copy, modify, and distribute code freely.
● Open-source software encourages collaborative development in a community-driven
environment.

Free Software vs. Open-Source Software

● While often used interchangeably, some distinguish between the terms. Free software
emphasizes user rights, while open source focuses on collaboration.
● "Free" here refers to freedom, not monetary cost.
● The term "free and open source software" (FOSS) is used to encompass both values.

Free Software Foundation and the GNU GPL

● The GNU Project, led by Richard Stallman, initiated the free software movement.
● The GNU General Public License (GPL) enforces copyleft, meaning derivatives must
also be under the same license.

The Unix Philosophy

● Linux adheres to the Unix philosophy, emphasizing simplicity, modularity, and individual
tools that do one thing well.
● Interactivity, handling input/output streams, and favoring limited functionality are key
aspects.

The Linux Operating System Family

● Linux is a family of operating systems based on the Linux kernel.


● Developed by Linus Torvalds in 1991, it was combined with GNU software to create a
complete FOSS operating system.

GNU/Linux

Copyright 2023+ Cyber Life All Rights Reserved


7

● Some prefer to call it "GNU/Linux" to acknowledge GNU's contribution.


● However, "Linux" remains the more common term.

Advantages of Using Linux

● Promotes transparency due to its FOSS nature.


● Emphasizes simplicity and modularity in design.
● Highly customizable, reliable, and stable.
● Strong integration with programming languages and a focus on security and privacy.
● Supported by a passionate community and often available at no monetary cost.

Disadvantages of Using Linux

● Has a steeper learning curve compared to other general-purpose operating systems.


● Desktop software support may not be as robust as in Windows and macOS.
● Lack of a definitive or official version can be confusing for new users.
● Official vendor-provided support is limited.

Linux Distributions

● Instead of an official "Linux" OS, there are various Linux distributions (distros) based on
the Linux kernel.
● Distros differ in the software they add on top of the kernel, community support, release
schedules, and more.
● Some popular distros include Slackware, Debian, Ubuntu, Kali Linux, Red Hat, CentOS,
Fedora, openSUSE, and Arch Linux.

Uses for Linux

● Linux is applied to various computing roles, including servers, workstations, mainframes,


supercomputers, mobile devices, personal computers, and embedded systems.
● It dominates the server and supercomputer markets and is the basis for the Android
mobile operating system.

Enter Shell Commands


The CLI (Command-Line Interface)

● In Linux, users interact with the system through text commands entered at a prompt.
● The CLI presents a command prompt, and users enter commands to interact with the
system.

Copyright 2023+ Cyber Life All Rights Reserved


8

● Command-line administration is vital for Linux administrators, while regular users often
rely on graphical interfaces.

CLI Advantages and Challenges

● Advantages: Speed, scriptability, scheduling, additional options, and consistency.


● Challenges: Learning curve, complex commands, misperceptions, and different CLI
environments.

Shells

● A shell acts as an interpreter between users and the kernel, facilitating command input
and output.
● Common CLI-based shells include Bourne shell (sh), Bash (bash), C shell (csh),
KornShell (ksh).

Bash (Bourne-Again Shell)

● Bash is the default Linux shell, widely used and well-documented.


● It is not always consistent due to numerous modifications.
● Bash includes history and tab completion features.

Bash Syntax

● Bash command syntax comprises the command, options, and arguments.


● Square brackets denote optional components, and curly brackets denote required
components.

Errors

● Bash returns descriptive error messages to help users understand issues.


● Common errors include "command not found" and "no such file or directory."

Basic Bash Commands

● Essential commands: echo, ls, pwd, cd, touch, cp, mkdir.


● File viewing commands: cat, less.
● File editing commands: vim, nano, gedit.
● Power management commands: shutdown, reboot, sleep.

Superuser Commands

● The superuser (root) is used for administrative tasks.


● The su - command switches user credentials to root.
● It's recommended to use a non-privileged account for everyday tasks.

Shell History

Copyright 2023+ Cyber Life All Rights Reserved


9

● Bash keeps a history file of entered commands.


● Users can reference this history, view recent commands, and reuse them.

Tab Completion

● Bash supports tab completion for quick and error-free command, file, and directory input.

Shell Tips and Tricks

● Use tab completion for speed and accuracy.


● Utilize the history command to access and repeat recent commands.
● Read commands backward to spot errors.
● Clear the screen with clear to start a new task with a clean slate.

Get Help with Linux


Help Option Description

● whatis: Displays a brief description of a given command.


● info: Displays the info page of a command, an alternative to man pages.
● --help: Displays a quick summary of a command's usage and arguments.

/usr/share/doc/

● Contains documentation for libraries, system utilities, and software packages.


● Each software package has its subfolder with relevant documentation.

Online Documentation

● Official distro documentation: Provided by popular Linux distributions for specific distro-
related information.
● Linux Documentation Project (LDP): Offers comprehensive Linux documentation,
including HOWTOs, Guides, FAQs, and more.
● Linux man-pages project: Provides official man pages for Linux kernel and C library
interfaces.
● GNU coreutils manual: The source for documentation on GNU core utilities included in
Linux distributions.

Interactive Help

Copyright 2023+ Cyber Life All Rights Reserved


10

● Usenet newsgroups: Online discussion repositories, some focused on providing Linux


help.
● Mailing lists: Threaded discussions among community members through email
messages.
● Q&A websites: Platforms for posting questions and receiving answers or comments from
other users, such as Stack Exchange.
● Forums and social media: Internet forums and social media platforms where users can
post questions and receive guidance.

Managing Users and Groups

Assume Superuser Privileges


User Accounts

● Accounts represent users and services in Linux.


● User accounts have attributes like passwords, group memberships, comments, etc.
● Three types of accounts: root (superuser), standard user, and service accounts.

Superuser

● Root account serves as the local administrator and security context for some
applications.
● Logging in directly as the root user is discouraged due to its extensive privileges.
● "Principle of Least Privilege" suggests giving users the minimum necessary access for
their tasks.

The su Command

● Used to switch between user identities, allowing users to act as root.


● The su - command launches a new shell as the target user.
● The syntax is su [-] [user name].

The sudo Command

● Delegates specific commands to users, avoiding granting full root privileges.

Copyright 2023+ Cyber Life All Rights Reserved


11

● Configuration is done in the /etc/sudoers file using the visudo editor.


● The syntax is sudo [options] {command}.

The sudoedit Command

● Enables users to edit files with their credentials, even if the file requires root privileges.
● Must be configured in the /etc/sudoers file.
● The syntax is sudoedit [options] {file name}.

The visudo Command

● Used to edit the /etc/sudoers file securely to avoid syntax errors.


● Syntax: visudo [options].

The wheel Group

● Many Linux distributions disable the root account for users and grant administrative
privileges through the wheel group.
● Members of the wheel group can use sudo to perform administrative tasks.
● Membership in the wheel group should be carefully controlled.

Create, Modify, and Delete Users


The useradd Command

● Used for creating user accounts and configuring basic settings.


● Default settings for the account are stored in /etc/login.defs.
● Home directories are created under /home by default.
● The useradd command does not set a password by default.
● Syntax: useradd [options] [user name].

The passwd Command

● Used for setting or resetting user passwords.


● Users can change their passwords themselves using this command.
● Also used to set the initial password when creating an account.
● Syntax: passwd [user name].

The /etc/passwd File

● Stores user account information.


● Contains fields: User name, Password (usually 'x'), User ID, Group ID, Comment (full
name), Home directory, and Login shell.

Copyright 2023+ Cyber Life All Rights Reserved


12

● Properly edited using user management commands, not manual editing.

The /etc/shadow File

● Modern storage location for hashed passwords and additional account info.
● Only root has access to its content for enhanced security.
● Prevents users from accessing each other's password hashes.

The /etc/shadow File Format

● Fields include User name, Password hash, Days since password changed (from 01-01-
1970), Days before password must be changed, Days until user is warned to change
password, Days after password expires for account disablement.

Create, Modify, and Delete Groups


Group Accounts

● Groups associate user accounts with similar security requirements.


● Simplify administrative tasks and resource access.
● Represented by a Group ID (GID).
● Users can be members of multiple groups.

The /etc/group File

● Stores group information.


● Contains fields: Group name, Password (usually 'x'), Group ID (GID), Group list
(members).
● Properly edited using group management commands, not manual editing.

The groupadd Command

● Creates a group.
● By default, the group has no members and no password.
● Syntax: groupadd [options] [group names].

The groupmod Command

● Used to modify group attributes.


● Can change the group's name or GID.

Copyright 2023+ Cyber Life All Rights Reserved


13

● Syntax: groupmod [options] [group names].

The groupdel Command

● Deletes groups from the /etc/group file.


● Does not delete user accounts that are members of the group.
● Exercise caution when deleting groups.

Query Users and Groups


whoami Command:

● whoami displays the current user's name.


● Useful for checking the user you're logged in as.

who Command:

● who provides details about users currently logged into the system.
● Shows user names, system names, and login times.
● Use -u option to see how long users have been idle.

w Command:

● w displays details of currently logged-in users and their activities.


● Includes user names, terminal, login time, and current activities.
● Great for tracking user activity in real-time.

last Command:

● last shows login/logout history, time, and date for users.


● Retrieves data from /var/log/wtmp.
● Can filter users or terminals using options.

id Command:

● id displays user ID (UID) and group ID (GID) information.


● Without options, it shows info for the currently logged-in user.
● Specify a username to view information for other users.

Copyright 2023+ Cyber Life All Rights Reserved


14

Configure Account Profiles


.bashrc File:

● Located in the user's home directory.


● Customizes a user's environment.
● Used for aliases, environment variables, and customizing the command prompt.
● User-specific and hidden (prefixed with a dot).

.bash_profile File:

● Provides shell configuration for the initial login environment.


● Only read during the first login.
● User-specific, not applied to all shells.
● Default .bash_profile can be set in the /etc/skel directory.

/etc/skel/ Directory:

● Contents copied to new users' home directories.


● Used for configuring initial settings for new users.
● Changes made after user creation won't affect existing users.

/etc/profile File:

● Provides system-wide environment variables.


● Read during initial login for all users.
● Global settings for Bash shell.
● User-specific settings are pulled from the .profile file in the home directory.

/etc/profile.d/ Directory:

● Storage for scripts to set system-wide variables.


● Recommended for setting environment variables.

/etc/bashrc File:

● Provides system-wide Bash settings.

Copyright 2023+ Cyber Life All Rights Reserved


15

Managing Permissions and Ownership

Modify File and Directory Permissions


ls -l Command:

● Lists files and directories with permission information.


● Displays columns with permission string, number of links, owner, group, size, date, and
name.
● Permissions are categorized into owner, group, and others.

Permission Attributes:

● Read (r): Access and view files or list directory contents.


● Write (w): Save changes to files or create/rename/delete files in directories.
● Execute (x): Run files or access directories and perform tasks (e.g., search).

Permission Contexts:

● Owner (u)
● Group (g)
● Other (o)

Permission String:

● Displays file type (d for directory, - for file).


● Followed by owner, group, and other permissions.
● Plus (+) and period (.) represent SELinux security context.

chmod Command:

● Used to modify file or directory permissions.


● Syntax: chmod [options] {mode} {file/directory name}.
● Supports options like -c, -f, -v, -R for recursive changes.

Symbolic Mode:

● Uses symbolic components: u/g/o/a, +/-/=, r/w/x.


● Examples: chmod u+rw,g+rw myfile, chmod a+x script.

Absolute Mode:

● Uses octal numbers (base-8) to specify permissions.


● Example: chmod 755 file (owner: rwx, group: rx, others: rx).

Copyright 2023+ Cyber Life All Rights Reserved


16

Three-Digit and Four-Digit Modes:

● Commonly represented as three digits: user/group/others.


● May also use four digits for advanced permissions (0 for none).
● Example: 0666 (rw-rw-rw-).

Modify File and Directory Ownership


Ownership:

● Ownership determines who can apply and modify permissions on a file or directory.
● The owner of a file or directory is the user who created it.
● By default, only the owner (or superuser) can change the permissions of an object.

chown Command:

● Used to change the owner, group, or both for a file or directory.


● Syntax: chown {user name} {file/directory name}, chown {user
name}:{group name} {file/directory name}, etc.
● -R option enables recursive ownership changes in a directory structure.

chgrp Command:

● Used to change the group ownership of a file or directory.


● Syntax: chgrp {group name} {file/directory name}.

Configure Special Permissions and Attributes


Special Permissions:

● Special permissions are used when normal permissions are not enough.
● They allow users to execute files with the privileges of the file's owner or group
temporarily.

SUID and SGID Permissions:

● SUID (Set User ID) allows users to execute a file with the privileges of the owner.
● SGID (Set Group ID) allows users to execute a file with the privileges of the group
owner.
● These permissions are set using chmod and are indicated by "s" in the execute position.

Sticky Bit:

Copyright 2023+ Cyber Life All Rights Reserved


17

● Sticky bit ensures that only the owner or root can delete a file or directory.
● Set using chmod and indicated by "t" or "T" (if execute permission is not set) in the
execute position.

File Attributes:

● File attributes allow you to customize the system's interaction with files.
● Examples include read-only, automatic compression, saving when deleted, and
immutability.

Immutable Flag:

● The immutable flag prevents files from being modified, even by the root user.
● Set with chattr and shown as "i" in file attributes.

Access Control Lists (ACLs):

● ACLs allow for more granular control over permissions beyond traditional owner and
group.
● getfacl retrieves ACL information, and setfacl modifies ACLs.
● ACLs are formatted as "u:{user}:{permissions}" for users and "g:{group}:{permissions}"
for groups.

Troubleshoot Permissions Issues


Troubleshooting Models:

● Troubleshooting involves recognizing, diagnosing, and resolving problems efficiently.


● Various troubleshooting models exist, and they aim to help you address problems
systematically.
● A common troubleshooting model includes identifying the problem, establishing a theory
of probable cause, testing the theory, planning a solution, implementing it, verifying
system functionality, and documenting the process.

Permissions Troubleshooting:

● When facing permissions issues, verify object permissions and ownership using the ls
-al command.
● Ensure users have the necessary permissions and do not have access beyond what
they should.
● Check for the immutable flag, SUID permissions for executables, and sticky bits on
directories.
● Ensure correct owner and owning group settings.
● Set the SGID permission on a directory to make new files inherit its group ownership.
● Use groups {user name} to check a user's group membership.

Copyright 2023+ Cyber Life All Rights Reserved


18

● Modify group membership when needed to grant or restrict access to specific users.

Remember that following a structured troubleshooting approach is essential for efficiently


identifying and resolving permissions issues. The ls -al command is your first tool for
checking permissions and ownership, and you can use various other commands and techniques
to address specific issues.

Managing Storage

Create Partitions
● Setting XFS file system labels: Use the command xfs_admin -L {label name}
/dev/{device name}{partition number}.
● Partitions: Divisions of storage drives that act as separate logical drives, enhancing data
organization. Partitions need formatting and file system assignment.
● Partition Tables: Used to identify partitions; stored in the drive. Partition size cannot
exceed free space.
● Types of Partitions: Three types - Primary (one file system or logical drive, e.g., boot
partition), Extended (contains logical drives), Logical (created within an extended
partition, no set limit but typically limited to 12 per drive).
● Swap Space: A partition for out-of-memory situations, typically twice the RAM capacity.
● fdisk Utility: Menu-driven tool for partition management, supporting DOS and Linux
partition tables.
● fdisk Syntax: fdisk [options] {device name}
● GNU Parted: Useful for creating, destroying, and resizing partitions.
● GNU Parted Syntax: parted [options] {device name}
● partprobe Command: Updates the kernel with changes in the partition table without
rebooting.
● partprobe Syntax: partprobe [options] [device name]
● mkfs Command: Builds a Linux file system on a device or partition.
● mkfs Syntax: mkfs [options] {device name}
● fstab File: Stores information on storage devices and partitions to specify where and how
partitions should be mounted.
● /dev/ Directory: Contains files representing and supporting attached devices, following
naming conventions.
● /dev/disk/by- Identifiers: Persistent naming schemes like by-id, by-path, and by-uuid
used to identify devices more predictably.

Copyright 2023+ Cyber Life All Rights Reserved


19

Manage Logical Volumes


Device Mapping:

● Device mapping is the process of abstracting physical storage devices into virtual
storage devices.
● Linux uses the device mapper to create virtual devices and manage data transfer
between virtual and physical devices.
● Device mapper is used for tasks like volume encryption and integrity checking services.

DM-Multipath:

● DM-Multipath is a Linux kernel feature that enhances redundancy and performance for
block storage devices.
● It uses the device mapper to provide multiple I/O paths between the CPU and storage
devices.
● If one path fails, DM-Multipath switches to another available path, ensuring device
availability for reading and writing.

mdadm Command:

● mdadm is a tool for managing software-based RAID (Redundant Array of Independent


Disks) arrays.
● RAID arrays store data across multiple physical storage devices, creating a single virtual
storage device.
● mdadm allows the creation, management, and monitoring of RAID arrays.

Logical Volume Manager (LVM):

● LVM is an application of the device mapper that maps physical devices and partitions
into virtual containers called volume groups.
● Volume groups contain one or more logical volumes, which become the storage devices.
● LVM advantages include dynamic volume operations, easier management, mapping
across multiple physical devices, and creating snapshots.

/dev/mapper/ Directory:

● Contains all logical volumes managed by LVM.


● Logical volumes are typically formatted as /dev/mapper/<volume group name>-
<logical volume name>.

LVM Tools:

● LVM tools are categorized into physical volume (PV) tools, volume group (VG) tools, and
logical volume (LV) tools.

Copyright 2023+ Cyber Life All Rights Reserved


20

● PV tools include pvscan, pvcreate, pvdisplay, pvchange, pvs, pvck, and


pvremove.
● VG tools include vgscan, vgcreate, vgdisplay, vgchange, vgs, vgck, vgrename,
vgreduce, vgextend, vgmerge, vgsplit, and vgremove.
● LV tools include lvscan, lvcreate, lvdisplay, lvchange, lvs, lvrename,
lvreduce, lvextend, lvresize, and lvremove.

Mount File Systems


Mount Points:

● A mount point is an access point to information stored on a local or remote storage


device.
● It is typically an empty directory where a file system is loaded or mounted to make the
data accessible.
● If the directory already has content, it becomes invisible to users until the mounted file
system is unmounted.

The mount Command:

● The mount command is used to load a file system to a specified directory to make it
accessible to users and applications.
● You need to specify both the device to mount and the desired mount point.
● Mount options, such as auto, noauto, nouser, user, exec, noexec, ro, rw, sync, and
async, can be specified.
● These options are often included in the /etc/fstab file for automatic mounting during
system startup.

Binaries:

● Binaries are source code compiled into executable programs or files readable by the
computer system.

The umount Command:

● The umount command is used to unmount a file system after it has been mounted.
● The file system must not be in use when unmounting.
● Common umount command options include -f (force unmounting despite issues), -l
(perform a "lazy" unmount), -R (recursively unmount directories), -t {fs type}
(unmount specific file system types), -O {mount options} (unmount file systems with

Copyright 2023+ Cyber Life All Rights Reserved


21

specified options in /etc/fstab), and --fake (test unmounting without actually


performing it).

Manage File Systems


The /proc/mounts File:

● Lists the status of all currently mounted file systems in a format similar to fstab.
● Represents the status of mounted objects as reported by the Linux kernel.
● Used to obtain details about currently mounted file systems.

The mtab File:

● Similar to /proc/mounts, it reports the status of currently mounted file systems.


● /proc/mounts is typically more accurate and up-to-date.

The /proc/partitions File:

● Contains information about each partition currently attached to the system.


● Provides information like major, minor, number of blocks, and partition names.

The lsblk Command:

● Displays information about all block storage devices available on the system.
● Provides details such as names, major and minor numbers, size, device type, and mount
points.

The blkid Command:

● Similar to lsblk, it prints each block device in a flat format and includes additional
information like device/partition UUID and file system type.
● Use lsblk -f for additional information.

Tools for Managing Ext File Systems:

● Tools for managing ext file systems, such as ext2, ext3, and ext4, include e2fsck,
resize2fs, tune2fs, and dumpe2fs.

The fsck Command:

● Checks the integrity of a file system.


● File system errors are usually caused by power failures, hardware failures, or improper
shutdown.
● Unmount the file system before scanning with fsck.

Copyright 2023+ Cyber Life All Rights Reserved


22

The resize2fs Command:

● Enlarges or shrinks an ext2/3/4 file system on a device.


● Must unmount the file system before shrinking it.

The tune2fs Command:

● Configures tunable parameters associated with an ext2/3/4 file system.


● Parameters include reserved blocks, mount checks, time intervals, and more.

The dumpe2fs Command:

● Dumps ext2, ext3, and ext4 file system information, including superblock and block
group information.
● Useful for troubleshooting faulty file systems.

XFS Tools:

● Tools for working with the XFS file system include xfs_info, xfs_admin,
xfs_metadump, xfs_growfs, xfs_copy, and xfs_repair.

Navigate the Linux Directory Structure


Types of Files

● Linux file system includes regular files (text, executables), directories, special files (block
or character), links, domain sockets, and named pipes.
● Represented by letters in the ls -l command output (d for directories, b/c for special
files, l for links, s for domain sockets, p for named pipes).

The file Command

● Used to determine the type of a file.


● Syntax: file [options] {file names}.

File Naming Conventions

● File names can be up to 255 bytes on ext4 filesystems.


● Avoid using NULL (\0) and forward slash (/) in file names.
● Convention: demarcate words with hyphen or underscore for easier command-line
management.

Copyright 2023+ Cyber Life All Rights Reserved


23

Filesystem Hierarchy Standard (FHS)

● Standardizes file and directory names/locations for Linux distributions.


● Root directory (/) at the top, followed by various standardized subdirectories (e.g., /bin,
/etc, /home, /lib).

Home Directory

● Contains personal files specific to a user.


● Root user's home directory is /root.

Current Working Directory

● Location you are accessing at a given time.


● Represented by a single period (.).
● Use pwd to display it.

Parent Directory

● Directory one level above the current working directory.


● Represented by double period (..).

Paths

● Specify file/directory locations in the file system.


● Absolute paths begin with a forward slash (/).
● Relative paths are based on the current working directory and may include . (current
directory) and .. (parent directory).

File System Navigation Commands

● cd: Change the current working directory.


● ls: List files and directories.
● pwd: Print the current working directory.

Troubleshoot Storage Issues


Symptom: Degraded Storage

● Degraded storage occurs when a storage drive in a RAID array has failed.

Copyright 2023+ Cyber Life All Rights Reserved


24

● Depending on the RAID type, the system may still function with reduced performance.
● The failed drive can be replaced to restore optimal performance.

Symptom: Performance Issues

● Investigating storage performance issues begins with considering the technology in use.
● Workstations may use SATA hard drives or SSDs, while servers typically use more
efficient options like SCSI, SAS, or SSDs, often in RAID arrays.
● Failing disks, controllers, or hardware components can cause performance problems.

Symptom: Resource Exhaustion

● In a busy server, too many open files can lead to resource exhaustion, causing most
Linux commands to fail.
● Rebooting the server can temporarily resolve the issue.
● The ulimit command can be used to adjust the available number of file descriptors.

Symptom: Storage Integrity/Bad Blocks

● Traditional magnetic hard disk drives may develop bad blocks over time.
● Bad blocks are sections of the disk that can't be read from or written to, and the file
system marks them for exclusion.
● Too many bad blocks can diminish performance and capacity, indicating a failing hard
disk drive that should be replaced.

Storage Space Tracking:

● df (disk free) command shows device free space, file system, total size, space used,
percentage used, and mount point.
● du (disk usage) command shows directory and file sizes, helping track space hogs.
● The -h option makes the output more human-friendly (e.g., in GB).

I/O Scheduling:

● I/O scheduling manages the order of input/output operations for block storage devices.
● Different scheduler types are available, including deadline, cfq, and noop.
● Changing the scheduler can help optimize performance in specific situations.

iostat Command:

● iostat generates CPU and device usage reports.


● Use -d to specify device information.
● Provides statistics like transfers per second, blocks read/written per second, and more.

ioping Command:

Copyright 2023+ Cyber Life All Rights Reserved


25

● ioping tests device I/O latency in real-time, similar to the standard ping for network
latency.
● Useful for troubleshooting latency issues.

Storage Quotas:

● Storage quotas allocate space to users.


● Quotas can have soft limits, grace periods, and hard limits.
● Exceeding soft limits during grace periods can lead to hard limits.

Quota Management Commands:

● Commands like quotacheck, edquota, and setquota are used for quota
management.
● Activate quotas by editing the fstab file.
● For XFS, use the xfs_admin utility to configure quotas.

Quota Reports:

● Reports detail user/group storage usage, soft/hard limits, and more.


● Use commands like repquota and quota for generating reports.

Additional Storage Troubleshooting Techniques:

● Troubleshooting starts with basic checks like permissions and available storage.
● Verify physical connections and system recognition of storage devices.
● Check configuration files (e.g., /etc/fstab) and tools like fsck.

Guidelines for Troubleshooting Storage Issues:

● Ensure devices are physically connected and powered.


● Verify device recognition by the system.
● Check configuration files for errors and reload them.
● Confirm storage capacity and workload.
● Use partprobe to scan for new storage devices and partitions.

Copyright 2023+ Cyber Life All Rights Reserved


26

Managing Files and Directories

Create and Edit Text Files


Text Editors

● Text editors are essential tools for viewing, creating, and modifying text files.
● They were originally designed for programming but are now used for various text-based
files.
● In Linux, many configuration components, such as system, network, kernel, and shell
configurations, are stored in text files.
● Text editors can work in both CLI and GUI environments and may have different modes
of operation.

Common Editors

● Popular text editors for Linux include Vi, Vim, Emacs, gVim, gedit, and GNU nano.
● Vim, short for Vi IMproved, is widely used and offers advanced features like text
completion, syntax highlighting, and spell checking.
● Vim operates in different modes: Insert, Execute, Command, and Visual modes.
● GNU nano is user-friendly and is less complex than Vim but lacks some advanced
features.

Using Vim

● Vim can be invoked with the vim or vi command.


● Vim has modes, including Insert, Execute, Command, and Visual modes, and you can
switch between them.
● Some important commands in Vim include :w (save), :q (quit), :q! (quit without
saving), and :wq (save and quit).
● Navigation in Vim can be done with single-key shortcuts like h, j, k, l, and many others.
● Editing operators in Vim, like x, d, p, y, are used to manipulate text.

Using GNU nano

● The nano command invokes the GNU nano text editor.


● Navigation and editing in nano are performed with shortcuts that use the Ctrl key, such
as Ctrl+G (help), Ctrl+X (exit), Ctrl+O (save), and more.
● Nano is more user-friendly than Vim and doesn't have different modes.
● Copying text in nano is done by marking the text with Ctrl+^ and then pasting with Alt+^
or Ctrl+U.

Using gedit

Copyright 2023+ Cyber Life All Rights Reserved


27

● Gedit is the default text editor for the GNOME desktop environment in Linux.
● It offers a graphical, menu-based interface, making it user-friendly.
● Gedit provides features like syntax highlighting and spell checking.
● The gedit command can be used in the CLI to open files with or without specifying a
filename.

Search for Files


The locate Command

● locate is used to search for files and directories by performing a quick search in the
mlocate database.
● The database must be regularly updated for effective searches.
● Syntax: locate [options] {string}
● Options include -r for using regular expressions, -c to display the number of matching
entries, and more.

The updatedb Command

● updatedb builds and updates the mlocate database based on the


/etc/updatedb.conf file.
● The configuration file (/etc/updatedb.conf) specifies paths to exclude from the
database.
● Regularly updating the database is crucial for an accurate search with the locate
command.

The find Command

● find allows you to search for files and directories based on specific criteria, recursively
throughout a directory structure.
● Syntax: find [options] {search locations} {search criteria}
[actions]
● Provides more precise and live searching compared to locate.
● You can perform actions on the found results using options like -print, -exec, -ok,
and -delete.

Comparison: find vs. locate Commands

Copyright 2023+ Cyber Life All Rights Reserved


28

● locate uses a pre-built database for faster but potentially outdated results.
● find performs live searches with more specific criteria and can take longer.

The which Command

● which displays the complete path of a specified command by searching the directories
assigned to the PATH variable.
● Useful for locating where a program is installed and identifying which version of a
command you're using.

The whereis Command

● whereis is used to display various details associated with a command.


● Provides information about the location of a command, manual pages, and sources.
● Options include -b to search only for binaries, -m for manual sections, and more.

Perform Operations on Files and Directories


The cat Command

● The cat command is used to display, combine, and create text files.
● It is commonly used to display the contents of small text files.
● Options include -n to number lines, -s to suppress output of repeated empty lines, and
more.

The head and tail Commands

● head displays the first 10 lines of a file, while tail displays the last 10 lines.
● Useful for quickly checking the beginning or end of a file.
● You can use options like -n to specify a different number of lines.

The less and more Commands

● Both less and more are used to display file contents and page through them if they
extend beyond the screen.
● less typically has more features and is preferred.
● Navigation includes arrow keys, searching, and pressing q to quit.

File Copy and Move: cp and mv Commands

Copyright 2023+ Cyber Life All Rights Reserved


29

● cp copies files and directories, while mv moves files and directories.


● To copy directories, use -R to copy recursively.
● mv can also rename files by specifying a new name.

The touch Command

● touch is used to change the access or modification time of a file to the current time or
create an empty file.
● Useful for testing permissions and creating files.

File Removal: rm and unlink Commands

● rm removes files and directories. Use -R to remove directories with contents.


● unlink removes one file at a time but can't remove directories.

The ls Command

● ls is used to list the contents of directories with various options.


● Options include -l for a long list, -a to display hidden files, and -R for recursive listing.
● Colors in ls output distinguish file types.

Directory Creation and Removal: mkdir and rmdir Commands

● mkdir creates directories with the specified names.


● rmdir removes empty directories.

Process Text Files


The cut Command

● cut is used to separate fields from text files based on a specified delimiter.
● Options include -d to specify the delimiter, -f to specify the field numbers, and -s to
suppress lines without the delimiter.

The paste Command

● paste merges lines from text files horizontally.


● By default, it uses tab space as a delimiter.

Copyright 2023+ Cyber Life All Rights Reserved


30

● You can use the -d option to specify a different delimiter.

The diff Command

● diff compares text files and displays the differences.


● Symbols like < and > indicate lines to be removed or added.
● It doesn't make changes; it suggests how to make files identical.

The grep Command

● grep searches file contents for specific patterns or strings.


● Options include -E for extended regular expressions, -i for ignoring case, and -c for
counting matching lines.

The awk Command

● awk performs pattern matching and text processing.


● Patterns and actions are specified within single quotes.
● It can be used to extract, delete, or modify text based on patterns.

The sed Command

● sed is a stream editor for text file modification.


● It can delete lines, substitute text, and more.
● Common commands include d for deleting lines and s for substitution.

The ln Command

● ln creates links to files.


● There are two types of links: hard and symbolic (soft).
● Hard links point to the same data; changes in one reflect in the other.
● Symbolic links point to different objects; changes in one don't affect the other.

Manipulate File Output


Text Streams:

● Text streams are sequences of lines of text used for reading from or writing to devices
and system components, including files, CLI, and network sockets.

Copyright 2023+ Cyber Life All Rights Reserved


31

● Three primary text streams in Linux are standard input (stdin), standard output (stdout),
and standard error (stderr).

Redirection Operators:

● >: Redirects standard output to a file, creating or overwriting the file.


● >>: Appends standard output to the end of a file.
● 2>: Redirects standard error to a file.
● 2>>: Appends standard error to the end of a file.
● &>: Redirects both standard output and standard error to a file.
● <: Reads input from a file instead of the keyboard.
● <<string: Provides input data until a line containing the specified string.
● |: Pipes, used to combine the standard I/O streams of commands.

Piping:

● Piping involves combining the standard output of one command as the standard input for
another command.
● The pipe operator | is used to connect commands together.

The xargs Command:

● xargs reads from standard input and executes a command for each argument provided.
● Useful for processing multiple arguments from standard input.

The tee Command:

● tee reads standard input, sends it to the CLI, and copies the output to specified files.
● The -a option appends output to files.

The /dev/null File:

● /dev/null discards all data written to it.


● Useful for testing commands, scripts, and suppressing error information by redirecting
error output.

Terminal Redirection:

● Terminals in Linux are assigned unique identifiers in the format /dev/tty#.


● Standard input and output can be redirected to different running processes by
referencing their /dev/tty numbers.

Copyright 2023+ Cyber Life All Rights Reserved


32

Managing Kernel Modules

Explore the Linux Kernel


1. Kernel Overview:

● The kernel is the core of an operating system, responsible for managing various aspects
of a computer system.
● It manages file system access, memory, processes, devices, and resource allocation.
● The kernel controls hardware devices and is loaded into the main memory during system
startup.
● It contains system-level commands and functions hidden from regular users.

2. Kernel Space and User Space:

● The kernel divides software running in memory into two spaces: kernel space and user
space.
● Kernel space is where the kernel executes its services, while user space includes all
other applications.
● System calls facilitate communication between user space and kernel space, allowing
user applications to access kernel resources.

3. Types of Kernels:

● Kernels can be monolithic or microkernel.


● A monolithic kernel runs all system modules, such as device drivers, in kernel space,
enabling fast device interaction but consuming more memory.
● A microkernel has a smaller kernel space, larger user space, and offers better stability
but may have lower performance.

4. Device Drivers:

● Device drivers are software programs that enable the OS to communicate with hardware
devices.
● They act as intermediaries between the operating system and hardware components.
● Device drivers can be included in the OS or installed as needed.

5. The Linux Kernel:

● The Linux kernel is a free and open-source monolithic kernel.

Copyright 2023+ Cyber Life All Rights Reserved


33

● It manages system resources and hardware devices, offering features like virtual
memory management, networking support, shared libraries, etc.
● The Linux kernel is highly modular, allowing users to configure and extend its
functionality.

6. Kernel Version History:

● The Linux kernel is continuously updated and given version numbers for identification.
● The version number format is major.minor, and it changes periodically based on major
developments.
● The uname command is used to check the kernel version and system information.

7. Kernel Layers:

● The kernel operates in several layers in kernel space.


● Layers include System Call Interface (SCI), Process Management, Memory
Management, File System Management, and Device Management.
● These layers control different aspects of the system, such as managing processes,
memory, files, and devices.

Install and Configure Kernel Modules


1. Kernel Modules:

● Kernel modules extend the functionality of the Linux kernel and can be dynamically
loaded or unloaded.
● Advantages of kernel modules include reducing kernel burden, lower memory
consumption, and the ability to update or recompile the kernel without rebooting.
● Kernel modules have the .ko file extension, and they are specific to particular kernel
versions.

2. Directory Structure for Kernel Modules:

● The /usr/lib/modules/ directory contains shared libraries and kernel modules.


● Modules are stored in subdirectories based on categories, such as architecture,
cryptography, drivers, file systems, and networking components.

3. Kernel Module Management Commands:

Copyright 2023+ Cyber Life All Rights Reserved


34

● Useful commands for managing kernel modules include lsmod to display loaded
modules, modinfo to view module information, insmod to install modules, and rmmod
to remove modules.
● The modprobe command is preferred as it can load dependent modules.

4. The depmod Command:

● The depmod command is used to update the modules dependency database, allowing
modprobe to load modules and their dependencies accurately.

5. Kernel Module Configuration:

● Configuration settings for kernel modules are stored in files with .conf extensions in the
/etc/modprobe.d/ directory.
● You can define module aliases, blacklist modules, or specify commands to run when
loading a module.

6. Kernel Parameters:

● Kernel parameters in /proc/sys/ can be modified at runtime to configure various


aspects of the Linux kernel, such as networking, security, virtual memory, and more.

7. The sysctl Command:

● The sysctl command is used to view or set kernel parameters at runtime, with options
like displaying parameters, setting parameter values, loading settings from a file, and
more.

8. The /etc/sysctl.conf File:

● The /etc/sysctl.conf file allows for configuring changes to the running Linux kernel,
including network, security, and logging settings.

Monitor Kernel Modules


1. The `/proc/ Directory:

● /proc/ is a virtual file system (VFS) that provides information about the kernel's running
processes.
● Some important files in the /proc/ directory include /proc/cmdline for kernel boot
options, /proc/cpuinfo for CPU details, /proc/devices for a list of device drivers,

Copyright 2023+ Cyber Life All Rights Reserved


35

/proc/filesystems for supported file system types, /proc/meminfo for RAM


usage information, and /proc/modules for information about loaded kernel modules.

2. The `/proc/version File:

● The /proc/version file contains information about the Linux kernel, including its
version, the version of the GNU Compiler Collection (GCC) used for compilation, the
compiler's username, and the compilation time.
● Verifying the kernel version can help ensure system functionality.

3. The dmesg Command:

● The dmesg (display message or driver message) command displays messages sent to
the kernel's message buffer during and after system boot.
● Device drivers and other kernel components send messages to the buffer, including
diagnostic messages in case of errors.
● The dmesg command is commonly used for troubleshooting various system issues.
● You can use options like -c to clear the kernel buffer, -f to restrict output by facility, and
-l to restrict output by message level.
● Additionally, you can use -e for human-readable timestamps, -L for color-coded
messages, and -H for human-friendly formatting.

Monitoring kernel modules and reviewing kernel information using these methods helps ensure
that the system is running as expected and that kernel modules are loaded correctly. It's
especially valuable for troubleshooting and system maintenance.

Managing the Linux Boot Process

Configure Linux Boot Components


1. Booting:

● Booting is the process of starting or restarting a computer and loading an operating


system.
● A booting environment reads a small program stored in ROM, which then executes
operations in RAM to bootstrap the operating system.

2. Boot Loader:

Copyright 2023+ Cyber Life All Rights Reserved


36

● A boot loader is a program stored in ROM that loads the kernel from a storage device
and initiates the operating system.
● It can protect the boot process with a password to prevent unauthorized system booting.
● Boot loaders can manage multiple operating systems on a computer.

3. Boot Loader Components:

● Boot loader components include the boot sector program (loaded by the boot
environment), the second stage boot loader (loads the operating system and contains a
kernel loader), and the boot loader installer (controls installation of drive sectors).

4. BIOS (Basic Input/Output System) and UEFI (Unified Extensible Firmware Interface):

● BIOS is a firmware interface standard stored on a computer's motherboard ROM chip.


● UEFI is a newer firmware technology that replaces BIOS, offering faster performance,
larger memory access, and improved security.

5. Password Protection:

● Both BIOS and UEFI support password protection to restrict unauthorized system
booting.

6. Additional Boot Options:

● Systems can be booted from various sources, including ISO images, PXE (Preboot
Execution Environment) for network booting, HTTP/FTP for network booting, and NFS
(Network File System) for network booting.

7. Sectors:

● Sectors are the smallest storage units on a drive, storing 512 bytes of data by default.
● MBR (Master Boot Record) and GPT (GUID Partition Table) are partition structures.

8. initrd and initramfs:

● Initrd (initial ramdisk) and initramfs (initial RAM file system) are temporary root file
systems loaded into memory during system boot.
● They help initialize the permanent root file system, manage device driver modules, and
handle complex boot scenarios.

9. The /boot/ Directory:

● The /boot/ directory contains important boot-related files, including GRUB (Grand Unified
Bootloader) configuration files, EFI boot files, initrd/initramfs images, and the Linux
kernel (vmlinuz).

10. The dracut Command:

Copyright 2023+ Cyber Life All Rights Reserved


37

● The dracut command generates initramfs images for Linux systems, replacing mkinitrd
on some distributions.

11. The Boot Process:

● The Linux boot process involves a series of steps, from BIOS/UEFI initialization to kernel
and initrd/initramfs loading, and finally boot scripts execution.
● Users select the desired operating system, the kernel initializes hardware and mounts
the root file system, and systemd manages service startup.

12. Kernel Panic:

● Kernel panic occurs when a fatal error is detected, rendering the system unstable or
unusable.
● Kernel panic can happen during boot due to issues like corrupted kernel, initrd/initramfs
problems, root file system mounting errors, or hardware incompatibility.

Understanding and configuring these boot components is essential for system administrators to
manage Linux systems effectively.

Configure GRUB 2
1. GNU GRUB:

● GNU GRUB (GRand Unified Bootloader) is the primary bootloader for most modern
Linux distributions.
● It allows users to select which operating system or kernel version to boot in a multi-
platform environment.

2. GRUB 2 Improvements:

● GRUB 2 is a complete redesign and rewrite of the GRUB system, offering more control
over the boot process and several improvements.
● These improvements include support for non-x86 platforms, live booting, partition
UUIDs, dynamic module loading, boot loader configuration through scripts, rescue
mode, and custom graphical boot menus.

3. GRUB 2 Installation:

● Use the grub2-install command to install GRUB 2 on BIOS systems. This copies
GRUB 2 files into the /boot/grub2 directory and, on some platforms, installs GRUB 2
into the boot sector.

Copyright 2023+ Cyber Life All Rights Reserved


38

● For UEFI systems, use a package manager to install the grub2-efi package, which
copies GRUB 2 files to the EFI system partition in the /boot/efi directory.

4. Configuration Files:

● The main configuration file for GRUB 2 is grub.cfg, located in /boot/grub2/ on


BIOS systems and /boot/efi/EFI/<distro>/ on UEFI systems.
● The grub.cfg file is an executable shell script generated from configuration scripts.

5. /etc/grub.d/ Directory:

● The /etc/grub.d/ directory contains scripts used to build the main grub.cfg file.
● These scripts execute in a specific order and should not be directly edited. Custom
scripts can be added with appropriate prefixes to control their execution order.

6. GRUB 2 Boot Menu Customization:

● The /etc/grub.d/40_custom file allows for the customization of the boot menu
presented to users.
● Users can specify the order of menu choices, provide user-friendly names, and add
password protection to menu entries.

7. Password Generation:

● Use the grub2-mkpasswd-pbkdf2 command to generate a password hash for


protecting the GRUB 2 boot menu.

8. /etc/default/grub File:

● The /etc/default/grub file contains settings for GRUB 2 display menu options,
including timeout, submenu ordering, graphical terminal display, and more.

9. grub2-mkconfig Command:

● The grub2-mkconfig command generates or updates the grub.cfg configuration


file.
● It combines configuration file templates in /etc/grub.d/ with settings in
/etc/default/grub to create the grub.cfg file.

By understanding and configuring these components and files, administrators can customize
and manage the GRUB 2 bootloader according to their system's requirements.

Copyright 2023+ Cyber Life All Rights Reserved


39

Managing System Components

Configure Localization Options


1. Localization Overview:

● Localization involves adapting a system's components for use within a distinct culture or
language.
● This includes translating the interface, configuring time zones, keyboard layouts, and
date and time formats according to specific regions.

2. /usr/share/zoneinfo/ Directory:

● Contains regional time zone information.


● Subdirectories organize time zone files by language and region.
● To change the system's time zone, create a symbolic link from one of these files to
/etc/localtime.

3. /etc/timezone File:

● Used in some Debian-based distributions to specify the time zone.


● Lists the time zone based on the structure found in /usr/share/zoneinfo.

4. date Command:

● Displays the date in various formats.


● Default format: <day of week> <month> <day> <24-hour time> <time zone>
<year>.
● Use formatting options (e.g., date +%V) to customize the date format.
● Can also change the system's date using the -s option.

5. timedatectl Command:

● Manages system date and time information.


● Subcommands include status (view current date and time), set-time (set the system
time), set-timezone (set the time zone), and more.
● Allows enabling/disabling synchronization with a Network Time Protocol (NTP) server.
● Three clock types: local clock, universal time (UTC), and hardware clock (RTC).

6. Setting the Hardware Clock:

● Aligning the hardware clock with UTC is recommended to prevent time correction issues.

Copyright 2023+ Cyber Life All Rights Reserved


40

● The hardware clock can be set using the hwclock command.

7. hwclock Command:

● Used to view and set the hardware clock.


● Can adjust systematic drift, which is the predictable daily time variation of the hardware
clock.
● The /etc/adjtime file records drift information.

8. localectl Command:

● Manages system locale and keyboard layout settings.


● Locale settings determine language and culture-specific elements.
● Keyboard layouts ensure correct interpretation of keypresses.
● Subcommands include status, set-locale, list-locales, set-keymap, and
list-keymaps.

9. Character Sets and Encoding:

● Character encoding is the process of converting text to bytes and vice versa.
● The locale settings in Linux determine the character encoding scheme used by the
system.

By configuring these localization options, administrators can create a user-friendly Linux


environment tailored to their users' preferences and regions.

Configure GUIs
Configuring graphical user interfaces (GUIs) in Linux involves selecting and customizing the
GUI environment to meet the needs and preferences of users. GUIs provide a visual interface
for interacting with the system and are a common choice for workstations and desktops. Here
are the key concepts and actions related to configuring GUIs in Linux:

GUIs in Linux:

1. What is a GUI: A graphical user interface (GUI) is a visual way to interact with a
computer system, allowing users to perform tasks using graphical elements such as
icons, menus, and windows. GUIs are an alternative to command-line interfaces (CLIs)
in Linux.
2. Choosing a Desktop Environment: Linux offers various desktop environments, each
with its own look, feel, and features. Some popular desktop environments include
GNOME, KDE Plasma, Cinnamon, and MATE. The choice of desktop environment is a
matter of personal preference.

Copyright 2023+ Cyber Life All Rights Reserved


41

3. Display Servers: Linux supports multiple display servers, including X11 (X Window
System) and Wayland. Display servers handle graphical output and user input for GUI
applications.
4. X11 (X Window System): X11 is the traditional display server used in Linux for many
years. It provides a framework for graphical applications to interact with the hardware.
Various implementations, such as X.Org Server, are available.
5. Wayland: Wayland is a newer and more modern display server protocol designed to
replace X11. It offers improved performance, security, and native support for
compositing.

Remote Desktop:

1. Remote Desktop Software: Remote desktop software allows users to access and
control a remote system's GUI from a local computer. Common remote desktop
solutions for Linux include Virtual Network Computing (VNC), xrdp, NoMachine, and
SPICE.
2. SSH Port Forwarding: Secure Shell (SSH) can be used to tunnel remote desktop
connections securely over the network. SSH port forwarding allows you to establish
encrypted connections for services like VNC.

Console Redirection:

1. Console Redirection: Console redirection allows administrators to remotely manage


systems, even at the BIOS/UEFI level, by forwarding input and output through a serial
connection.

Accessibility Options:

1. Accessibility Features: Modern desktop environments provide a range of accessibility


options to assist users with disabilities. These options include screen readers,
magnifiers, enlarged text, on-screen keyboards, sticky keys, repeat keys, toggle keys,
and visual themes designed for high contrast and readability.

Overall, configuring a GUI in Linux involves selecting the appropriate desktop environment,
display server, and remote desktop software to meet the user's needs. It also includes
customizing accessibility features to ensure an inclusive computing experience. The choice of
GUI components and their configurations should align with the specific requirements of the
users and the purpose of the system.

Manage Services
Services and Daemons:

● Linux services provide specialized functionality and can be critical or non-critical.

Copyright 2023+ Cyber Life All Rights Reserved


42

● Daemons are background processes that run without human intervention and can start
at boot, by applications, or manually.

Service Management:

● Service management involves starting, modifying, and stopping services.


● This process is important for configuring server functionality and troubleshooting issues.

System Initialization:

● System initialization begins when the kernel loads and involves loading the OS
components.
● An init daemon, such as SysVinit or systemd, handles system initialization.

systemd:

● systemd is a modern init method and is the dominant approach in modern Linux
distributions.
● It offers improvements like parallelization, cgroups for process tracking, and other
features.

systemd Unit Files:

● Unit files are used by systemd to manage system resources.


● These files define how systemd handles various system resources.
● Unit files are stored in specific directories, and environment variables can be set within
them.

systemd Targets:

● systemd uses targets to represent specific modes of operation.


● Targets define different system states (e.g., multi-user mode, graphical environment).
● Targets group unit configuration files.

The systemctl Command:

● systemctl is used to control systemd.


● It can view, enable, disable, start, stop, and restart services.
● It also manages the system's default target.

The hostnamectl Command:

● hostnamectl is used to view and change the system's hostname and system information.

SysVinit and Runlevels:

● SysVinit is an older init method with runlevels, still supported by some distributions.

Copyright 2023+ Cyber Life All Rights Reserved


43

● Runlevels control the system's state and determine which daemons should run.

The /etc/inittab File:

● /etc/inittab stores information about system initialization in SysVinit systems.


● It defines runlevels and actions to take when changing runlevels.

The /etc/init.d/ Directory:

● /etc/init.d/ stores initialization scripts for services and controls how they start.

The chkconfig Command:

● chkconfig manages services in different runlevels, enabling, disabling, or resetting them.

The service Command:

● service is another tool for controlling SysVinit services, starting, stopping, restarting, and
reloading them.

These notes provide a concise summary of the key topics covered in your lesson about
managing services.

Troubleshoot Process Issues


Process States:

● Stopped: Indicates a process was stopped by a debugger or a kill signal.

Process IDs (PID):

● Every process is assigned a unique PID.


● The init daemon always has a PID of 1 and is the parent of all other processes.
● Process troubleshooting often requires knowing a process's PID.

pgrep Command:

● Displays the PID of processes matching a pattern.


● Useful for identifying processes based on various criteria.

ps Command:

Copyright 2023+ Cyber Life All Rights Reserved


44

● Shows a summary of running processes.


● Various options allow you to filter and display specific information.

top Command:

● Lists all running processes and provides real-time status.


● Allows you to prioritize, sort, and terminate processes interactively.

systemd-analyze Command:

● Used for retrieving performance statistics for boot operations.


● The "blame" subcommand identifies slow-starting units.

lsof Command:

● Lists all files currently open to active processes.


● Helps identify processes preventing file modifications and analyze file usage.

Process Priorities:

● Processes are prioritized based on nice values (-20 to 19), with lower values indicating
higher priority.

nice Command:

● Used to start a new process with a specific nice value.


● Requires root authority to increase priority.

renice Command:

● Alters the scheduling priority of running processes.

Foreground and Background Processes:

● Explains how to manage processes running in the foreground and background.


● Introduces commands like fg, bg, and nohup for process management.

Kill Commands:

● Describes different commands for terminating processes.


● Explains the use of signals like SIGINT, SIGKILL, SIGTERM, and more.

Guidelines for Troubleshooting Process Issues:

● Provides a set of guidelines for troubleshooting process-related problems.

These notes summarize the key points from your lesson. If you need more specific information
or have any questions, feel free to ask.

Copyright 2023+ Cyber Life All Rights Reserved


45

Troubleshoot CPU and Memory Issues


Common CPU Issues:

● CPU underperformance or overload can cause system disruptions.


● Non-functional CPU cores or processes not getting enough CPU time are common
issues.
● High CPU usage by some processes can starve others of resources.
● Insufficient CPU utilization or lack of support for virtualization features can be
problematic.

/proc/cpuinfo File:

● Contains CPU information.


● Useful fields include processor, vendor_id, model name, cpu MHz, cache size, and flags.
● Helps identify CPU characteristics and performance-related issues.

CPU-Based Kernel Parameters:

● sysctl command for viewing kernel parameters.


● Useful for analyzing scheduling domains, grouping logical cores with shared properties.

Common Memory Issues:

● Low total memory, not enough free memory, or processes not accessing memory are
common problems.
● Insufficient memory for file access, killing critical processes, or improper swap space
usage can cause issues.

/proc/meminfo File:

● Contains information about system memory usage.


● Fields like MemTotal, MemFree, Cached, SwapTotal, and SwapFree provide valuable
memory details.

free Command:

● Parses /proc/meminfo for memory usage stats.


● Displays total memory, used, free, shared, buffered, cached, and available memory.
● Useful options include -b, -k, -m, -g, -t for different memory units and -o for excluding
buffered/cached information.

Copyright 2023+ Cyber Life All Rights Reserved


46

vmstat Command:

● Provides statistics on virtual memory, CPU, process, and I/O.


● Useful stats include total virtual memory, free memory, memory used in buffers/cache,
and CPU times.
● Requires a delay parameter for accurate reports (e.g., vmstat 5 5).

OOM Killer:

● Linux kernel's feature to handle extreme memory shortage by killing processes based on
OOM scores.
● Process OOM scores determine which to kill based on memory release and system
stability.
● Can be controlled by managing OOM control group.

Swap Space Configuration:

● Essential for handling memory shortages.


● Three types: device swap, file system swap, and pseudo-swap.
● Swap files are dynamic, while swap partitions perform better.

mkswap Command:

● Creates swap space on a storage partition.


● Useful options include -c for checking for bad sectors and -L for labeling.

Swap Partition Management:

● Use swapon to activate a swap partition and swapoff to deactivate it.


● Options like -e, -a, and -a for bulk management.

Guidelines for Troubleshooting:

● Use /proc/cpuinfo, uptime, sar, /proc/meminfo, free, and vmstat to diagnose CPU and
memory issues.
● Adjust the OOM killer if necessary.
● Consider expanding swap space if adding physical memory isn't possible.

Copyright 2023+ Cyber Life All Rights Reserved


47

Managing Devices

Identify the Types of Linux Devices


The Importance of Device Drivers:

● Device drivers are essential for hardware devices to work properly in Linux.
● Compatibility issues can arise if hardware lacks Linux-compatible drivers.
● Lack of proper drivers can result in devices not functioning or functioning poorly.

Thin Clients:

● Thin clients are lightweight devices that connect to more powerful servers.
● Servers handle most processing, storage, and data management.
● Centralized operations make system management more efficient.

USB Devices:

● Universal Serial Bus (USB) connects various peripherals to computers.


● Supports thumb drives, external HDDs, cameras, smartphones, printers, keyboards, and
more.
● Plug-and-play technology allows devices to configure themselves automatically.

Wireless Devices:

● Linux supports various wireless protocols, including Wi-Fi, Bluetooth, and Near Field
Communication (NFC).
● Wi-Fi for wireless LAN connectivity.
● Bluetooth for personal area networking.
● NFC for close-range data sharing.

Video and Audio Devices:

● Video and audio devices connect to client systems.


● Input devices include webcams, cameras, and microphones.
● Output devices include monitors, TVs, speakers, and headphones.
● Connection types vary; HDMI, DisplayPort, DVI, and VGA are common.

Printers:

● Linux offers printer support, and compatibility depends on available drivers.


● Printers can connect via USB or network interfaces (Wi-Fi or Ethernet).
● A Linux computer can serve as a print management server.

Network Adapters:

Copyright 2023+ Cyber Life All Rights Reserved


48

● Network adapters (NICs) connect devices to networks.


● Built into motherboards or added as expansion cards.
● Include Wi-Fi adapters for wireless and Ethernet for wired connections.

GPIO:

● General-purpose input/output (GPIO) pins are on circuit boards.


● Used for digital signals, controlled programmatically through software.
● Common in single-board microcontrollers like Arduino and Raspberry Pi.

SATA and SCSI:

● SATA (Serial AT Attachment) is a storage bus interface for connecting storage devices.
● SCSI (Small Computer System Interface) connects various peripherals, including
storage.
● SAS (Serial Attached SCSI) uses a serial interface for high-speed storage connections.

HBA and PCI:

● Host Bus Adapter (HBA) connects host systems to storage devices.


● PCI (Peripheral Component Interconnect) and PCIe (PCI Express) are expansion bus
interfaces for peripheral devices.
● PCIe is the dominant expansion bus technology, supporting various devices.

Configure Devices
Device File Locations:

● Device files are located in various directories, including /proc/, /sys/, /dev/, and
/etc/.
● /proc/ and /sys/ contain information about devices and hardware details.
● /dev/ stores device driver files to access devices.
● Configuration files for device-related components can be found in /etc/.

Hotpluggable Devices:

● Hotpluggable devices can be added or removed without rebooting.

Copyright 2023+ Cyber Life All Rights Reserved


49

● Hotpluggable devices are automatically detected when connected, such as USB,


FireWire, and SATA.
● udev is responsible for managing both coldpluggable and hotpluggable devices.

udev Rules:

● udev rules are configured in /etc/udev/rules.d/ to customize device behavior.


● Rules specify how devices are configured or actions taken when devices are plugged in.
● Rules can create symbolic links, specify attributes like vendor and product IDs, and
more.

Additional udev Rules Directories:

● /usr/lib/udev/rules.d/ contains system-generated rules with lower priority.


● Rules in this directory should not be edited.
● /run/udev/rules.d/ holds volatile rules that apply at runtime but are lost upon
reboot.

The udevadm Command:

● udevadm manages udev.


● Subcommands include info (retrieve device information), control (modify udev's
running state), trigger (execute rules for device events), monitor (watch for kernel
and udev events), and test (simulate udev events).
● Syntax: udevadm [options] [subcommand] [arguments].

Printing Software:

● Printers often come with software utilities, but their compatibility with Linux may vary.
● Major vendors provide Linux drivers on their websites.
● CUPS (Common Unix Printing System) serves as a print management system for Linux.
● CUPS enables computers to act as print servers, processing print jobs from clients.
● The lpr command submits files for printing, with options like destination, copies, job
name, job options, and more.

Monitor Devices
The lsdev Command:

● Displays hardware information collected from /proc/ files.


● /proc/interrupts shows CPU cores and associated IRQs.

Copyright 2023+ Cyber Life All Rights Reserved


50

● /proc/ioports lists I/O ports and their hardware devices.


● /proc/dma lists ISA DMA channels.
● Common on Debian-based distributions, may require the procinfo package.

The lsusb Command:

● Shows USB device information.


● Scans /dev/bus/usb/ for data.
● By default, displays bus number, device number, device ID, vendor, and product.
● Use -v for detailed device information.
● Filter results by bus (-s) and by vendor/product (-d).

The lspci Command:

● Displays information about devices connected to PCI buses.


● Default output includes slot address, device class, vendor, and device names.
● Offers verbose mode for more detailed device info.

The lpq Command:

● Shows the status of the printer queue.


● Displays job rank, owner, job number, files, and job size.
● Can refresh the report at specified intervals with the +interval option.

Additional Device Monitoring Tools:

● lsblk: Identifies block storage devices and checks if they are recognized, partitioned,
and mounted.
● dmesg: Shows messages sent to the kernel's message buffer after system boot,
including device driver messages. Useful for monitoring hardware issues and driver
problems.

Troubleshoot Hardware Issues


Common Hardware Issues:

● Problems can affect various hardware devices, including keyboards, communications


ports, printers, memory, video, and storage adapters.

Keyboard Mapping Issues:

● Incorrectly configured keyboard layout or language can lead to issues.


● Use localectl to check and set the correct keyboard layout.
● Remote terminal clients like PuTTY may offer options to adjust keystroke behavior.

Copyright 2023+ Cyber Life All Rights Reserved


51

Communications Port Issues:

● Ensure devices are properly connected, cables aren't loose, and power is supplied.
● Install necessary drivers for the interface.
● Confirm device's compatibility with the bus interface version (e.g., USB version).
● For serial devices, configure them to use appropriate serial console.
● Adjust permissions on serial consoles if needed.

Printer Issues:

● Check printer for common problems like ink/paper shortage or paper jams.
● Ensure Linux-compatible drivers are installed and loaded.
● Use network diagnostic tools like ping to verify the printer's presence on the network.
● In a print server setup, use lpq and lprm to manage print jobs and prevent queue
overload.

Memory Issues:

● Monitor memory usage with tools like free and top.


● Identify and resolve processes causing memory leaks.
● For hardware memory problems, look for "Machine Check Exception" errors in logs. Use
mcelog to retrieve these errors.
● Perform stress tests with utilities like MemTest to identify faulty RAM modules.

Video Issues:

● Troubleshoot display issues, blank screens, color problems, etc.


● Ensure monitors are properly connected and compatible with the system.
● Install the latest GPU drivers provided by vendors (AMD, Nvidia).

Storage Adapter Issues:

● Check data transfer speeds and device recognition.


● Ensure devices are correctly connected to the appropriate bus adapter.
● For SCSI devices, use echo command to rescan the SCSI bus.
● RAID issues can be managed with mdadm, with options like -f, -r, --re-add, and -a.

lshw Command:

● lshw lists hardware components and details, extracted from various files.
● Use it to identify recognized devices and review device characteristics.
● You can specify device classes with -c option.
● Helpful for verifying hardware presence and compatibility.

dmidecode Command:

Copyright 2023+ Cyber Life All Rights Reserved


52

● dmidecode dumps the Desktop Management Interface (DMI) table, which tracks
hardware component information.
● Use it to verify connected devices and their features.
● Be aware that DMI tables may contain inaccurate information.

ABRT (Automatic Bug Reporting Tool):

● ABRT reports on problems detected during system runtime, including hardware issues.
● It collects data like memory dumps and reports to help diagnose problems.
● Configure ABRT to redirect problem data to different destinations or write to local or
remote files.

Guidelines for Troubleshooting Hardware Issues:

● Ensure driver support for hardware devices.


● Verify driver installation.
● Confirm device compatibility with Linux.
● Check keyboard layout and language.
● Manage print jobs and queues.
● Monitor memory usage.
● Diagnose and replace faulty RAM.
● Update GPU drivers.
● Check device connections.
● Rescan SCSI buses when needed.
● Use mdadm for RAID issues.
● Utilize tools like lshw and dmidecode.
● Be cautious of potentially inaccurate DMI data.
● Review crash data reported by ABRT.

Managing Networking

Identify TCP/IP Fundamentals


TCP/IP:

● Transmission Control Protocol/Internet Protocol (TCP/IP) is the default protocol suite of


the Internet and most private networks.

The OSI Model:

Copyright 2023+ Cyber Life All Rights Reserved


53

● The OSI model standardizes networking into seven layers, from physical (Layer 1) to
application (Layer 7).
● Each layer has a specific function.
● It provides a common reference point for devices and network applications.

TCP/IP Layers:

● TCP/IP consists of four layers: Application, Transport, Internet, and Link.


● These layers align with different OSI layers.
● Understanding these layers is essential for troubleshooting and configuring networks.

Network Identities:

● Nodes in a network have various identities: MAC address, IP address, and hostname.
● MAC addresses are physical and unique identifiers.
● IP addresses are logical and unique addresses.
● Hostnames are human-readable and help identify devices.

Network Devices and Components:

● Key network devices include switches, routers, and media (e.g., Ethernet cable).
● Switches work at Layer 2 (Data Link), routers at Layer 3 (Network).
● Different types of network cables exist, including twisted pair, coaxial, and fiber optic.

Frame vs. Packet:

● Data in a TCP/IP network is transmitted as frames at Layer 2 and packets at Layer 3.

DNS and DHCP:

● Domain Name System (DNS) provides name resolution, mapping hostnames to IP


addresses.
● Dynamic Host Configuration Protocol (DHCP) allows dynamic configuration of IP
addresses for nodes on a network.

IPv4 Addressing:

● IPv4 addresses are 32 bits long and represented in decimal form.


● Addresses consist of a network identifier and a host identifier.
● Subnet masks divide the address into these parts.
● IPv4 classes (A, B, C, D, E) determine the number of networks and hosts for each class.

Reserved Ranges:

● Some address ranges (e.g., 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) are reserved for
internal networks.

Copyright 2023+ Cyber Life All Rights Reserved


54

Loopback and Link-Local:

● Loopback address (127.0.0.1) is used for diagnostics and local network communication.
● Link-local addresses (169.254.0.0–169.254.255.255) are for automatic IP configuration.

IPv6:

● IPv6 offers advantages over IPv4, including a larger address space, built-in encryption,
and more efficient routing.
● Linux is fully compatible with IPv6.

Network Ports:

● Network port numbers identify application-layer protocols.


● Ports help devices determine which application handles communication.
● Common port numbers include 22 (SSH), 80 (HTTP), and 443 (HTTPS).

Network Segments:

● Network administrators divide networks into segments (subnets) to manage traffic


efficiently and enhance security.
● Each subnet has a unique network ID, and nodes in the same subnet share this ID.

Identify Linux Server Roles


Here are some common Linux server roles that are essential in TCP/IP networking:

1. NTP Services (Network Time Protocol): NTP is used for time synchronization. Linux
systems can act as NTP servers or clients, ensuring accurate timekeeping for network
devices.
2. SSH Services (Secure Shell): SSH provides secure remote access to Linux systems. It
is commonly used for remote administration and secure tunneling. Linux can function as
both an SSH client and server.

Copyright 2023+ Cyber Life All Rights Reserved


55

3. Web Services: Linux servers are frequently used for hosting websites. Apache is a
popular web server software, and Linux supports web services using HTTP (TCP port
80) and HTTPS (TCP port 443).
4. Certificate Authority Services: Certificate authorities (CAs) manage digital certificates
used for secure identity verification. Linux servers can be configured as CAs, enabling
secure communication and website authentication.
5. Name Server/DNS Services: DNS servers resolve hostnames to IP addresses. Linux
systems can function as DNS servers or clients, ensuring name resolution for network
resources.
6. DHCP Services (Dynamic Host Configuration Protocol): DHCP servers dynamically
assign IP addresses and network configuration settings to clients. Linux can serve as a
DHCP server or client, simplifying IP configuration management.
7. SNMP Services (Simple Network Management Protocol): SNMP enables monitoring
and management of network devices. Linux servers can act as SNMP managers or
agents, collecting and transmitting device performance data.
8. Authentication Services: Centralized authentication services, such as Kerberos and
LDAP, enhance network security by validating user identities. Linux can operate as an
authentication server.
9. Proxy Services: Linux can function as a proxy server, facilitating communication
between untrusted and trusted network segments. Proxy servers, like Squid, are often
used for web browsing.
10. Logging Services: Linux systems generate log files that capture important events and
activities. Centralized logging services collect and store log data for analysis,
troubleshooting, and security monitoring.
11. Monitoring Services: Linux offers various monitoring tools to track system and
application performance. Examples include top, ApacheTop, Monit, and System Monitor.
12. Load Balancing Services: Load balancers distribute incoming connection requests
among multiple servers to improve availability and distribute traffic. They are commonly
used for web services.
13. Clustering Services: Clustering involves creating a group of interconnected servers
(nodes) that work together to ensure high availability and scalability. Clusters are often
used for database access and critical services.
14. File/Print Services: File servers store and centralize user data, while print servers
manage networked printers. These services improve data management and print
resource sharing.
15. Samba and NFS: Samba supports SMB-compatible file sharing for integration with
Windows systems. NFS provides native Unix/Linux file sharing for workstations.
16. Database Services: Linux supports both SQL and NoSQL database services, such as
MySQL, MariaDB, PostgreSQL, and MongoDB, for storing and querying data.
17. VPN Services (Virtual Private Network): VPN servers enable remote users to securely
access the internal network over untrusted connections. Linux can function as both a
VPN server and a VPN client.
18. Virtualization/Container Host Services: Linux serves as a host for virtual machines
(VMs) and containers, allowing efficient resource utilization and isolation of applications.

Copyright 2023+ Cyber Life All Rights Reserved


56

19. Email Services: Email servers, like Sendmail and Postfix, facilitate the distribution of
electronic mail within organizations. They use email protocols like SMTP, POP3, and
IMAP.

These server roles are vital for maintaining and managing network services in a Linux
environment.

Connect to a Network
Hostname Configuration:

● You can use the hostnamectl command to configure the hostname of your Linux
system. For example: sudo hostnamectl set-hostname server01.

IP Configuration:

● To participate on a network, a computer needs a valid identity, including a MAC address,


an IP address, and a hostname.
● Key IP configurations include the IP address, subnet mask, default gateway (router), and
DNS server information.
● Misconfigurations in these values can prevent the system from connecting to the
network.

NetworkManager:

● Many Linux distributions include NetworkManager, a utility for configuring IP information.


● NetworkManager provides different interfaces, which can be accessed via a GUI or
command-line tools.

nmcli Command:

● nmcli is a command-line tool that allows you to view and configure network settings.
● Examples of nmcli subcommands include general status, connection show,
con up, and device status.
● Use the syntax: nmcli [options] [subcommand] [arguments].

nmtui Utility:

● The nmtui utility offers a text-based user interface (TUI) for configuring network
settings.
● Navigate through the interface using the Tab key, Spacebar, Enter key, and arrow keys.

Copyright 2023+ Cyber Life All Rights Reserved


57

nmgui Utility:

● NetworkManager also includes a graphical user interface (GUI) tool for managing
network connections.
● This tool is suitable for configuring IPv4, IPv6, and various network settings.

ifconfig Command:

● The ifconfig command displays IP addressing information for network interfaces.


● It's often used for basic network troubleshooting.
● The syntax is: ifconfig [options] [interface].

ip Command:

● The ip command has largely replaced ifconfig and provides similar information.
● Use the ip command to show IP address details, interface status, and enable/disable
network interfaces.

iwconfig Command:

● The iwconfig command is used for configuring wireless network interfaces, including
SSID, encryption, frequency, and channel settings.

These tools and commands are essential for configuring and verifying network connections on
Linux systems.

Configure DHCP and DNS Client Services


Configuring DHCP and DNS client services in Linux is essential for network connectivity. Here
are some key points and concepts related to these services:

Static vs. Dynamic IP Address Configuration:

● Static IP address configuration involves manually setting IP parameters and is typically


used for network devices, servers, and network print devices.
● Dynamic IP address configuration relies on DHCP servers to provide IP settings
dynamically to client machines. This method is suitable for client devices.

Copyright 2023+ Cyber Life All Rights Reserved


58

DHCP Configuration:

● DHCP (Dynamic Host Configuration Protocol) servers manage pools of IP addresses


and related configuration options for client machines.
● DHCP servers simplify IP address management by leasing configurations to clients.

DHCP Lease Generation and Renewal Process:

● DHCP clients lease IP configurations from DHCP servers, and leases include IP
addresses, subnet masks, gateway addresses, DNS server addresses, and lease
duration.
● The lease renewal process allows clients to renew their leases, which also provides
opportunities for updates.

/etc/dhcp/dhclient.conf File:

● The /etc/dhcp/dhclient.conf file allows configuration of DHCP client settings,


including timeouts and dynamic DNS configurations.

Name Resolution:

● Name resolution relates easy-to-remember names (like website URLs) to difficult-to-


remember IP addresses (DNS).
● The DNS (Domain Name System) is a dynamic database for name resolution.

Testing Name Resolution:

● Tools like host and nslookup are used to test name resolution and ensure proper
DNS functionality.

/etc/hosts File:

● The /etc/hosts file contains static IP address and hostname mappings, providing a
manual way of resolving names to IP addresses.

/etc/resolv.conf File:

● The /etc/resolv.conf file specifies the IP addresses of DNS servers, allowing


systems to query DNS for name resolution.

/etc/nsswitch.conf File:

● The /etc/nsswitch.conf file defines the order of name resolution methods,


specifying whether to use /etc/hosts or DNS first.

DNS Configuration Using NetworkManager:

Copyright 2023+ Cyber Life All Rights Reserved


59

● NetworkManager provides command-line, text-based, and graphical tools for configuring


DNS settings, including specifying DNS server IP addresses.

These concepts and tools are essential for configuring DHCP and DNS client services on Linux
systems, ensuring reliable network connections and proper name resolution.

Configure Cloud and Virtualization Technologies


Configuring cloud and virtualization technologies is essential for optimizing your Linux
infrastructure. Here are the key concepts and tools related to cloud computing and virtualization:

Cloud Computing:

● Cloud computing is a rapidly changing aspect of IT that offers several essential


characteristics, including on-demand self-service, broad network access, resource
pooling, rapid elasticity, and measured service.
● Cloud services provide flexibility, scalability, and cost-efficiency, making it a mission-
critical service for businesses.

Cloud Models:

● There are three primary cloud models: Software as a Service (SaaS), Platform as a
Service (PaaS), and Infrastructure as a Service (IaaS), each serving different purposes.
● Public, private, and hybrid clouds offer different structures for deploying cloud services,
with varying levels of control and security.

Cloud Service Providers:

● Leading cloud service providers include Amazon Web Services (AWS) and Microsoft
Azure, with Red Hat Cloud Suite as a Linux-based private cloud option.
● Various other providers offer specialized services and solutions tailored to different
market segments.

Virtualization:

● Virtualization forms the foundation of cloud computing, allowing more efficient use of
hardware, fault tolerance, and quick server deployments.
● Hypervisors, like Type 1 (bare-metal) and Type 2 (hosted), manage virtual machines,
providing control between VMs and physical hardware.

Templates:

Copyright 2023+ Cyber Life All Rights Reserved


60

● Templates facilitate efficient deployment of virtual machines with pre-defined


configurations for processors, memory, storage, and network settings.
● Templates can be in various formats like Open Virtualization Format (OVF), JSON,
YAML, or container images for container virtualization.

Bootstrapping:

● Bootstrapping refers to the initial setup and customization of virtual machines during
their first boot. Tools like cloud-init, Anaconda, and Kickstart enable bootstrapping.
● These tools help automate the installation and configuration of virtual machines.

Storage:

● Storage in virtualization can be provided as virtual storage drives, allowing greater


flexibility, fault tolerance, and scalability.
● Thin provisioning and thick provisioning are options for allocating virtual storage, with
different trade-offs between space efficiency and performance.

Networking Configurations:

● Virtual machines can be configured with virtual NICs connected to virtual switches within
the hypervisor.
● Network configurations, including public, private, and internal networks, provide different
levels of connectivity and isolation.

Virtualization Tools:

● Virtualization tools like virsh and libvirt are used for managing virtual machines, providing
command-line and API-based access to VMs.
● GNOME VMM (Virtual Machine Manager) offers a graphical interface for VM
management.

These concepts and tools help configure and manage cloud and virtualization technologies,
enabling businesses to leverage the benefits of scalability, flexibility, and cost-efficiency in their
IT infrastructure.

Copyright 2023+ Cyber Life All Rights Reserved


61

Troubleshoot Networking Issues


1. nmap (Network Mapper):
○ A network scanning tool.
○ Checks for open ports on a target host.
○ Syntax: nmap [options] {target}.
2. Wireshark:
○ Packet sniffer and network analyzer.
○ Intercepts and analyzes network traffic.
○ Used for both eavesdropping attacks and network troubleshooting.
3. tcpdump:
○ Packet sniffer.
○ Captures network packets.
○ Useful for analyzing network traffic.
○ Syntax: tcpdump [options] [-i {interface}] [host {IP
address}].
4. netcat (nc):
○ Tool to test connectivity and transfer data between hosts.
○ Syntax: netcat [options].
○ Can be used for creating network connections and transferring files.
5. iftop:
○ Displays bandwidth usage information.
○ Helps identify bandwidth-hungry applications.
○ Useful for investigating network slowness.
6. iperf:
○ Tests maximum throughput of a network interface.
○ Used to ensure that network bandwidth meets expectations.
○ Syntax: iperf {-c|-s} [options].
7. mtr (My TraceRoute):
○ Combines ping and traceroute.
○ Tests the quality of network connections.
○ Identifies packet loss and network issues.
○ Syntax: mtr [options] [hostname].
8. arp (Address Resolution Protocol):
○ Resolves IP addresses to MAC addresses.
○ Allows you to clear ARP cache.
○ Syntax: arp [options].
9. whois:
○ Retrieves information on DNS registrations for domains.
○ Useful for verifying domain ownership and contact details.
○ Syntax: whois [options] {domain name}.
10. Troubleshooting Guidelines:
○ Start by narrowing the scope of the problem.

Copyright 2023+ Cyber Life All Rights Reserved


62

○ Verify IP address configurations using ip.


○ Renew dynamic IP configurations from DHCP.
○ Check for typographical errors in static IP configurations.
○ Use various tools to diagnose bandwidth and connectivity issues.
○ Utilize common commands for network troubleshooting.

Managing Packages and Software

Identify Package Managers


Package Managers:

● Linux distributions use package managers for software management.


● Package managers install, update, inventory, and uninstall software packages.
● The alternative to package managers is manual compilation from source code.

Software Dependencies:

● Many Linux applications depend on other software components.


● Package managers check and manage these dependencies.
● "Failed dependency" errors indicate unsatisfied requirements.

Red Hat vs. Debian vs. Compiling:

● Red Hat Package Manager (RPM) and Debian dpkg are two dominant package
management methods.
● RPM packages have a .rpm extension, while Debian uses .deb.
● Compiling from source code is an option for open-source Linux software.
● Compiling requires more effort but offers customization.

Distribution Origins:

● Common Linux distributions and their origins include Red Hat, CentOS, Fedora, and
Debian.

Red Hat Package Managers:

● RPM is Red Hat's package manager.

Copyright 2023+ Cyber Life All Rights Reserved


63

● YUM (Yellowdog Updater, Modified) is a more advanced package manager based on


RPM.
● YUM is favored for software lifecycle management.

Debian Package Managers:

● Debian uses dpkg as its package manager.


● Advanced Package Tool (APT) is a more flexible package manager used in Debian
derivatives.

DNF and Zypper:

● Dandified YUM (DNF) is an improved version of YUM, using fewer resources and
maintaining RPM support.
● Zypper is an openSUSE package manager that efficiently manages package
dependencies.

DNF Syntax:

● Install a DNF package: dnf install {package name}


● Uninstall a DNF package: dnf remove {package name}

Zypper Syntax:

● Install a Zypper package: zypper in {package name}


● Uninstall a Zypper package: zypper rm {package name}

Manage RPM Packages with YUM


The rpm Command:

● rpm is used to manage RPM packages on Red Hat-derived distributions.


● It includes options like -i to install, -e to uninstall, -v for verbose mode, and -V to
verify software components.
● You can query packages with commands like rpm -qa, rpm -qi {package name},
and rpm -qc {package name}.
● RPM can verify installed software components.

Copyright 2023+ Cyber Life All Rights Reserved


64

RPM Upgrades:

● RPM offers -U to upgrade an installed package, installing if not present.


● -F freshens an installed package, upgrading without installing if missing.

The yum Command:

● yum improves RPM functionality and handles software dependencies.


● Uses repositories to store .rpm files for version control.
● It can install packages and automatically install dependent packages.

yum Subcommands:

● install {package name} to install a package from a configured repository.


● localinstall {package name} to install from the local repository.
● remove {package name} to uninstall a package.
● update [package name] to update packages, updating all installed ones if no
package name is specified.
● info {package name} to get information about a package.
● provides {file name} to find packages that provide specified files or libraries.

The -y Option:

● Use the -y option with yum to automatically answer yes when prompted for installing
additional software dependencies.

Manage Debian Packages with APT


The dpkg Command:

● dpkg is used to manage packages on Debian-derived distributions.


● Options include -i to install, -r to remove, -l to list package information, and -s to
check if a package is installed.

Debian Package Verification:

Copyright 2023+ Cyber Life All Rights Reserved


65

● Use -i with dpkg to ensure all necessary components are installed when repairing a
software installation.

The apt Command:

● apt is a front-end manager for dpkg on Debian-derived distributions.


● It is commonly used to manage .deb packages.
● More streamlined than the previous apt-get and apt-cache commands.

apt Subcommands:

● install {package name} to install a package.


● remove {package name} to uninstall a package, preserving configuration files.
● purge {package name} to uninstall a package and remove its configuration files.
● show {package name} to get information about a package.
● version {package name} to display version information.
● update updates the APT database of available packages.
● upgrade [package name] upgrades packages based on newer versions seen in the
APT database.

The apt-get and apt-cache Commands:

● Still functional, these commands provide lower-level functionality for more specific
control.

Debian Package Upgrades:

● Use apt update to update the APT database of available packages.


● Then, use apt upgrade to upgrade all installed packages based on the database.
● apt upgrade {package name} upgrades a specified package based on the
database.

Make sure to run apt update before apt upgrade to ensure the database is aware of newer
packages.

Configure Repositories
Repositories:

● Repositories are storage locations for software packages.

Copyright 2023+ Cyber Life All Rights Reserved


66

● Three types of repositories: Local repositories (on local storage), Centralized internal
repositories (within LAN), Vendor repositories (maintained on the Internet).

YUM Repository Configuration:

● Use the createrepo command to designate a location as a YUM repository.


● Create a .repo configuration file in /etc/yum.repos.d/ with essential components.
● Subcommands include repolist (view available repositories), makecache (locally
cache information), and clean all (clear outdated cache).

Repository Synchronization:

● YUM allows synchronization (mirroring) of an online repository to a local storage,


reducing WAN traffic.
● Use the reposync command for synchronization.

APT Repository Configuration:

● APT, like YUM, can access repositories.


● Repositories are exposed in /etc/apt/sources.list and
/etc/apt/sources.list.d/.
● Entries in sources.list contain fields: deb URL distro-name components.
● After editing sources.list, run apt update to inform APT about new repositories.

Acquire Software
Download Sites:

● Linux software can often be freely downloaded from application vendors or websites that
centralize information about available software.
● Popular Linux applications include Audacity, Atom, GIMP, and Nmap.
● Open-source hosting sites like GitHub also host software.

wget and curl Commands:

Copyright 2023+ Cyber Life All Rights Reserved


67

● wget and curl are command-line utilities for accessing websites.


● Useful for downloading files using known URLs or in scripts.
● Example usage: wget http://download.samba.org/pub/samba/samba-
latest.tar.gz or curl -o nmap-7.70.tar.bz2
https://nmap.org/dist/nmap-7.70.tar.bz2.
● Differences: wget is command-line only, supports recursive downloads, and is better for
straightforward downloads, while curl is cross-platform, supports various network
protocols, and is suitable for complex requests.

.tar Files:

● Linux often uses tar (tape archiver) to bundle files into a single .tar file.
● Useful for bundling multiple files for efficient downloads.
● Example of creating a tarball: tar -cvf tarball.tar file1 file2 file3.
● Basic tar command options: -c (create), -x (extract), -v (verbose), -r (append), -t (test), -f
(specify tarball name).

Compressed Files:

● File compression reduces file size for more efficient downloads.


● Common Linux compression utility: gzip (.gz extension).
● Tarballs can be compressed as .tar.gz or .tgz.
● Another compression format: .tar.bz2 (compressed with bzip2).
● Basic gzip commands: gzip {file name} (compress) and gzip -d {file name}
(decompress).

Build Software from Source Code


Why Compile?

● Compiling software from source allows customization for specific hardware or needs.
● Linux users have access to open-source code for compilation.
● Windows and macOS typically use pre-compiled software.

Compilers:

Copyright 2023+ Cyber Life All Rights Reserved


68

● Compilers translate human-readable programming languages (e.g., C, C++) into


machine-readable binaries.
● GNU Compiler Collection (GCC), often used in Linux, implemented as gcc utility.
● Software may require specific libraries for compilation.

Libraries:

● Libraries contain compiled code for common tasks.


● Shared libraries enhance modular program builds and reduce compilation time.
● Libraries can be accessed from /usr/lib/ or /lib/ directories.
● Developers may include libraries with their software for users.

The ldd Command:

● ldd command shows shared library dependencies for an application.


● Useful for troubleshooting and gathering system requirements.

Software Compilation Process:

1. Unpack the downloaded software (use tar and gzip).


2. Change to the created directory.
3. Run ./configure to gather system information.
4. Use make to compile the application (often requires root privileges).
5. Use make install to install the binaries.

The make Command:

● Typically, make without arguments installs the application, looking for the makefile in the
current directory.
● Developers may provide instructions and options for optimizing the software.

More on Makefiles:

● A makefile contains instructions for compiling a program from source.


● Specifies dependencies, resources, and directives for the compiler.
● Efficiently rebuilds the program if changes are made to source files.

Troubleshoot Software Dependency Issues


Troubleshooting Software Dependencies and Repositories:

Copyright 2023+ Cyber Life All Rights Reserved


69

● Use rpm -V {package name} to verify the installation of all components of a


package, especially configuration files.
● Use rpm -qR {package name} for Red Hat-derivative distributions or yum deplist
{package name} to discover dependencies before installation.
● For Debian-derivative distributions, use apt-cache depends {package name} to
identify dependencies.
● Ensure that repositories contain all necessary dependency packages.
● Keep repositories up-to-date.
● Verify network connectivity to repositories.

Troubleshooting Patching and Update Issues:

● Read patch documentation to understand potential disruptions and required actions


(e.g., system restart).
● Ensure network connectivity for downloading updates.
● Test patches and updates in a controlled environment before applying them to
production systems.
● Confirm that all dependencies and software versions required for the patches and
updates are met.
● Check installation logs for any post-patching issues.
● Have a rollback plan in case patches result in unexpected behavior and ensure data is
backed up before applying patches.

Troubleshooting GCC and Library Issues:

● Check documentation for the required GCC or other compiler versions when compiling
software.
● Verify the Linux kernel and software dependencies versions required by the program
you're compiling.
● Use ldd {program binary} to check shared library file dependencies.
● Verify library file versions and availability.
● Consider compiling and testing software in a virtual machine to ensure proper
functionality.
● Assume root privileges when using make install command for software compilation.

Copyright 2023+ Cyber Life All Rights Reserved


70

Securing Linux Systems

Implement Cybersecurity Best Practices


Multi-Factor Authentication (MFA):

● MFA involves using more than one factor, such as something you know (password) and
something you have (smart card or token), for enhanced security.

Privilege Escalation:

● Privilege escalation can be both legitimate (e.g., administrator using sudo) and malicious
(exploiting vulnerabilities to gain elevated privileges).
● Poorly configured SUID and SGID permissions can enable privilege escalation.

chroot Jail:

● A chroot jail confines a process to a specific environment, preventing it from accessing


other parts of the file system.
● While effective, a chroot jail doesn't prevent a user or process with root privileges from
breaking out.

Encryption:

● Encryption transforms data from plaintext into ciphertext, safeguarding data


confidentiality.
● Types of encryption include data in transit, data in use, and data at rest encryption.

LUKS (Linux Unified Key Setup):

● LUKS is a platform-independent full-disk encryption solution used in Linux.


● LUKS uses the dm-crypt subsystem in the Linux kernel and offers compatibility with
various software.

Hashing:

● Hashing converts data into an indecipherable fixed-length output, providing data integrity
and security.
● Hash functions make it challenging to reverse-engineer the original data from the hash.

Networking Security Best Practices:

● Secure network services using SSL/TLS.


● Disable root access via SSH.
● Implement access control lists (ACLs) to allow connections only from trusted hosts.
● Consider changing default port associations for certain services for added security.

Copyright 2023+ Cyber Life All Rights Reserved


71

User Access Security Best Practices:

● Protect the boot loader configuration and BIOS/UEFI with passwords.


● Discourage the use of USB devices and ensure unique User IDs (UIDs).
● Establish a public key infrastructure (PKI) for password-less login.
● Restrict access to cron and disable Ctrl+Alt+Del functionality.
● Separate OS data from application data into different partitions for enhanced availability.

Additional Security Best Practices:

● Enable the auditd service for auditing and monitoring.


● Add a banner message for user login information.
● Continuously monitor the Common Vulnerabilities and Exposures (CVE) database.
● Harden the system by disabling or uninstalling unused and insecure services.

Guidelines for Implementing Cybersecurity Best Practices:

● Focus on protecting the confidentiality, integrity, and availability of information (CIA).


● Consider advanced authentication methods, centralizing authentication with LDAP and
Kerberos.
● Require multi-factor authentication for sensitive accounts.
● Implement security measures like chroot jails, encryption, and best practices for
networking and user access.

Implement Identity and Access Management Methods


SSH Key-Based Authentication:

● SSH key-based authentication involves using a public-private key pair for secure access.
● Key files: id_rsa (private key), id_rsa.pub (public key), authorized_keys (server-
side list of accepted public keys), and known_hosts (client-side list of accepted server
public keys).

sshd_config File:

● /etc/ssh/sshd_config configures the SSH server.


● Settings include PasswordAuthentication (password-based auth),
PubkeyAuthentication (public key-based auth), Port (SSH port), and more.

TCP Wrappers:

● Used to allow or deny connections from specific hosts to the SSH service.

Copyright 2023+ Cyber Life All Rights Reserved


72

● Configured in /etc/hosts.allow and /etc/hosts.deny.

PAM (Pluggable Authentication Modules):

● Centralized authentication framework in Linux.


● Configuration files located in /etc/pam.d/.
● Four module interfaces: account, auth, password, and session.

Password Policies:

● Password policies can be configured using PAM directives in /etc/pam.d/ files.


● Examples: password quality checks, password history enforcement, and password
hashing algorithms.

User Lockouts:

● Use PAM modules like pam_tally2 and pam_faillock to lock out users after
multiple failed login attempts.
● Add directives in /etc/pam.d/password-auth and /etc/pam.d/system-auth.

PKI (Public Key Infrastructure):

● PKI comprises digital certificates, CAs, and cryptographic components.


● Digital certificates validate entities' identities using public key cryptography.
● CAs issue and sign certificates for authentication.

OpenSSL:

● Open source implementation of SSL/TLS.


● Generate keys, certificates, and more.
● Used for managing PKI components.

VPNs and IPSec:

● IPSec secures data in transit, used in site-to-site and remote access VPNs.
● Modes: transport (packet content encryption) and tunnel (packet content and header
encryption).
● StrongSwan is a tool for IPSec implementation.

VPNs and SSL/TLS:

● SSL/TLS used in remote access VPNs.


● OpenVPN is a popular implementation supporting various authentication methods.
● DTLS is a protocol that provides security for datagram-based applications.

Access and Authentication Troubleshooting:

Copyright 2023+ Cyber Life All Rights Reserved


73

● Troubleshoot remote access issues by verifying user credentials, local accounts,


account status, and external services.
● Consider PAM policy violations and adjust policies if needed.

Configure SELinux or AppArmor


Configuring SELinux or AppArmor:

● SELinux and AppArmor are context-based permission schemes used to enhance Linux
system security.
● Mandatory Access Control (MAC) is the underlying model used by both to control access
based on security designations and clearances.
● SELinux is the default on CentOS and Red Hat Enterprise Linux, offering file system and
network security, protecting against unauthorized access and data tampering.
● SELinux uses User, Role, and Type contexts to control access, where Type (label) is
crucial for fine-grained control.
● Multi-Level Security (MLS) introduces a fourth context for sensitivity levels and
categories.
● SELinux has three modes: Disabled (MAC off), Enforcing (security policies enforced),
and Permissive (security policies not enforced but violations are logged).
● Security policies are categorized as targeted (only certain subjects/objects are confined)
or strict (everything is confined).
● Common SELinux commands include semanage, sestatus, setenforce, and
getsebool for configuration and status checks.
● Diagnose SELinux violations using sealert with the audit log or audit2why for more
human-readable explanations.

For AppArmor:

● AppArmor is an alternative context-based permission system, commonly found on


Debian-based and SUSE Linux distributions.
● Unlike SELinux, it uses paths for reference and works with flat configuration files
(profiles).
● Profiles contain rules for capabilities (access to system functions) and path entries
(access to specific files).

Copyright 2023+ Cyber Life All Rights Reserved


74

● AppArmor operates in two modes: Complain (violations logged but not prevented) and
Enforce (violations both logged and prevented).
● Tunables allow you to configure AppArmor without modifying profiles directly (e.g.,
adjusting variable names).
● Major AppArmor commands include apparmor_status, aa-complain, aa-enforce,
and aa-disable to manage profiles.

Configure Firewalls
Iptables:

● Iptables is a command-line utility for configuring the firewall in Linux.


● It allows you to set up rules to control incoming and outgoing network traffic.
● You can define custom chains for more granular control.
● Common default tables include filter, nat, mangle, raw, and security.
● To make rules persist across reboots, use the "iptables-services" package in
CentOS/RHEL or "iptables-persistent" in Debian-based systems.

UFW (Uncomplicated Firewall):

● UFW is a user-friendly firewall management tool for Linux.


● It simplifies configuring the underlying iptables rules.
● You can allow or deny specific services and enable logging with UFW commands.
● For advanced configurations, edit text files in "/etc/ufw/".

Firewalld:

● Firewalld is a dynamic firewall management service used in many Linux distributions.


● It categorizes resources into zones and applies services to them.
● Zones range from trusted to drop (blocking everything).
● You configure firewalld using the "firewall-cmd" command.
● Use the "--permanent" option to make changes persistent.

IP Sets:

● IP sets are collections of IP addresses, ports, etc., used for efficient rule matching with
iptables.
● Create and modify IP sets with the "ipset" command.
● Reference IP sets in iptables rules to make rule sets dynamic.

Firewall Troubleshooting:

Copyright 2023+ Cyber Life All Rights Reserved


75

● Blocked ports: Check firewall rules for needed ports.


● Blocked protocols: Ensure ports are open for the correct protocol (TCP/UDP).
● Restrictive ACLs: Simplify ACL rules for straightforward configuration.

Intrusion Prevention Systems (IPS):

● IPS monitors and blocks malicious traffic.


● It complements firewalls by detecting suspicious behavior inside the network.
● IPS only handles incoming traffic.

DenyHosts and Fail2ban:

● DenyHosts protects SSH servers from brute force attacks, monitoring failed logins.
● Fail2ban prevents brute force attacks for various services, using log files and Netfilter.
● Both tools help enhance security by blocking malicious IP addresses.

Implement Logging Services


System Logs:

● System logs track and maintain records of system activities and events.
● They use the syslog standard and can be centralized for remote logging or stored
locally.
● Entries in a syslog include date, time, process name, ID, message, facility, and severity.
● Common system log locations include /var/log/syslog, /var/log/messages,
/var/log/auth.log, /var/log/secure, /var/log/kern.log, and /var/log/[application].

Log Rotation:

● Log rotation is the practice of creating new versions of log files to manage their size.
● Logrotate is a utility used for automatic log rotation.
● Log files can be rotated based on size, time, or other criteria.
● It improves log management and analysis.

rsyslogd Service:

● Rsyslogd is an enhanced version of the syslog service in Linux.


● It supports TCP, SSL/TLS encryption, output to databases, and more.
● Rsyslogd maintains configuration files similar to syslogd for compatibility.

Copyright 2023+ Cyber Life All Rights Reserved


76

syslog-ng Service:

● Syslog-ng is an alternative to syslogd and rsyslogd.


● It offers similar functionality but with its own syntax and features.

Third-Party Agents:

● Third-party agents enable integration of non-syslog platforms (e.g., Windows) with


syslog.
● Agents capture and convert messages into syslog format for centralized logging.

journalctl Command:

● Journalctl is used to view and query logs created by the systemd journald service.
● It can display logs, filter by severity, service, and more.
● Journalctl settings are configured in /etc/systemd/journald.conf.

/var/log/journal/ Directory:

● The systemd journal can store logs in the /var/log/journal/ directory.


● This allows logs to persist after a reboot.

last Command:

● The last command displays the history of user login and logout events, including time
and date.
● Options allow you to filter results, such as by specific users or terminals.
● It retrieves information from /var/log/wtmp.

lastlog Command:

● The lastlog command lists users and their last login times.
● It retrieves data from /var/log/lastlog and is similar to last, but doesn't show login/logout
events.

Back Up, Restore, and Verify Data


Backup Types:

● There are three main types of backups: Full, Differential, and Incremental.
● Full backups include all selected files, making them reliable for data recovery.
● Differential backups cover changes since the last full backup.
● Incremental backups include changes since the last full or incremental backup, and they
are faster to perform but slower to recover.

Copyright 2023+ Cyber Life All Rights Reserved


77

Backup Storage Methods:

● Snapshot: Records the state of a storage drive at a specific time on the same drive.
● Image: Saves the state of an operating system as an image file (e.g., ISO) for system
recovery.
● Clone: Copies all contents of a storage drive to another storage medium.

The tar Command:

● Tar is used to create archives of data, often with a .tar file extension.
● It can create archives, extract files, store additional files, and list archived files.
● Syntax: tar [options] {file names}

Restoring Files with tar:

● Use the command "tar -xvf" to restore the entire contents of a source file or directory.
● For partial restores, provide the path and name used when creating the tar file.

The dar Command:

● Dar (Disk Archiver) replaces tar, offering more backup and archiving functionality.
● It can create full, differential, and incremental backups.
● Example: dar -R [source] -c [backup file] -A [reference backup]

The cpio Command:

● Cpio copies files to and from archives and has three modes: copy-out, copy-in, and
copy-pass.
● Syntax varies depending on the mode, and it reads from standard input.
● Example: ls | cpio -o > [archive file]

The dd Command:

● Dd copies and converts files for transferring data between different media.
● It has various operands for reading from and writing to files, specifying block size, and
counting blocks.
● Example: dd if=[source] of=[destination]

The mirrorvg Command:

● Mirrorvg creates copies (mirrors) of all logical volumes in a specified volume group.
● It can create multiple copies for redundancy.

Off-Site Backup:

● Off-site backups store data at a location outside the main site for disaster recovery.

Copyright 2023+ Cyber Life All Rights Reserved


78

● Data transfer tools include scp, sftp, and rsync for secure off-site data transfer over
networks.

Working with Bash Scripts

Customize the Bash Shell Environment


Shell Environment:

● The shell environment stores settings and behavioral details about the shell.
● New sessions are created through shell spawning, and these sessions can become child
processes.
● Each process calls upon the shell environment and passes details to the next
generation.

Scripts:

● Scripts are computer programs that automate tasks in a runtime or shell environment.
● They are written in scripting languages, a subset of programming languages.
● Scripts do not have the feature set of full programs but integrate with other components
to achieve automation.

Variables:

● Variables can be shell variables or environment variables.


● Shell variables do not pass values to child processes, while environment variables do.
● You can set and reference variables using VAR=value and ${VARIABLE_NAME}
respectively.

Environment Variables:

● Environment variables are inherited by child processes and consist of key-value pairs
(e.g., KEY=value).
● Some default environment variables include HOSTNAME, SHELL, MAIL, HOME, PATH,
HISTSIZE, and USER.

Localization Environment Variables:

Copyright 2023+ Cyber Life All Rights Reserved


79

● Localization settings can be configured using environment variables such as LC_*,


LANG, LC_ALL, and TZ.

The export Command:

● You can change a shell variable to an environment variable using the export
command.
● Change the value of a variable while exporting it using export VARIABLE_NAME="New
value".

The env Command:

● env is used to run a command with modified environment variables.


● You can change the value of a variable for a specific command session.
● env lists all variables and their values, and env -u can remove variables from the
environment.

Printing All Variables:

● The set command without arguments prints all shell variables, environment variables,
and shell functions.

Search Paths:

● The PATH variable consists of directory paths for locating executable files.
● You can add, modify, or delete paths to customize the search path.

HISTFILESIZE:

● HISTFILESIZE sets the maximum lines in the command history file and the number of
lines displayed with the history command.

The alias Command:

● alias creates command-line aliases for shorter expressions.


● Aliases can be viewed with alias, removed with unalias, and persisted in profile files.

The time Command:

● time gathers information about command execution time and statistics, including real,
user, and system time.

Troubleshooting:

Copyright 2023+ Cyber Life All Rights Reserved


80

● Troubleshoot issues related to aliases, script execution, variable settings, and


environment configurations.

Identify Scripting and Programming Fundamentals


Common Operators:

● Bash supports various types of operators, including arithmetic, comparison, logical, and
string operators.
● Arithmetic operators perform mathematical operations, comparison operators compare
values, logical operators combine values, and string operators manipulate strings.
● Examples of operators in Bash include +, -, ==, -ge, &&, ||, =, and more.

String Literals:

● String literals are fixed values that represent strings within source code and are enclosed
in single or double quotation marks.
● Double quotes allow variable substitution, while single quotes preserve the literal value
of characters.
● You can use an escape character (\) to remove special meanings from specific
characters in a string, making them interpreted literally.

Arrays:

● Arrays are collections of values, allowing you to store multiple values in a single variable.
● Arrays are ordered based on indices, usually starting from 0.
● You can assign values to arrays using compound assignment (my_arr=(1 "Hello"
3.1)) or individual assignment (my_arr[0]=1).

Functions:

● Functions are blocks of reusable code that perform specific tasks.


● In Bash, functions can be defined using function function_name { code... }
or function_name() { code... }.
● Arguments in Bash functions are passed differently compared to some other
programming languages.

Comments:

● Comments are used to annotate source code for clarity and documentation.
● In Bash, comments are preceded by the # character and are ignored by the interpreter.

Copyright 2023+ Cyber Life All Rights Reserved


81

● Good commenting practices involve explaining the script's purpose, commenting


complex sections, and avoiding over-commenting obvious code.

Write and Execute a Simple Bash Script


To create a simple Bash script and execute it, you can follow these steps:

1. Create a New Bash Script: Open a text editor on your Linux system, such as nano,
vim, or gedit, and create a new file. For example, you can use nano to create a file
named myscript.sh:
bash

nano myscript.sh

Write the Script: Add your Bash script code to the file. For this example, we'll create a simple
script that prints a greeting message. Here's an example script:
bash
#!/bin/bash
# This is a simple Bash script

echo "Hello, World!"


In this script, we have the shebang line (#!/bin/bash) at the beginning to specify that it's a
Bash script.
Save the Script: Save the file and exit your text editor. In nano, you can press Ctrl + O to
save, then Enter, and Ctrl + X to exit.
Make the Script Executable: Before you can run the script, you need to make it executable.
Use the chmod command to add the execute permission:
bash
chmod +x myscript.sh

Execute the Script: Now that the script is executable, you can run it from the terminal:
bash
./myscript.sh
The ./ is necessary to specify that you want to execute the script located in the current
directory.
Output: When you run the script, it will print the greeting message to the terminal:
bash
Hello, World!

Copyright 2023+ Cyber Life All Rights Reserved


82

Incorporate Control Statements in Bash Scripts


if Statement: The if statement allows you to execute code based on a condition. Here's an
example:

bash
var=5
if [ $var -gt 1 ]
then
echo "$var is greater than 1!"
fi

if...else Statement: The if...else statement lets you choose between two actions based on
a condition:
bash
var=1
if [ $var -gt 1 ]
then
echo "$var is greater than 1!"
else
echo "$var is less than or equal to 1!"
fi

case Statement: The case statement allows you to evaluate multiple conditions. Here's an
example with multiple conditions:
bash
var=blue
case $var in
red)
echo "Your color is red."
;;
green)
echo "Your color is green."
;;
blue)
echo "Your color is blue."
;;

Copyright 2023+ Cyber Life All Rights Reserved


83

*)
echo "Your color is neither red, green, nor blue."
;;
esac

1.

Loops:

4. while Loop: The while loop repeatedly executes a block of code while a specific
condition is met:
bash

var=1
while [ $var -le 5 ]
do
echo "The current number is $var."
((var++))
done

until Loop: The until loop is similar to the while loop but continues executing code while a
condition is false:
bash
var=1
until [ $var -ge 5 ]
do
echo "The current number is $var."
((var++))
done

for Loop: The for loop is used to iterate through a list of items or numbers:
bash
names=("Carla" "Robert" "Mary")
for name in "${names[@]}"
do
echo "$name is a member of the team."
done

Looping Through Ranges: You can use the for loop to iterate through a range of numbers:
bash
for i in {1..5}

Copyright 2023+ Cyber Life All Rights Reserved


84

do
echo "The current number is $i."
done

4.

You can incorporate these control statements and loops into your Bash scripts to create more
complex and interactive scripts.

Automating Tasks

Schedule Jobs
Using the at command

The at command allows you to run a task once at a specified time. It's suitable for one-time,
non-recurring tasks. Here's an example:

bash
at 15:30

This will enter an interactive mode where you can specify the command to be executed at 3:30
PM. After entering the command, press Ctrl+D to schedule it.

You can also schedule a task to run after a specific time interval:

bash
at now + 1 hour

This schedules a task to run one hour from the current time.

Using cron for recurring tasks

cron is a daemon used to manage scheduled tasks called cron jobs. You can specify tasks to
run at various intervals: minutes, hours, days, months, or days of the week.

1. To edit your user's crontab file, run:


bash

Copyright 2023+ Cyber Life All Rights Reserved


85

crontab -e
This opens a text editor (usually Vim) where you can define your cron jobs.
The format of a cron job is as follows:
bash
* * * * * /path/to/command
The five asterisks represent the schedule in this order: minutes, hours, days of the month,
months, and days of the week. For example:

● * 20 * * 1-5 /path/to/command runs the command at 8 PM, Monday through


Friday.
● 15 2 * * * /path/to/command runs the command at 2:15 AM every day.
● 30 4 1 * * /path/to/command runs the command at 4:30 AM on the first day of
each month.

To view your current crontab, run:


bash
crontab -l

To remove your crontab, run:


bash
crontab -r

1.
2. System-wide cron jobs are located in /etc/cron.d/. Standard users can create and
manage their own cron jobs in /var/spool/cron/.
3. There are also directories like /etc/cron.hourly, /etc/cron.daily,
/etc/cron.weekly, and /etc/cron.monthly, where you can place scripts to be
executed on an hourly, daily, weekly, or monthly basis.

Remember that the cron daemon checks its configuration file every minute, so the tasks are
executed based on the schedule you define.

Implement Version Control Using Git


To implement version control using Git, you need to perform several steps to create and
manage your Git repository. Below is a step-by-step guide:

Copyright 2023+ Cyber Life All Rights Reserved


86

1. Install Git: If Git is not already installed on your Linux system, you can install it using
your distribution's package manager. For example, on Debian-based systems, you can
use apt:
bash

sudo apt update


sudo apt install git

Configure Git: Set your user name and email address globally. These will be used to identify
your commits. Replace 'User' and 'user@domain.tld' with your actual name and email
address:
bash
git config --global user.name 'User'
git config --global user.email 'user@domain.tld'

Create a Git Repository: Navigate to the directory where your project is located and initialize a
Git repository:
bash
cd /path/to/your/project
git init

Add Files: Add the project files you want to track to the Git repository. You can specify
individual files or use a wildcard * to add all files:
bash
git add myfile
# or to add all files
git add .

Commit Changes: Commit the changes to the repository. When you commit, provide a clear
and descriptive commit message:
bash
git commit -m 'Initial commit'

View Repository Status: You can check the status of your Git repository at any time to see
which files have been modified, added, or deleted:
bash
git status

Working with Branches: Optionally, you can work with branches in Git. Branches are used to
isolate work on a particular feature or bug fix. Here's how to create and merge branches:

Copyright 2023+ Cyber Life All Rights Reserved


87

● Create a new branch:


bash

git branch newbranch

Make changes and commit them in the new branch.


Merge changes from the new branch into the master branch:
bash
git checkout master
git merge newbranch

Delete the branch (after merging):


bash
git branch -d newbranch

Collaborate with Others: If you're collaborating with other developers, you can pull their
changes and push your own. To pull changes from a remote repository:
bash
git pull origin otherbranch

To push your changes to a remote repository (e.g., GitHub):

bash
git push origin mybranch

View Commit History: You can view the commit history of your repository to see what changes
were made. Use the git log command:
bash
git log

1.
2. .gitignore File: If there are files or directories you want Git to ignore (e.g., temporary
files, build artifacts), you can create a .gitignore file in your repository and list the
patterns for files or directories to be excluded from version control.

That's a basic overview of how to implement version control using Git on your local system and
collaborate with others. Git is a powerful tool that allows you to manage your project's source
code efficiently and keep track of changes over time.

Copyright 2023+ Cyber Life All Rights Reserved


88

Identify Orchestration Concepts


Orchestration:

● Orchestration involves automating multiple related tasks or an entire workflow.


● It is used to manage large-scale deployments and configurations, both on-premise and
in the cloud.

Infrastructure Automation:

● Automation refers to accomplishing a single configuration task without human


intervention.
● Orchestration, on the other hand, manages a series of automation tasks for large-scale
deployments.
● Build automation focuses on the initial operating system deployment.

Infrastructure as Code:

● Infrastructure as code (IaC) relies on scripting and code files to manage the deployment
and configuration process.
● It uses a single configuration specification to deploy the supporting infrastructure and
applications.

Orchestration Tools:

● Common orchestration tools include Ansible, Puppet, Chef, Kubernetes, and


OpenStack.
● These tools help define desired configuration states and deliver those configurations to
target systems.

Agent-Based vs. Agentless Orchestration:

● Agent-based orchestration tools require a software component to be installed on


managed devices.
● Agentless tools do not require pre-existing software on the managed system.

Orchestration Procedures:

● Orchestration involves defining a desired configuration and delivering that configuration


file to the destination system.
● The configuration definition is processed to set the system's configuration to match the
definition file.

Attributes:

● Orchestration attributes define specific configurations that need to be set by the


orchestration process.

Copyright 2023+ Cyber Life All Rights Reserved


89

● They are used to identify tasks to be managed during the orchestration process.

Inventory Management:

● Orchestration tools can manage inventory, including hardware, virtual machines,


operating systems, applications, and configurations.
● Inventory management is essential for effective administration.

Automated Configuration Management:

● Configuration management ensures consistently configured systems, enhances security,


enforces SLAs, and streamlines change management.

Installing Linux

Prepare for Linux Installation


System Requirements:

● System requirements are not only about hardware but also about keeping the system
operational and functional.
● Different Linux distributions have varying requirements based on CPU speed, RAM,
storage space, and more.
● Hardware compatibility is crucial as even powerful hardware may not be supported by a
particular distribution.

Partitioning Strategy:

● Planning a partitioning strategy is essential to prevent the system from crashing.


● Isolating directories to their own partitions, such as home directories and log files, helps
maintain system stability.
● Swap space partition should be planned alongside data storage partitions.

Hardware Compatibility:

● Check whether hardware components are compatible with the chosen Linux distribution.
● Some distros maintain a hardware compatibility list (HCL) to help identify supported
hardware.
● Gathering hardware information from system documentation, BIOS/UEFI, or physical
inspection is necessary.

Copyright 2023+ Cyber Life All Rights Reserved


90

Questions for Choosing Hardware:

● Before purchasing hardware, address questions such as manufacturer, model, driver


support, and component specifications.
● Components like storage drives, CPUs, memory, network cards, input devices, monitors,
and display adapters should be evaluated.

Installation Methods:

● Installation often requires booting into a special environment.


● Installation media can be removable (DVDs, USB drives), on the local drive, or delivered
over a network (PXE, NFS).
● BIOS/UEFI settings may need to be adjusted for booting from removable media.

Guidelines for Preparing to Install Linux:

● Consider cost, system role, and distribution when identifying system requirements.
● Choose partitioning strategies based on the system's role, keeping complexity in mind.
● Check hardware compatibility with the chosen Linux distribution.
● Address questions for each hardware component.
● Select an installation method that suits your needs and organization efficiently.

These are key considerations and steps to take when preparing for a Linux installation.

Perform the Installation


1. Configure System Language and Keyboard Layout:

● Set the system's language and keyboard layout to establish a baseline for the installation
process.

2. Configure Date and Time Settings:

● Set the time zone and other date and time settings. You may also have the option to
synchronize with a Network Time Protocol (NTP) server.

3. Choose Installation Media:

● Select the installation media to use. Even if you booted from a specific source, you may
have the option to choose an alternative source for installation.

4. Choose Software Environment and Components:

Copyright 2023+ Cyber Life All Rights Reserved


91

● Select the software environment and components to install. This may include choosing a
base environment, which can vary from minimal installs to full-fledged GUI installations.
You might also be able to specify specific software packages.

5. Partition and Configure Storage:

● Design the structure of the root file system, including its size and file system type.
Configure logical volumes on available storage drives and define additional file systems
if needed.

6. Configure Networking Identity:

● Set up the system's networking identity. Configure network interfaces, assign IP


addresses, and specify hostnames and other networking information.

7. Configure User Accounts:

● Configure user accounts, including setting the root user's password and creating
additional administrator or standard user accounts.

8. Configure Security Policies:

● Apply security profiles and policies to the system, if available in the installer.

Copyright 2023+ Cyber Life All Rights Reserved

You might also like