How to set up smartphones and PCs. Informational portal
  • home
  • Iron
  • Package management basics: apt, yum, dnf, pkg. Using Yum with a proxy server

Package management basics: apt, yum, dnf, pkg. Using Yum with a proxy server

Yum and RPM are both great package management tools, but they have a few obscure options and features that allow you to do some pretty cool things. You don't have to use them, but they may come in handy someday.

1. Displaying the type of architecture in the resulting RPM

This simple little thing is quite easy to accomplish and will be very useful for people using x86_64 systems. One line in ~ / .rpmmacros will save you trouble later.

Echo "% _query_all_fmt %% (name) - %% (version) - %% (release). %% (arch)" >> ~ / .rpmmacros

2. Requesting packages not from CentOS

Want to get a list of packages installed from third party repositories other than CentOS?

Rpm -qa --qf "% (NAME)% (VENDOR) \ n" | grep -v CentOS

3. Reset file permissions

Are you having a complete mess with the permissions on files in a package? Never mind, RPM will take care of that.

Rpm --setperms

4. View changes

Since CentOS and the original code vendor release security updates, version numbers can be confusing when you look at CVE fixes. Checking for changes in the package is good way see if corrections have been made or not. Once again, RPM comes to the rescue.

Rpm -q --changelog | less

Using "less" is optional, but for some packages, such as the kernel, the changes can be quite extensive. Therefore, this addition makes the conclusion more readable.

5. Where is the documentation?

To quickly get the documentation associated with a package, you can use the following two options:

  • This will show you the documentation contained in that rpm. If you only have the name of the file then:
rpm -qdf / path / to / file
  • and rpm will show you the documentation for the package that owns that file.

6. Origin of the package

Sometimes you want to know where you got a package or packages, how many packages are in your system from a particular repository or vendor. There are several search parameters that you can use. While they are not 100% perfect, they can still help. Most of the packages from the repositories have tags with an ID in the Release line. For example rpmforge uses rf as an identifier. You can use this to see what you have installed from there:

Rpm -qa release = "* rf *"

and if you want to see how many packages you have installed from Johnny Hughes you can use:

Rpm -qa packager = "Johnny *"

This method works for most categories like rpm -qi

This command will return the entire list installed packages.

7. Extract only one file

If you only need to extract one file from rpm without reinstalling the entire package, you can do so with rpm2cpio. For example, to extract only one file from the logrotate rpm, use the following:

Rpm2cpio logrotate-1.0-1.i386.rpm | cpio -ivd etc / logrotate.conf

8. Request for the installation date of the package

It is useful to find old packages after an upgrade that have not been upgraded.

Rpm -qa --last> ~ / RPMS_by_Install_Date

You can use "less" in the output to find all RPMSs older than the installation date. Using also grep - specify packages and installation date.

9. Request for available packages from the repository

Find all packages available from a specific repository, such as RPMforge. Packages already installed from this repository will not be shown.

Yum --disable "*" --enable "rpmforge" list available

10. Search with YUM in the package repository for a given string

Search for packages that contain the desired string in the package name or description.

Yum search buildrpmtree | less

11. Using Yum with a proxy server

In order to make Yum work through a proxy server, add the following parameter to /etc/yum.conf:

Proxy = http: // yourproxy: 8080 /

where - yourproxy is the proxy server name and 8080 is the proxy server port. If the server requires authentication, you can specify the login as:

Proxy = http: // username: [email protected]:8080/

RPM Package Manager allows you to use proxy environment variables. It can be set in / etc / profile or specific to specific user in the file ~ / .bash_profile ::

Export http_proxy = http: // yourproxy: 8080 / export ftp_proxy = http: // yourproxy: 8080 /

To use wget through a proxy add following lines in / etc / wgetrc

Http_proxy = http: // yourproxy: 8080 / ftp_proxy = http: // yourproxy: 8080 /

In both cases, the username and password can be specified as in the example above.

12. Using Yum to install a local package, automatically checking and satisfying dependencies

yum --nogpgcheck localinstall packagename.arch.rpm

13. Getting and rebuilding a package without being root

