0% found this document useful (0 votes)
57 views39 pages

Linux Compression and Backup Techniques

Getting information about the CompTIA Linux + Certification requirements.

Uploaded by

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

Linux Compression and Backup Techniques

Getting information about the CompTIA Linux + Certification requirements.

Uploaded by

Will Murphy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CompTIA Linux+

and LPIC-1: Guide


to Linux
Certification, 6e
Chapter 11: Compression,
System Backup, and
Software Installation

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 1
Chapter Objectives (1 of 2)

By the end of this chapter, you should be able to:


1. Outline the features of common compression utilities
2. Compress and decompress files using common compression utilities
3. Perform system backups using the tar, cpio, dump, and dd
commands
4. View and extract archives using the tar, cpio, restore, and dd
commands
5. Use burning software to back up files to CD and DVD

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 2
Chapter Objectives (2 of 2)

By the end of this chapter, you should be able to (continued):


6. Describe common types of Linux software
7. Compile and install software packages from source code
8. Install and manage software packages using the Red Hat Package
Manager (RPM) and Debian Package Manager (DPM)
9. Identify and support shared libraries used by software
10. Install and manage Snap, Flatpak, and AppImage applications

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 3
Compression

• Compression is a process in which files are reduced in size by stripping


out certain patterns of data
• The standard set of instructions used to compress a file is known as a
compression algorithm
• Compression ratio is the percentage by which the file size was
decreased
• Common compression utilities include: compress, GNU zip, xz, zip, and
bzip2

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 4
Using compress (1 of 3)

• compress uses the Adaptive Lempel-Ziv coding (LZW) compression


algorithm, which has an average compression ratio of 40-50%
• To compress files using compress, you specify the files to compress as
arguments
− Each file is renamed with a .Z filename extension to indicate that it
is compressed
− Use the -v (verbose) option to display the compression ratio during
compression

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 5
Using compress (2 of 3)

• The zcat command can be used to display the contents of a


compressed file
• The uncompress command can be used to decompress files that have
been compressed by the compress command
• The compress utility is a filter command that can take information
from Standard Input and send it to Standard Output

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 6
Using compress (3 of 3)

Table 11-1 Common options used with the compress utility

Option Description

-c When used with the uncompress command, it displays the contents of the compressed file to
Standard Output (same function as the zcat command).
-f When used with the compress command, it can be used to compress linked files. When used with
the uncompress command, it overwrites any existing files without prompting the user.
-r Specifies to compress or decompress all files recursively within a specified directory.

-v Displays verbose output (compression ratio and filenames) during compression and decompression.

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 7
Using GNU zip (1 of 2)

• GNU zip is used to compress files using the Lempel-Ziv compression


algorithm (LZ77)
− It varies slightly from the algorithm used by compress
− The average compression ratio for GNU zip is 60-70%
− It uses .gz filename extension by default
• To compress files using GNU zip, you can use the gzip command
− Use the –r option to compress all files in a certain directory

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 8
Using GNU zip (2 of 2)

• Use the zcat, zmore, zless, and zgrep commands to send the
contents of a gzip-compressed file to Standard Output
− The gzip command can accept information via Standard Input
• The gunzip command is used to decompress .gz files
− The gunzip command prompts you to overwrite existing files unless
the -f option is specified
• An advantage of gzip over compress is its ability to control the level of
compression via a numeric option (-1 results in the lowest compression
ratio and -9 results in the highest compression ratio)

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 9
Using xz

• The xz command can be used to compress files and Standard Input


using a Lempel-Ziv compression algorithm (LZMA)
− It uses a different implementation that typically yields a higher
compression ratio compared to compress and gzip for most files
(60-80%)
• To decompress xz-compressed files, you can use the -d option to the
xz command, or the unxz command

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 10
Using zip

• The zip command is a Linux implementation of the cross-platform


PKZIP utility, which was originally designed to compress multiple files
into a single compressed file
− It compresses files and Standard Input using the same implementation of
the Lempel-Ziv compression algorithm that gzip uses
− It often yields a similar compression ratio on average
− The zip command compresses linked files, as well as preserves file
ownership, modification, and access time during compression

• To view the contents of, or extract a zip-compressed file, use the


unzip command
Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 11
Using bzip2

• The bzip2 command compresses files using the Burrows-Wheeler


Block Sorting Huffman Coding compression algorithm
− It provides a compression ratio of 60% to 80% on average
• The filename extension given to bzip2-compressed files is .bz2
• The bzcat command can be used to display the contents of bzip2-
compressed files to Standard Output
• To decompress files, use the bunzip2 command followed by the
filename(s) to decompress

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 12
System Backup (1 of 2)

