CHAPTER 5 Software Management and System Monitoring
CHAPTER 5 Software Management and System Monitoring
SYSTEMS
PACKAGE MANAGERS AND INSTALLATION FROM SOURCES
CHAPTER 5: OUTLINE
5.1 Package concept
5.2 RPM and YUM
5.3 Debian Package managers
5.4Installations from sources
5.5Management of shared Libraries
5.6 Process management
5.7 Cron and At
5.8 Monitoring of Linux Systems
5.1 Package Concept
• A package is a collection of files that are installed on the computer.
• Any computer’s software is like a house of cards relying on several more, and so on.
• Linux package management tools are intended to help build and modify this house of cardsby tracking what software is installed.
• Packages are usually distributed as a single file that are similar to tarballs.
• Once installed, most packages consist of dozens or hundreds of files, and the package system tracks them all.
5.1 Package Concept
• Package systems maintain a database of installed files.
• Dependencies are the requirement of packages for one another.
• By tracking files and dependencies, package systems permit easy upgrades and uninstallation . The package manager can upgrade, remove a
package, and it will replace or remove every file in the package.
5.2 Package Concept
Advantages Disadvantages
Easy installation and uninstallation Loss of performance due to
compilation on a different platform
Easy Update
Protection of configuration files
OPERATION DESCRIPTION
-e Uninstalls a package
-b Builds a binary package, given source code
and configuration files; moved to the
rpmbuild program with RPM v4.2
- - root dir Any Modifies the Linux system having a root directory located at dir
- -force -i, -U, -F Forces installation of a package even when it means overwriting
existing files or packages
-h, or - - -i, -U, -F Displays a series of hash marks (#) to indicate the progress of the
hash operation.
-v -i, -U, -F Used in conjunction with the –h option to produce a uniform
number of hash marks for each package
- - nodeps -i, -U, -F Specifies that no dependency checks be performed. Installs or
removes the package even if it relies on a package or file that is not
present or is required by a package that is not being uninstalled.
- - test -i, -U, -F Checks for dependencies, conflicts, and other problems without
5.2.1 RMP command set
OPTIONS USED WITH DESCRIPTION
OPERATIONS
--prefix path -i, -U, -F Sets the installation directory to path. Works
only for some packages
- a or -- all -q, -V Queries or verifies all packages
upgrade Works like update with the - -obsoletes flag set, which handles
obsolete packages in a way that is superior or when performing a
distribution version upgrade.
remove or erase Deletes a package from the system; similar to rpm –e, but yum
5.2.2 YUM
COMMAND DESCRIPTION
list Displays info about a package (version and available
updates)
search Searches package names, summaries, packagers and
descriptions for a specified keyword
Ex:
$gunzip name-of-program.tar.gz
• After decompression, the program should be removed from the archive.
• The tool used in creating and extracting archives is tar
• The options of tar are:
• -c to create an archive
• -x to extract the archive
• -f to indicate a file
• V :verbose, giving indications on the progress
• Ex: tar -xvf name-of-program.tar
• If the original archive was a directory, its entire structure would be recreated.
5.4 Installations from Source (Steps)
• tar decompresses and extracts archives with the single command with the following
additional options:
• -z for compression from gzip
• -j for compression from bzip2
• Ex
$tar -xzvf program-name.tar.gz
$tar -xjvf program-name.tar.bz2
Then enter the root of the directory where the program was extracted.
$ cd program-name
3. Configuration
$ ./configure from the directory where you extracted your software
5.4 Installations from Source (Steps)
• Dynamic libraries are loaded by the utility ld.so using the following search
order on disks.
• The directories mentioned in environment variable LD_LIBRARY_PATH;
• The cache file /etc/ld.so.cache that contains the list of libraries and search
directories. It is updated by the command ldconfig that searches the files
mentioned in /etc/ld.so.conf
• The directories /lib and /usr/local/lib etc.
• The ldd command lists the shared libraries needed by an executable
• Ex: ldd /bin/ls
5.5 Processes
• A process is the instantiation of a program
• From the kernel's perspective, a process is:
• An address space (the set of memory pages with code, libraries,
and data)
• Set of data structures (within the kernel)
– The process's address space map
– Current status
– Execution priority
– Resources used
– The owner
• Multiple variations of ps
• ps -aux (BSD, Linux)
• ps -Af (Solaris)
5.5.6 Monitoring Processes: top
•/bin/top is optional in some OSes
• Shows top-n CPU-using processes
• Plus other stats, like memory usage and availability,
system load
• Can renice within top
• Automatically refreshes screen every 5 seconds
• Can focus on a particular user
5.5.6 Runaway Processes
•What can you do about processes using an
unusual amount of resources (memory, CPU,
disk space)?
• Identify resource hogs using top and/or ps
• Contact owner and ask about resource usage
• Suspend using STOP signal (might break job)
• Contact owner, restart or kill later
• Renice CPU hog
5.5.7 Creating Periodic Processes
• Automation, as you've heard, is key to efficiency
• Instead of manually performing tasks daily, weekly, or monthly,
you can schedule them
– cron (wakes up every minute)
– anacron ( hourly)
Includes tasks like:
• monitoring, log rotation, backups, file distribution
• At
5.5.7 cron
• cron daemon performs tasks at scheduled times
• crontab files are examined by cron for schedule
- /etc/crontab, /etc/cron.d/*, /var/spool/cron/*
• cron wakes up each minute and checks to see if anything needs to be executed
• cron is susceptible to changes in time
• doesn't compensate for when machine is down, or time changes (clock adjustments or
daylight savings time) that are sufficiently large (3 hours, at least for some implementations)
• anacron works daily
• records when task last performed, and will catch up with missing time
5.5.7 cron
• cron daemon performs tasks at scheduled times
• crontab files are examined by cron for schedule
- /etc/crontab, /etc/cron.d/*, /var/spool/cron/*
• cron wakes up each minute and checks to see if anything needs to be executed
• cron is susceptible to changes in time
• doesn't compensate for when machine is down, or time changes (clock adjustments or
daylight savings time) that are sufficiently large (3 hours, at least for some implementations)
• anacron works daily
• records when task last performed, and will catch up with missing time
5.5.7 crontab files
• Filename provides username in /var/spool/cron/
• Format of a crontab file
minutes Hour Day of month month day of week command
0-59 0 - 23 1-31 1 - 12 0 -7
• Example crontab entries
• 30 2 * * 1 (cd /home/frungang/project; make)
run make at 2:30 each Monday morning
• 36 2 * * 7 root /usr/local/sbin/backup.sh
Backup at 2:36 every Sunday
5.5.7 crontab files
0-59 0 - 23 1-31 1 - 12 0 -7
SHELL=/bin/bash
MAILTO=tbaker
HOME=/home/tbaker
0,30 * * * * /usr/bin/fetchmail -s
0 2 * * mon /usr/local/bin/clean-adouble $HOME