Вы находитесь на странице: 1из 50

Archiving, Compression, and Managing Software Packages

Chapter Eleven

Compressing Files
Compressing files
Useful way to use less space for rarely accessed data Makes files smaller before transmitting them over network

gzip command
Compress any file; best compression 60-70% of original size Lempel-Ziv Compression gzip v sample sample.gz -v verbose option zcat sample.gz to view compressed file contents

gunzip command
Uncompresses file compressed using gzip gunzip v sample.gz Alternative: gzip d sample.gz

The gzip Utility (continued)

The gzip Utility (continued)

The gzip Utility (continued)

Compressing Files
bzip2 command
Compress any file; better compression than gzip BurrowsWheeler transform and Huffman coding bzip2 v sample sample.bz2 -v verbose option bzcat sample.bz2 to view compressed file contents

bunzip2 command
Uncompresses file compressed using gzip bunzip2 v sample.bz2 bzip2 d sample.bz2

The bzip2 Utility (continued)

The bzip2 Utility (continued)

System Backup
System backup: process whereby files are copied to an archive Archive: location (file or device) that contains copy of files
Typically created by a backup utility

Should backup user files from home directories and any important system configuration files
Possibly files used by system services as well

Several backup utilities available

tar, cpio, dump/restore, burning software

System Backup (continued)

Using tar for Archiving Files

tar archive
Tape Archive Single file that can contain other files and directory structure

tar command
Create tar archive Specify files to be included in backup archive on command line Writes data to file name or device

The tar Utility (continued)

The tar Utility (continued)

Using tar for Archiving Files

tar and compress an entire directorys contents
tar zcvf backup.tar.gz *

View contents of archive

tar ztvf backup.tar.gz *

tar to a tape device

tar cvf /dev/st0 *

Extract and uncompress

tar zxvf backup.tar.gz

Extract from a tape device

tar xvf /dev/st0

Tarball archive and compressed

.tar.gz or .tgz

Using tar and cpio for Archiving Files (continued)

cpio command
Copy in and out Similar to tar Reads from STDIN channel for file names Writes data back to STDOUT Examples Archive find /home u horvathe | cpio vocB O horvathe.cpio Extract cpio vicB I horvathe.cpio

tar and cpio

Help create incremental or multilevel backup

The cpio Utility (continued)

The cpio Utility (continued)

The dump/restore Utility

dump/restore: Used to back up files and directories to device or file on filesystem
Works only with files on ext2 and ext3 filesystems

Designed to backup entire filesystems to an archive /etc/dumpdates: file used to store information about incremental and full backups

The dump/restore Utility (continued)

Full backup: archiving all data on filesystem Incremental backup: backs up only data that has changed since last backup
Can perform up to nine different incremental backups

dump command: create archives for full or incremental backup restore command: extract archives created with dump

The dump/restore Utility (continued)

A sample back-up strategy

The dump/restore Utility (continued)

Burning Software
tar, cpio, and dump utilities copy data to backup medium in character-by-character or block-by-block format
Typically used with tape, floppy, and hard disk media

Disc burning software: used to write files to CD or DVD media

Build CD or DVD filesystem, organize the data, and write it all to CD or DVD

Ubuntu comes with k3b Disc Burner burning software Fedora comes with Brasero Disc Burner burning software

Managing Packages
Linux groups related files into packages for easier management Software package contains all files needed to install and use application Red Hat Package Manager format
Abbreviated as rpm

Debian Package Manager format

Abbreviated as deb

Managing Packages (continued)

Debian package format
Used by Debian Linux distributions .deb file extension dpkg old form for installing packages apt Advanced Packaging Tool dselect - utility manages Debian packages

Synaptic Package Manager in Ubuntu

Using rpm to Manage Software Packages

rpm command-line utility maintains database listing all software packages installed on system
Files included in each package Packages are dependent on other packages Other information

rpm command
Install new software packages Erase software packages from system

Using rpm to Manage Software Packages (continued)

Name of package file includes version information
gedit-2.4.0-3.i386.rpm Version 2.4.0 Release code 3 Platform i386

Using rpm to Manage Software Packages (continued)

Rpm command options fall into categories
-q optionquery database and learn about packages -i or -U optioninstall or upgrade package -e optionerase (uninstall) rpm package -f option: together with q used to display the package to which a specific file belongs

Install new rpm files either from:

