package_name-version-release.arch.rpm
postfix-2.3.3-2.1.el5_2.i386.rpm
To download and install packages you obtain them from repositories. Needless to say you should only use repositories and files from trusted sources. The Red Hat Network (RHN) also provides packages and software updates from Red Hat clients. It also provides a web interface which allows for snapshots, scheduled commands, and kickstart installations. Instead of going into every single detail relating to rpm and yum (the frontend to rpm), we will look at common tasks and commands for system administration.
Querying Packages
To list all install packages on the system:
$rpm -qa
- or -
$rpmquery -a
Use commands like sort, grep, and wc to filter the results.
Check to see if Apache is installed:
$rpm -qa | grep httpd
If it returns the package then it is installed, otherwise nothing will be returned meaning it is not installed.
Also available is the yum commands which produce alot of output so make sure to pipe them:
$yum list | grep httpd
httpd.i386 2.2.3-31.el5.centos.2 installed
Searching for Packages
To find a package to install:
$yum search httpd
Installing Packages
To install Apache with no prompts:
$yum -y install httpd.i386
You can also use rpm to install packages that you have downloaded:
$rpm -ivh mypackage.rpm
Removing Packages
To uninstall Apache:
$yum remove httpd
You can also do the same with the rpm command:
$rpm -e mypackage
Some other commands that may be useful include updating, upgrading, obtaining information on packages, and group installs.
$yum update
$yum check-update
$yum info
$yum groupinstall
$yum clean all
For those of you can don't like the command line you can also use the GUI tool that comes with Red Hat called pirut. This is the package manager which can perform all the same commands that we have discussed via the command line. The last part of package management that we will discuss deals with YUM repositories. When handling a large number of systems and installs you will probably want to configure a local package repository (unless you happen to have a massive bandwidth pipe to the internet). It also will help with dependency issues because it will make certain that all packages are using the versions. to create a local repository follow these steps:
1) Download the needed package
$yum -y install createrepo
2) Create a directory for the repors
$mkdir -p /var/yum/repos.d && cd /var/yum/repos.d
3) Move all packages that you wish to be made available
4) Execute the createrepo command to convert the packages to local distribution
$createrepo -v .
5) Create the repo file for the repository
$nano /etc/yum.repos.d/server01.repo
[server01]
name=yum repository for server01
baseurl=ftp://server01/var/yum/repos.d/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Finally you will need to make sure that your main yum configuration file is in order and specifies you local repositories as well. You can find the file in /etc/yum.conf. You now should have a pretty good handle on managing packages for your system. There are obviously many other commands and options that you can use with yum or rpm however it is better to have a foundation and then work through the --help parameters. This will show you all the options available and as always use the man pages for clarification of anything you may need.
0 comments:
Post a Comment