0% found this document useful (0 votes)
20 views46 pages

CHAPTER 5 Software Management and System Monitoring

Chapter 5 covers software management and monitoring of systems, focusing on package managers like RPM, YUM, and Debian tools for installation and management of software. It explains the package concept, installation from sources, management of shared libraries, and process management, including process attributes and life cycles. The chapter also discusses the handling of signals and their importance in process control.

Uploaded by

Steve Ndjeumou
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)
20 views46 pages

CHAPTER 5 Software Management and System Monitoring

Chapter 5 covers software management and monitoring of systems, focusing on package managers like RPM, YUM, and Debian tools for installation and management of software. It explains the package concept, installation from sources, management of shared libraries, and process management, including process attributes and life cycles. The chapter also discusses the handling of signals and their importance in process control.

Uploaded by

Steve Ndjeumou
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
You are on page 1/ 46

CHAPTER 5: SOFTWARE MANAGEMENT AND MONITORING OF

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.

• Package management relates to programs as files on your hard disk.

• 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

Easy management of installed Corruption of the installed


packages database of installed packages
may make the system
unmanageable
5.2 RMP Package Manager
• Developed by Red Hat for its distribution but used today by many distributions like Fedora,
SuSe, Mandriva, CentOS
• Convention for naming RPM packages
• Packagename-a.b.c-x.arch.rpm
• The database is stored in /var/lib/rpm
• Information on the database of packages is found in /usr/lib/rpm
• Management is done using the rpm command.
5.2.1 RMP Package Manager
•Rpm command syntax
#rpm [operation] [options] [package-files|package-names]
operation Description
-i Installs a package; system must not contain a package of the
same name
-U Installs a new package or upgrades an existing one
-F or --freshen Upgrades a package only if an earlier version already exists
-q Queries a package – finds whether a package is installed, what
files it contains and so on
-V or --verify Verifies a package – checks that its files are present and
unchanged since installation
5.2.1 RMP command set (most important options)

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

--rebuild Builds a binary package, given a source


RPM
--rebuilddb Rebuilds the RPM database to fix errors
5.2.1 RMP command set
OPTIONS USED WITH DESCRIPTION
OPERATIONS

- - 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

-f file -q Queries the uninstalled RPM package -file

-i -q Displays package information, including the


package maintainer,
-R or -- -q Displays the packages and files on which this
requires one depends
5.2.1 RMP command set
• The file rpmrc controls the actions of the rpm command.
• There are many rpmrc files in the system, /usr/lib/rpm/rpmrc,
/etc/rpmrc and also the personalized rpmrc each users home.
• The contents of the rpmrc are displayed using the –showrc option of
the rpm command
• # rpm –showrc
• The rpm2cpio program can be used to create a cpio archive
• $rpmcpio samba-3.6.5-86.fc17.src.rpm > samba-3.6.5-86.fc17.src.cpio
5.2.2 YUM
• YUM enables you to easily install a package and all its
dependencies using a single command line.
• When using yum, you dont even need to locate and
download the package files, because YUM does this for you
by searching in one or more repositories – Internet sites that
host RPM files for a particular distribution.
• Yum is configured via /etc/yum.conf file with additional
configuration files in the /etc/yum.repos.d/ directory
• Yum syntax:
• #yum [options] [command] package
5.2.2 YUM
COMMAND DESCRIPTION
install Installs one or more packages by package name. Also installa
dependencies of the specified package or packages

update Updates the specified package or packages to the latest available


version. If no packages are specified, yum updates every installed
package
check-update Checks to see whether updates are available. If they are yum
displays their names, versions, and repository area

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

info Displays info about a package, similar to rpm –qi


command
clean Cleans up the Yum cache directory.
resolvedep Displays package matching the specified dependency
5.2.2 YUM
• There are GUI versions of yum. Examples include :
yumex, kyum
• You can use the text-mode to install these front-ends
as in
#yum install yumex
5.3 DEBIAN PACKAGE MANAGERS
• Used by distributions like Debian, Ubuntu, Linux Mint
and Xandros.
• Like rpm, it is neutral with respect to OS and CPU
type. Extremely rare outside Linux.
• Follows a naming convention similar to rpm ending
with .deb
Ex:
apport_2.0.1-0ubuntu12_all.deb
udev_175-0ubuntu9.1_amd64.deb
5.3.1 dpkg
•It allows you to install, uninstall, visualize,
configure and construct Debian packages.
•The configuration files are found in
/etc/dpkg/dpkg.cfg and the options controlling
the behaviour of dpkg are found in it.
•The files containing information on Debian
packages are found in the directory
/var/lib/dpkg
5.3.1 dpkg
Common options of dpkg command are:
• -i app-name.deb: installs the application app-name.deb
• -u : update
• -r app-name.deb: uninstalls the application app-name.deb
• -l | grep appli : searches if appli is installed . Without grep it would list all packages.
• -L app-name : lists the files of package app-name ( if it is installed) and its location.
• -- unpack : unpacks but does not configure the package.
• The dpkg-reconfigure reconfigurs an already installed package
5.3.2 APT
APT(Advanced Package Tool) is a tool that uses dpkg
commands on which are added other functionalities for the
definition of sources (local disks, cdrom, or Internet using
HTTP or FTP) of applications to be installed and the
management of dependencies.
• Sources are defined in /etc/apt/sources.list
• The main configuration file is found in /etc/apt/apt.conf
5.3.2 APT
The main options of apt are:
- apt-get install prog: installs prog
- apt-get remove prog : uninstalls prog
- apt-get - -purge remove prog: uninstalls prog and its configuration file
- apt-get install prog1 prog2- : installs prog1 and uninstalls prog2
- apt-get remove prog1 prog2+: uninstalls prog1 and installs prog2
- apt-get - - reinstall prog1: reinstalls package prog1
5.3.2 APT
The main options of apt continue:
- apt-get update: updates a list of available packages
- apt-get upgrade: upgrades the packages that can be upgraded.
- apt-get dist-upgrade: upgrades the distribution
- apt-get source prog: download the source files of prog
- apt-get -b source prog: download the source files of prog and then compiles it
- apt-get build-dep prog: download the dependencies of prog that would be
compiled
5.3.2 APT
Other apt commands:
- apt-show-versions –u: displays the list of packages that can be updated
- apt-cache search foobar: searches the occurrence of foobar in the list of
packages
- apt-cache show package: displays the description of package
Other Tools
- dselect: a tool that installs a package and also dependent packages
- alien: A program that converts rpm to dpkg format and vice versa
5.4 Installations from Source
- The oldest method of installation of Linux programs
- Sources are made up of archives and compressed to
facilitate their distribution
- The form most often is:
Program-name-version.tar.gz
5.4 Installations from Source (Steps)

