The default utility used to manage software packages on Red Hat Enterprise Linux and CENTOS is yum, which stands for Yellowdog update manager. Yum is designed to work with repositories, which are online depots of available software packages.
While installing Red Hat Enterprise Linux, it asks you to register with Red Hat Network (RHN). From RHN, different repositories are provided. After registering with RHN, you can install software packages that are verified by Red Hat automati- cally. If you are using CentOS, you get access to the CentOS repositories. If you choose to install Red Hat Enterprise Linux without a registration key, however, it cannot get in touch with the RHN repositories, and you end up with no repositories at all. In that case, you have to be able to specify yourself which repository you want to use.Note that repositories are specific to an operating system.
To tell your server which repository to use, you need to create a file with a name that ends in .repo. In that file you need the following contents:
[label]The .repo file can contain different repositories, each section starting with a label that identifies the specific repository.
name=Use this to specify the name of the repository you want to use.
baseurl=Contains the URL that points to the specific repository location.
In the repository files that are provided by default, you may find several repositories in one file, . This is useful to group reposi tories that belong together in one file, and is often done in repository files that are provided as a default. If you are creating repository files yourself, you are free to create separate files for each repository.
Working with yum search
To install packages with yum, you first need to know the exact name of the package. The yum search command can help you with that. When you use yum search, it first gets in touch with the online repositories (which might take a minute), after which it downloads the most recent repository metadata to the local machine. Then, yum search looks in the package name and description for the string you have been looking for.
Desktop]# yum search nmap Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.nbrc.ac.in * epel: ftp.jaist.ac.jp * extras: mirror.nbrc.ac.in * nux-dextop: mirror.li.nux.ro * updates: mirror.nbrc.ac.in ============================== N/S matched: nmap =============================== nmap-frontend.noarch : The GTK+ front end for nmap nmap-ncat.x86_64 : Nmap’s Netcat replacement nmap.x86_64 : Network exploration tool and security scanner Name and summary matches only, use "search all" for everything.
Once you search for a package using yum search, you can use ‘yum info package’ to view additional information about the package.
Desktop]# yum info nmap Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.nbrc.ac.in * epel: ftp.riken.jp * extras: mirror.nbrc.ac.in * nux-dextop: mirror.li.nux.ro * updates: mirror.nbrc.ac.in Available Packages Name : nmap Arch : x86_64 Epoch : 2 Version : 6.40 Release : 7.el7 Size : 4.0 M Repo : base/7/x86_64 Summary : Network exploration tool and security scanner URL : http://nmap.org/ License : GPLv2 and LGPLv2+ and GPLv2+ and BSD Description : Nmap is a utility for network exploration or security auditing. : It supports ping scanning (determine which hosts are up), many : port scanning techniques (determine what services the hosts are : offering), and TCP/IP fingerprinting (remote host operating system : identification). Nmap also offers flexible target and port : specification, decoy scanning, determination of TCP sequence : predictability characteristics, reverse-identd scanning, and more. : In addition to the classic command-line nmap executable, the Nmap : suite includes a flexible data transfer, redirection, and : debugging tool (netcat utility ncat), a utility for comparing scan : results (ndiff), and a packet generation and response analysis : tool (nping).
Installing Software with yum
we can install packages by using yum install package-name command.
# yum install -y nmap
~]# yum install nmap Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.nbrc.ac.in * epel: ftp.jaist.ac.jp * extras: mirror.nbrc.ac.in * nux-dextop: mirror.li.nux.ro * updates: mirrors.vinahost.vn Resolving Dependencies –> Running transaction check —> Package nmap.x86_64 2:6.40-7.el7 will be installed –> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================================== Installing: nmap x86_64 2:6.40-7.el7 base 4.0 M Transaction Summary ====================================================================================================================================================== Install 1 Package Total download size: 4.0 M Installed size: 16 M Is this ok [y/d/N]: y Downloading packages: nmap-6.40-7.el7.x86_64.rpm | 4.0 MB 00:00:31 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 2:nmap-6.40-7.el7.x86_64 1/1 Verifying : 2:nmap-6.40-7.el7.x86_64 1/1 Installed: nmap.x86_64 2:6.40-7.el7 Complete!
By default ‘yum install’, will prompt you to accept or decline before installing the packages. If you want yum to install automatically without prompting, use -y option.
We could also update the nmap package. Just change the command from install to update
# yum update -y nmap
Uninstall a package using yum remove
~]# yum remove nmap Loaded plugins: fastestmirror, langpacks Resolving Dependencies –> Running transaction check —> Package nmap.x86_64 2:6.40-7.el7 will be erased –> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================================== Removing: nmap x86_64 2:6.40-7.el7 @base 16 M Transaction Summary ====================================================================================================================================================== Remove 1 Package Installed size: 16 M Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : 2:nmap-6.40-7.el7.x86_64 1/1 Verifying : 2:nmap-6.40-7.el7.x86_64 1/1 Removed: nmap.x86_64 2:6.40-7.el7 Complete!
By using Yum list command you can list out the available packages in yum Repositories
Desktop]# yum list |grep less java-1.7.0-openjdk-headless.x86_64 1:188.8.131.52-184.108.40.206.el7 @anaconda java-1.8.0-openjdk-headless.x86_64 1:220.127.116.11-3.b17.el7 @anaconda less.x86_64 458-9.el7 @anaconda java-1.7.0-openjdk-headless.x86_64 1:18.104.22.168-22.214.171.124.el7_2 updates java-1.8.0-openjdk-headless.x86_64 1:126.96.36.199-2.b15.el7_2 updates java-1.8.0-openjdk-headless-debug.x86_64 1:188.8.131.52-2.b15.el7_2 updates lesstif.x86_64 0.95.2-8.el7 epel lesstif-clients.x86_64 0.95.2-8.el7 epel lesstif-devel.x86_64 0.95.2-8.el7 epel lesstif-mwm.x86_64 0.95.2-8.el7 epel libreoffice-headless.x86_64 1:184.108.40.206-5.el7_2.1 updates nodejs-less.noarch 1.7.0-2.el7 epel php-lessphp.noarch 0.5.0-2.el7 epel python-blessings.noarch 1.5-3.el7 epel python-lesscpy.noarch 0.9j-4.el7 epel wireless-tools.x86_64 1:29-13.el7 epel wireless-tools-debuginfo.x86_64 1:29-9.1.el7.nux nux-dextop wireless-tools-devel.x86_64 1:29-13.el7 epel
If you want to see which packages are installed on your server,instead you can use the yum list installed command.
#yum list installed
Desktop]# yum list installed |grep less java-1.7.0-openjdk-headless.x86_64 1:220.127.116.11-18.104.22.168.el7 @anaconda java-1.8.0-openjdk-headless.x86_64 1:22.214.171.124-3.b17.el7 @anaconda less.x86_64 458-9.el7 @anaconda
The yum list command can also prove useful when used with the name of a specific package as its argument.
While managing specific services on a Linux machine, you often need several different packages. If, for instance,while configuring your server as a web server, you need to install additional packages like PHP as well in many cases.Instead of searching and installing all the individual packages that belongs to a specific function, you can simply install the group, which will install all the packages that belongs to the group.
~]# yum group list Available Groups: CIFS file server Compatibility Libraries Console Internet Tools Desktop Desktop Platform Desktop Platform Development Development Tools Eclipse Educational Software Electronic Lab FCoE Storage Client Fedora Packager General Purpose Desktop Graphical Administration Tools Haskell Legacy UNIX Compatibility Messaging Client Support Messaging Server Support Milkymist MySQL Database client MySQL Database server NFS file server Network Storage Server SNMP Support Scientific Support Security Tools Server Platform Server Platform Development Smart Card Support Storage Availability Tools System Administration Tools System Management TeX support TurboGears application framework Virtualization Web-Based Enterprise Management Xfce iSCSI Storage Client Done
# yum groupinstall "<group name>"
we can install specific software group, by using groupinstall option.
If you’ve already installed a software group using yum groupinstall , and would like to upgrade it to the latest version, use ‘ yum groupupdate ’ and we can remove it by using yum groupremove
All yum commands goes against one or more yum repositories. To view all the yum repositories that are configured in your system, do ‘yum repolist’ as shown below.
The following will display only the enabled repositories.
Desktop]# yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.nbrc.ac.in * epel: ftp.jaist.ac.jp * extras: mirror.nbrc.ac.in * nux-dextop: mirror.li.nux.ro * updates: mirror.nbrc.ac.in repo id repo name status !adobe-linux-x86_64 Adobe Systems Incorporated 2 !base/7/x86_64 CentOS-7 – Base 9,007 !bsrtech bsrtech 1,164 *!epel/x86_64 Extra Packages for Enterprise Linux 7 – x86_64 9,627 !extras/7/x86_64 CentOS-7 – Extras 226 !nux-dextop/x86_64 Nux.Ro RPMs for general desktop use 2,360 !updates/7/x86_64 CentOS-7 – Updates 919 repolist: 23,305
Use ‘yum provides’ if you like to know which package a particular file belongs to. For example, if you like to know the name of the package that has the /etc/httpd/conf/httpd.conf file, do the following.
Desktop]# yum provides /etc/httpd/conf/httpd.conf Loaded plugins: fastestmirror, langpacks httpd-2.4.6-40.el7.centos.x86_64 : Apache HTTP Server Repo : base Matched from: Filename : /etc/httpd/conf/httpd.conf httpd-2.4.6-40.el7.centos.x86_64 : Apache HTTP Server Repo : @anaconda Matched from: Filename : /etc/httpd/conf/httpd.conf
The “yum clean all” command will not only remove cached packages, but also any headers. i do it occasionally to totally flush out everything in case there are obsolete headers – which can also take up space.
yum clean packages
Eliminate any cached packages from the system. Note that pack-
ages are not automatically deleted after they are downloaded.
yum clean headers
Eliminate all of the files which yum uses to determine the
remote availability of packages. Using this option will force
yum to download all the headers the next time it is run.
yum clean all
Runs yum clean packages and yum clean headers as above.”
Desktop]# yum clean Loaded plugins: fastestmirror, langpacks Error: clean requires an option: headers, packages, metadata, dbcache, plugins , expire-cache, rpmdb, all [ [email protected]
Desktop]# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: adobe-linux-x86_64 base bsrtech epel extras nux-dextop updates Cleaning up everything Cleaning up list of fastest mirrors
While working with yum, all actions are logged to the /var/log/yum.log file. You can use the yum history command to get an overview of all actions that have been issued.
~]# yum history Loaded plugins: fastestmirror, langpacks ID | Login user | Date and time | Action(s) | Altered ——————————————————————————- 10 | root <root> | 2016-03-16 15:32 | Erase | 1 9 | root <root> | 2016-03-16 15:23 | Install | 1 8 | root <root> | 2016-03-16 14:52 | Install | 1 7 | root <root> | 2016-03-14 13:49 | Install | 1 6 | root <root> | 2016-03-14 13:48 | Install | 37 5 | root <root> | 2016-03-14 13:25 | Install | 1 4 | root <root> | 2016-03-14 13:25 | Update | 1 3 | root <root> | 2016-03-14 13:17 | Install | 1 2 | root <root> | 2016-03-14 12:47 | Install | 1 1 | System <unset> | 2016-03-14 11:17 | Install | 1939 history list
From the history file, it is possible to undo specific actions; use yum history undo followed by the number of the specific action(mentioned as ID in above output) you want to undo.
On your system, two package databases are maintained:
The yum database and
The rpm database.
When you are installing packages through yum, the yum database is updated first, after which the updated information is synchronized to the RPM database. If you install packages using the rpm command, the update is written to the rpm database only and will not be updated to the yum database, which is an important reason not to use the rpm command anymore to install software packages.
转载本站任何文章请注明：转载至神刀安全网，谢谢神刀安全网 » Managing Software Packages with yum in RHEL7/CENTOS7