• System backup is a process whereby files and directories are copied to


an archive
• The backup copies of files and directories are called archives and they
should be stored at an alternate location
• Many types of media can be used to create archives
− Tapes, CDs, DVDs, a USB flash drive, a hard disk, or SSD
• It is good practice to copy an archive file to another server across the
Internet (called offsite backup)

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 15
System Backup (2 of 2)

• You should back up files used by system services, user files from home
directories, and any important system configuration files
• Common backup utilities include the following:
− tape archive (tar)
− copy in/out (cpio)
− dump/restore
− dd
− disc burning software

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 16
Using tape archive (tar)

• The tape archive (tar) utility is one of the oldest and most common
backup utilities and is executed via the tar command
− It can create an archive in a file on a filesystem or directly on a
device
• The tar command accepts options to determine the location of the
archive and action to perform on the archive
− Any arguments specified list the file(s) to place in the archive
• The tar command accepts options that allow you to compress an
archive immediately after creation

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 17
Using copy in/out (cpio)

• copy in/out (cpio) is a common backup utility, which can be executed


via the cpio command
− It includes options similar to the tar utility
− Some added features include the following:
▪ Long filenames
▪ The ability to back up special files, like device files
− It uses absolute pathnames by default when archiving

• There is no need to have an extension, however, it is good practice to


use extensions
Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 18
Using dump/restore (1 of 3)

• The dump command can be used to back up files and directories to a


device or file on filesystem
• The restore command can be used to restore those files and
directories backed up using dump
• The dump and restore commands can only work with files on ext2,
ext3, and ext4 filesystems
• dump was designed to backup entire filesystems to an archive
− /etc/dumpdates is the file used to store information about
incremental and full backups
Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 19
Using dump/restore (2 of 3)

• Archiving all data on a filesystem is known as a full backup


− You can choose to perform a full backup on weekends
• An incremental backup backs up only data that has changed since the
last backup
• You can perform up to nine different incremental backups using dump
− Number 0 represents a full backup
− Numbers 1 through 9 represent incremental backups

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 20
Using dump/restore (3 of 3)

Figure 11-1 A sample


backup strategy

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 21
Using dd

• The dd command backs up data block by block to an archive device or


file, without keeping track of the files that the blocks comprise
− This type of backup is called an image backup and is often used to
create archives of entire filesystems or disk structures (e.g., MBR)
− At minimum, the dd command requires an input file (if) and an
output file (of) option to be specified

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 22
Using Disc Burning Software (1 of 2)

• Disc burning software is used to write files to CD or DVD media


− It allows you to select the data to copy, organize the data, build a
CD or DVD filesystem, and write the entire filesystem to the CD or
DVD
• You can install Brasero on a Fedora system using the dnf install
brasero command as the root user
− Then, launch it from the GNOME desktop by navigating to Activities,
Show Applications, Brasero

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 23
Using Disc Burning Software (2 of 2)

Figure 11-2 The Brasero


disc burning software

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 24
Software Installation

• Software for Linux can consist of binary files that have been
precompiled to run on certain hardware architectures or as source
code, which must be compiled before use
• A package manager provides a standard format for distributing
programs and can be used to install, query, and uninstall packages
• Red Hat Package Manager (RPM) is a common package manager used
by Linux systems today, including Fedora
− Debian-based Linux distributions, such as Ubuntu Linux, use the
Debian Package Manager (DPM)

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 27
Compiling Source Code into Programs
(1 of 2)
• Program source code is typically obtained by cloning an online git
repository
• After you clone a git repository of source code, there will be a
subdirectory under the current directory containing the source code
• While inside the source code directory, the first step to installation is
to run the configure program
− This performs a preliminary check for system requirements and
creates a list of what to compile inside a file called Makefile

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 28
Compiling Source Code into Programs
(2 of 2)
• The make command looks for the Makefile and uses it to compile the
source code into binary programs using the appropriate compiler
• To install the compiled program on your system, you must type make
install to copy the complied executable programs to the correct
location on the filesystem
• After the program has been compiled and copied to the correct
location on the filesystem, you can remove the source code directory
and its contents from the system

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 29
Working with the Red Hat Package
Manager (RPM) (1 of 5)
• RPM packages have filenames that indicate the hardware architecture
for which the software was compiled and end with an .rpm extension
• To install an RPM package, use –i option to the rpm command

• Some RPM packages require that other RPM packages be installed on