1. Download the source code from github or using wget


2. Decompress the archive
• Decompression depends on the tool used in compressing the
archive. There are three tools most widely used

Compression tool Decompression File extension


command
compress uncompress .Z
gzip gunzip .gz
bzip bunzip .bz
bzip2 bunzip2 .bz2
5.4 Installations from Source (Steps)

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)

4. Compilation and installation


- $ make or make all
- # make install

- It is important sometimes to use the command make clean to


delete previous files generated by the compilation
5.4 Management of shared Libraries

• Libraries are functions genrally shared and used by a binary


program in its executable form.
• There are two types of libraries
• Static libraries which are included in the main file of the executable
(.a)
• Dynamic libraries or shared libraries when the codes are not included
in the main file of the executable (.so in linux and .dll in Windows)
• Dynamic libraries can be called by many programs simultaneously
and they are associated with processes in the course of the
execution.
5.4 Management of shared Libraries

• 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

– Signal mask (which signals are blocked)

– The owner

– Which instructions are currently being executed


5.5.1 Process Attributes
• Process id:
• A unique number in that identifies a program in a system
• Processes are created through cloning that permits it to copy some of its information for
other programs. When a process is cloned, there is a parent and a child.
• Real and effective user ID – UID and EUID
• Real and effective user ID – UID and EUID
• Also records original EUID (saved UID)
• Can be re-accessed later in program (even after changing EUID)
• Real and effective group id (GID and EGID)
• Niceness
• The CPU time available depends on its scheduling priority
• Users can make their processes 'nicer' to the rest of the system

• Control terminal – where stdin, stdout, stderr are attached


5.5.2 Process Life Cycle
• An existing process calls fork
● Parent is told PID of child
● Child process is told
• Child can use exec (or similar) to start a new program
• When ready to die, process calls _exit(2) with exit code
• Process becomes a zombie
• Parent must wait(2) to collect status of dead children
• Resource usage, why killed
• Orphans are re-mapped to init
5.5.3 Signals
● Signals are process-level interrupt requests
● Uses
• Inter-process communication
• Terminal driver can kill, interrupt or suspend processes (Ctrl-C, Ctrl-Z)
• Can be sent by admin (with kill) for various purposes
• Can be sent by kernel when process breaks a rule
• e.g., division by zero
• Can be sent by kernel for i/o available, death of child
5.5.3Handling Signals
• Process can designate a signal handler for a particular signal
• If no handler, kernel takes some default action
• When handler is finished catching signal, execution continues where the
signal was received
• Process can request that particular signals be ignored, or blocked
• If signal is received while blocked, one instance of that signal is buffered
until it is unblocked
5.5.3 Important Signals
# NAME DESCRIPTION DEFAULT CATCH? BLOCK? DUMP?

1 HUP HANGUP TERMINATE YES YES NO

Reset request; clean up process on terminal (modem hangup)


*csh processes ignore HUP; bash users need nohup command
2 INT INTERRUPT TERMINATE YES YES NO

Control-C, can catch and clean up before quiting.


3 QUIT QUIT TERMINATE YES YES YES

Similar to TERM, but generates a core dump


9 KILL KILL TERMINATE NO NO NO

Never received by process; OS terminates process.


* BUS BUS ERROR TERMINATE YES YES YES

Error signal. Typically a memory alignment problem.


11 SEGV SEGMENTATION FAULT TERMINATE YES YES YES
SENDING SIGNALS
#kill [-signal] pid
#kill sends TERM signal by default
#kill -9 pid = = = kill -KILL pid
‘’Guarantees’’ that the process would die
# sudo killall httpd
- killall removes need for pid
5.5.4 Process States
● Process exist in one of four states
• Runnable – can be executed
• Sleeping – waiting for some resources
- Gets no CPU time until resource is available
• Zombie – trying to die (parent hasn't waited)
• Stopped – process is suspended (i.e., not permitted to run)
-Like sleeping, but can't wake until CONT received
5.5.5 Scheduling Priority
• “Niceness” is hint to kernel about how often to schedule the process
• Linux ranges from -20 (high priority, not nice) to +19 (low priority,
very nice), 0 is default
• User/process can raise, but not lower niceness
• Root can lower
• Examples
$nice +5 ~/bin/longtask
$renice -5 8829
$sudo renice 5 -u boggs
5.5.6 Monitoring Processes: ps
• /bin/ps is the primary tool
• Shows
– PID, UID, priority, control terminal
– Memory usage, CPU time, status

• 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

minutes Hour Day of month month day of week command

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

You might also like