Sometimes you just need to rebuild a specific package - perhaps just add configuration options that simply don't exist in the main package. Or because you found the required package that is not in the repository, but on the RPMs developer site for another distribution. So you have to get src.rpm and rebuild it for yourself. But you really don't want to do this as a superuser. So how to rebuild your packages in your home directory under your own account.

13.1 Method A

First, you need to configure the directory for work. Its structure is quite similar to the / usr / src / redhat directory:

$ cd $ mkdir -p redhat / (SRPMS, RPMS, SPECS, BUILD, SOURCES) $ ls redhat / BUILD RPMS SOURCES SPECS SRPMS $

Using the rpm macro, we will make a substitution in order for rpmbuild to find out about us and what needs to be assembled:

$ echo "% _topdir / home / testuser / redhat" >> .rpmmacros $ echo "% packager Test User" >> .rpmmacros $ cat .rpmmacros% _topdir / home / testuser / redhat% packager Test User $

Exactly. The next step is to set rpmbuild --rebuild foo.src.rpm, and the result will be in ~ / redhat / RPMS / i386 (or whatever architecture you built the package with).

13.2 Method B

For CentOS-4, configure the kbs-Extras repo (optionally add kbs-Misk) from the page and "yum install fedora-rpmdevtools" as root using "sudo" or "su -". Create a user (you may want to use a special account to avoid problems in your normal home directory) and execute "fedora-buildrpmtree" and ~ / rpmbuild / ... in the directory tree and the ~ / .rpmmacros file will be automatically generated. (Note "rpmbuild" versus "RedHat" in method A.)

For CentOS-5, the rpmdevtools package is not available. In FC6 SRPM rpmdevtools-5.3-1.fc6.src.rpm builds and runs.

Below is a macro for getting the proper names of some packages (replace the appropriate distribution for "el4" with your own):

$ echo "% dist .el4" >> .rpmmacros

14. Displaying priorities for all installed repositories

You can get a list of all the repositories you have installed - yum repolist all... However, it does not show the priority index. Here is the line required for this. If no number is specified, it defaults to the lowest priority (99).