your system first (known as package dependency)
− You receive an error message that indicates the RPM package that
needs to be installed first
− After installing the prerequisite packages, you can successfully
install your desired RPM package

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 30
Working with the Red Hat Package
Manager (RPM) (2 of 5)
• After installation, the RPM database is updated to contain information
about the installed package and files contained within
− To query the full package name, use the –q option
− Use the -i option, together with –q to display detailed package
information
− Use the -f option, together with –q to display the package to which
a specific file belongs
− To remove a package from the system, use the –e option

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 31
Working with the Red Hat Package
Manager (RPM) (3 of 5)
• Most RPM packages are available for free on Internet Servers called
software repositories
• You can use the yum (Yellowdog Updater Modified) command to search
Internet software repositories for RPM packages
• Fedora and many other Linux distributions use the dnf (Dandified
YUM) command alongside the repository information stored in the
/etc/dnf/[Link] and /etc/[Link].d/* files

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 32
Working with the Red Hat Package
Manager (RPM) (4 of 5)
• The dnf command tries several different software repositories that
contain the necessary software (called software mirrors) before finding
one that accepts a connection
• A package group is a group of related RPM packages that are often
installed together to provide a key function
− The dfn grouplist available command will display a list of
package group names
• On Fedora Linux, the graphical Software utility is used to view,
manage, and install software within a desktop environment

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 33
Working with the Red Hat Package
Manager (RPM) (5 of 5)

Figure 11-5 The Software


utility

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 34
Working with the Debian Package Manager
(DPM) (1 of 4)
• The Debian Package Manager (DPM) is used by default on Linux
distributions based on the Debian Linux distribution
− Ubuntu Linux in an example
• DPM packages use the .deb extension and are installed and managed
using the dpkg command

• The DPM database is stored within files in the /var/lib/dpkg directory)


− After you install a DPM package, the database is updated to contain
information about the package and files contained within

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 35
Working with the Debian Package Manager
(DPM) (2 of 4)
• Most DPM packages are hosted on Internet software repositories
• To download and install DPM packages, you can use the apt (Advanced
Package Tool) command or apt-get command
• To remove a DPM package, use the apt remove nmap command
• To update and upgrade a DPM package on your system, use the apt
update command
− You can also use this command to update the list of available DPM
packages from Internet software repositories

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 36
Working with the Debian Package Manager
(DPM) (3 of 4)
• You can add new repositories using the add-apt-repository
command
− You can search available repository information using the apt or
apt-cache command

• You can use the Aptitude utility to install, query, and remove DPM
packages
− You can start this utility by executing the aptitude command
− The aptitude command accepts many of the same arguments as
apt and apt-get

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 37
Working with the Debian Package Manager
(DPM) (4 of 4)

Figure 11-6 The Aptitude


utility

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 38
Understanding Shared Libraries

• When you install an RPM or DPM package, the package manager does a
preliminary check to ensure all shared libraries and prerequisite
packages required for the program to work properly are installed
− To identify which shared libraries are required by a certain program,
you can use the ldd command
− Run the ldconfig command to ensure that the list of shared library
directories (/etc/[Link]) and the list of shared libraries
(/etc/[Link]) are updated

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 39
Working with Sandboxed Applications
(1 of 2)
• Sandboxed applications ensure that each software package include a
unique copy of each required dependency
− This approach consumes additional storage for each application, but
it ensures that dependency issues cannot cause application
problems
• Flatpack and Snap are two package managers designed to obtain and
manage sandboxed applications
− Flatpack is installed by default on Fedora systems and Snap is
installed by default on Ubuntu systems

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 40
Working with Sandboxed Applications
(2 of 2)
• To install and manage sandboxed applications using Flatpak, you can
use the flatpak command
− Use the flatpak install application command to install a
sandboxed application
• To install and manage sandboxed applications using Snap, you can use
the snap command
− Use the snap install application command to install a
sandboxed application

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 41
Summary (1 of 2)

Now that the lesson has ended, you should be able to:
1. Outline the features of common compression utilities
2. Compress and decompress files using common compression utilities
3. Perform system backups using the tar, cpio, dump, and dd
commands
4. View and extract archives using the tar, cpio, restore, and dd
commands
5. Use burning software to back up files to CD and DVD

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 45
Summary (2 of 2)

Now that the lesson has ended, you should be able to (continued):
6. Describe common types of Linux software
7. Compile and install software packages from source code
8. Install and manage software packages using the Red Hat Package
Manager (RPM) and Debian Package Manager (DPM)
9. Identify and support shared libraries used by software
10. Install and manage Snap, Flatpak, and AppImage applications

Jason W. Eckert, Linux+ and LPIC-1 Guide to Linux Certification, 6th Edition. © 2024 Cengage. All Rights Reserved. May not be
scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 46

You might also like