Linux CD-ROM Internet

Using rpm to Manage Software Packages (continued)

Install package zsh-4.2.0-1.i386.rpm
rpm -uvh /tmp/zsh-4.2.0-1.i386.rpm

Can use regular expression to specify package names rpm utility maintains internal database of keys Key is part of encryption information used to digitally sign rpm file

Using rpm to Manage Software Packages (continued)

Fedora keys located in /usr/share/rhn --import imports keys into rpm database Check for keys
rpm --checksig -v packagefilename

Installing Programs Using RPM

Packages in RPM format have filenames that indicate hardware architecture for which the software was compiled
End with .rpm extension

To install an RPM package, use i option to rpm command

Command used to install, query, and remove RPM packages

Installing Programs Using RPM (continued)

Installing Programs Using RPM (continued)

Installing Programs Using RPM (continued)

Most RPM packages are located on Internet Servers
Called software repositories

yum command: used to search Internet software repositories for RPM packages
Installs dependent packages if necessary yum install packagename command yum update packagename command KPackageKit: graphical utility for installing or updating packages

Installing Programs Using RPM (continued)

The KPackageKit utility

Converts RPM to DEB Packages sudo aptitude install alien Download rpm sudo alien --scripts --to-deb avg75flm-r45a0973.i386.rpm avg75flm_r45-1_i386.deb Coverts to deb generated Install Debian package sudo dpkg --install avg75flm_r45-1_i386.deb

Repairing Package Manager

sudo aptitude install -c
Checks apt may need to be run if Synaptic package manager hangs

sudo aptitude install --fix-missing

sudo aptitude -f install
Fix packages; even

sudo dpkg --configure -a

Attempts to install all partially installed packages

APT Tools
aptitude install package-name
Installs a package

aptitude reinstall package-name

Reinstalls a package

aptitude remove package-name

Removes a package

aptitude purge package-name

Removes package and configuration files
aptitude show packagename
Displays information about the package, including dependencies.

May also use apt-get for many commands

aptitude update aptitude upgrade

APT Tools

Updates the list of available packages from the apt sources Upgrades installed packages to the most recent versions.

aptitude safe-upgrade
The safest way to upgrade is to use the action 'safe-upgrade'. The new action will upgrade a package only if it does not impact other packages, i-e: if it is necessary to add or remove a dependency package during upgrade, safe-upgrade won't upgrade

aptitude full-upgrade

APT Tools

Upgrades installed packages to the most recent versions. aptitude will upgrade to the latest version of a package even if it is necessary to add or remove dependencies.

aptitude clean
Deletes packages in the APT cache.

APT Tools
apt-cache search keyword
Searches for packages that match a keyword

apt-cache depends packagename

Display dependencies; packages that must be installed before this package can be used.

aptitude search packagename

Searches for packages have the packagename

Sites where packages can be downloaded /etc/apt/sources.list # comment deb executable deb-src source code

Monitors which software packages are installed Location of packages Dependencies Will not download packages from a repository dpkg --list packagename.deb
Information about packages

dpkg --install packagename.deb

Install packages

dpkg -- purge packagename

Delete package and configuration files

dpkg --status packagename
Displays information about an installed package

dpkg --search packagename

Search for packages with a name

Updating the System Automatically

Download upgrades or security fixes for key operating system packages installed on system

Software Updates in Ubuntu

Updating the System Automatically

Red Hat Network
Download upgrades or security fixes for key operating system packages installed on system Subscribe to Red Hat Network service
May be entitled to annual subscription as part of purchase Individuals can use for free

Updating the System Automatically (continued)

Red Hat Network
Uses icon on Panel in GNOME or KDE to indicate status
Check mark in blue circle Flashing exclamation point in red circle

To register, double-click network alert icon on panel To configure, right-click alert icon

Updating the System Automatically (continued)

up2date utility
Manage updated software

Configure overall settings for Red Hat Network

System Tools then Red Hat Network on GNOME main menu Tabs
General Retrieval/installation Package exceptions

Compiling Source Code into Programs

Procedure for compiling source code into binary programs standardized among most OSS developers Source files are typically stored in a .tar.gz file make command: looks for Makefile and it to compile the source code into binary using compiler
Makefile: contains most of the information and commands necessary to compile a program, as well as instructions for use of commented areas

make install command: copies complied executable programs to correct location