Cat /etc/yum.repos.d/*.repo | sed -n -e "/ ^ \ # yum list" vim * "Installed Packages vim-minimal.i386 2: 7.0.109-7.el5 installed Available Packages vim-X11.i386 2: 7.0.109-7.el5 base vim-augeas.i386 0.9.0-2.el5.rf rpmforge vim-clustershell.noarch 1.5.1-1.el5 epel vim-common.i386 2: 7.0.109-7.el5 base vim-enhanced.i386 2: 7.0.109-7.el5 base vim-halibut.i386 1.0-2.20100504svn8934.el5.1 epel vim-puppet.noarch 2.7.9-1.el5.rf rpmforge

16. Show all installed GPG keys

Show a list of all keys with the corresponding repository information:

Rpm -q gpg-pubkey --qf "% (name) -% (version) -% (release) ->% (summary) \ n"

17. Signing packages

Do you want to sign your package that you have put together so that others can verify its validity? You can do this quite simply. Check out the documentation.

Note: for CentOS 5 and 4, it will be better if you use the DSA key for signing (as there were problems with verification for RSA version 4).

18. YUM Metapackages

A metapackage is a special package that does not contain any software, but has a certain set of software in its dependencies. For instance: installing X on the server.

To see a list of all metapackages, you need to run the command: yum grouplist... But if you have a Russian locale, then the list will be issued in Russian. For a list of installable ones (in English), set the command output language to English:

LANG = C yum grouplist

19. How to list installed packages

Installed packages can show commands

Yum list installed

Example, to get a list of installed packages from the repository:

# yum list installed | grep ius php71u-cli.x86_64 7.1.17-1.ius.el6 @ius php71u-common.x86_64 7.1.17-1.ius.el6 @ius php71u-embedded.x86_64 7.1.17-1.ius.el6 @ius php71u-fpm.x86_64 7.1.17-1.ius.el6 @ius 7.1.17-1.ius.el6 @ius php71u-gd.x86_64 7.1.17-1.ius.el6 @ius php71u-intl.x86_64 7.1. 17-1.ius.el6 @ius php71u-json.x86_64 7.1.17-1.ius.el6 @ius php71u-mbstring.x86_64 7.1.17-1.ius.el6 @ius php71u-pdo.x86_64 7.1.17- 1.ius.el6 @ius 3.4.3-2.ius.el6 @ius php71u-pgsql.x86_64 7.1.17-1.ius.el6 @ius php71u-xml.x86_64 7.1.17-1.ius.el6 @ius php71u-xmlrpc.x86_64 7.1.17-1.ius.el6 @ius

Today I would like to briefly describe the commands of the package manager yum- the official FreePBX build is based on CentOS with yum installed by default. It is useful for installing, removing, updating packages.

Installing a package

For example, to install a package mc you need to enter the command yum install mc. After entering the command, the system will ask for confirmation. For the confirmation to be approved by default, you need to add a key -y, for example yum –y install mc:

# yum install mc Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.corbina.net * epel: mirror.datacenter.by * extras: mirror.corbina.net * updates: mirror.corbina.net Resolving Dependencies - > Running transaction check ---> Package mc.x86_64 1: 4.8.7-11.el7 will be installed -> Finished Dependency Resolution Dependencies Resolved ================== ================================================== ============= Package Arch Version Repository Size ================================ ============================================== Installing: mc x86_64 1: 4.8.7-11.el7 base 1.7 M Transaction Summary ================================= ============================================ Install 1 Package Total download size: 1.7 M Installed size: 5.6 M Is this ok: y Downloading packages: mc-4.8.7-11.el7.x86_64.rpm | 1.7 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing: 1: mc-4.8.7-11.el7.x86_64 1/1 Verifying: 1: mc-4.8.7-11.el7.x86_64 1 / 1 Installed: mc.x86_64 1: 4.8.7-11.el7 Complete!

Removing a package

To remove a package, respectively, you need to enter the command yum remove mc. Likewise, you can use the -y key to confirm:

# yum remove mc Loaded plugins: fastestmirror Resolving Dependencies -> Running transaction check ---> Package mc.x86_64 1: 4.8.7-11.el7 will be erased -> Finished Dependency Resolution Dependencies Resolved ====== ================================================== ======================== Package Arch Version Repository Size ===================== ================================================== ========= Removing: mc x86_64 1: 4.8.7-11.el7 @base 5.6 M Transaction Summary ====================== ================================================== ======== Remove 1 Package Installed size: 5.6 M Is this ok: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing: 1: mc-4.8.7-11.el7.x86_64 1/1 Verifying: 1: mc-4.8.7-11.el7.x86_64 1/1 Removed: mc.x86_64 1: 4.8.7-11.el7 Complete!

Package update

Suppose you have old version mysql and you need to update it - here the command is used update... The whole command will look like this: yum update mysql.

Search for a package

If you want to check whether a specific package is installed on the server and available for installation, use the command list... The whole command will look like this: yum list mysql. You can also specify the exact version of the package if you require a more detailed search.

Displaying information about a package

If you want to display information about a package, use the command info... The whole command will look like this: yum info mc.

Listing information about all available and installed packages

To do this, use the command list with modifiers. For withdrawal available packages: yum list | less, and to display all installed - yum list installed | less

Examination available updates for packages and the update itself

To check, use the command check-update, and to update - update... Below are three examples of command usage:

  • yum check-update mysql - check for updates of the mysql package;
  • yum list updates - displays the list of updates;
  • yum update mc - Midnight Commander update;
  • yum –y update - update all installed packages;
Group packages and operations with them

In Linux, some packages are collected in so-called group packages - for example, DNS Name Server, Editors, Java Development etc. With yum, you can install group packages using the command groupinstall- example below yum groupinstall 'Clustering. I will briefly describe the rest of the commands for manipulating group packets:

  • yum grouplist - displays all group packages available for installation;
  • yum groupupdate ‘Base’ - update of a specific group package, in in this case- Base;
  • yum groupremove ‘Editors’ - remove a group package;
Repositories in yum

The search for packages occurs in the so-called repositories, below I will give several commands for working with them - the principle is the same as with packages (list commands, for example). All active repositories are displayed using the yum repolist command, and inactive repositories are also displayed using the yum repolist all command

To install a package from a specific repository, no matter whether it is active or inactive, the key is used --enablerepo... As an example - phpmyadmin installation: yum –enablerepo = epel install phpmyadmin

Terminal in yum and history

If you are going to carry out a lot of operations with packages, then you can immediately go into the yum shell using the yum shell command and using the commands you already know (only without first three letters, respectively), you can install \ remove \ update \ whatever packages. Also an interesting feature is the ability to view the installation history in yum - using the yum history command.

Was this article helpful to you?

Please tell me why?

We are sorry that the article was not useful to you: (Please, if it does not make it difficult, indicate why? We will be very grateful for a detailed answer. Thank you for helping us become better!

The Purpose of Yum

Yum was created to solve the following tasks:

  • Searching for packages in the repositories
  • Installing packages from repositories
  • Installing packages from .rpm files, resolving dependencies using repositories
  • System update
  • Removing unnecessary packages
  • In fact, yum is a repository wrapper for rpm.

Basic package operations

Searching the repositories

There are three commands used to search repositories using yum: list, search, and provides.

The easiest way to find is using the list command. The list command looks at package names and versions for matches. For example, to view packages named tsclient, use:

Yum list tsclient

The search command searches the package name and description for the specified string. For example, to search for packages associated with the PalmPilot, enter:

Yum search PalmPilot

The provides command allows you to search for packages containing specified file... For example, to search for packages containing libneon, enter:

Yum provides libneon

Do all search commands support wildcards? and * (escape them with \ for correct bash handling). For example, to search for packages starting with tsc, type:

Yum list tsc \ *

to search for packages containing files in the / etc / httpd directory

Yum provides / etc / httpd \ *

or to search for specific commands / programs, for example to search for mc (midnight commander)

Yum provides \ * / mc

as a result, we get the following output

1: mc-4.7.4-1.fc14.i686: User-friendly text console file manager and visual shell Repository: base Matches from: Filename: / usr / share / mc Filename: / usr / libexec / mc Filename: / etc / mc Filename: / usr / bin / mc

Installing packages with Yum

The install parameter is used to install packages using yum

To install tsclient enter:

Yum install tsclient

Yum will automatically resolve (if it can) the dependencies and offer to install them:

================================================== =========================== Package Arch Version Repository Size ================== ================================================== ========= Installing: tsclient i386 0.132-6 base 247 k Installing for dependencies: rdesktop i386 1.4.0-2 base 107 k Transaction Summary =============== ================================================== ============ Install 2 Package (s) Update 0 Package (s) Remove 0 Package (s) Total download size: 355 k Is this ok:

Installing packages from .rpm files

The localinstall command was previously used to install the .rpm package with automatic dependency resolution. Now you can use regular install. So the command:

Yum install foo.rpm

will automatically find the dependencies of the foo.rpm package in the repositories (if it can) and offer to install them.
There may be a problem in the absence or unknown GPG signature of the RPM package, which will result in a refusal to install and, as a consequence, the following error

Public key for foo.rpm not set

In order to get around this (if you trust the source providing the package), you must turn off the check of GPG keys by adding the --nogpgcheck parameter at the end of the command

System update

Updating the system is carried out using one command - update. In this way:

Yum update

will update your entire system. And the team

Yum update foo

With both methods, performance is maintained.

Using Yum with a proxy server

In order to make Yum work through a proxy server, add the following parameter to /etc/yum.conf:

Proxy = http: // yourproxy: 8080 /

where - yourproxy is the proxy server name and 8080 is the proxy server port. If the server requires authentication, you can specify the login as:

Proxy = http: // username: [email protected]:8080/

RPM Package Manager allows you to use proxy environment variables. This can be set in / etc / profile or user-specific in ~ / .bash_profile ::

Export http_proxy = http: // yourproxy: 8080 /
export ftp_proxy = http: // yourproxy: 8080 /

To use wget through a proxy, add the following lines to / etc / wgetrc

Http_proxy = http: // yourproxy: 8080 /
ftp_proxy = http: // yourproxy: 8080 /

In both cases, the username and password can be specified as in the example above.

Using Yum to install a local package, automatically checking and satisfying dependencies

yum --nogpgcheck localinstall packagename.arch.rpm

Displaying priorities for all installed repositories

You can get a list of all the repositories you have installed - yum repolist all... However, it does not show the priority index. Here is the line required for this. If no number is specified, it defaults to the lowest priority (99).

Cat /etc/yum.repos.d/*.repo | sed -n -e "/ ^ \)

Top related articles