Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic operation of linux yum

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the basic operation of linux yum". In the daily operation, I believe that many people have doubts about the basic operation of linux yum. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about the basic operation of linux yum! Next, please follow the editor to study!

Basic operation of yum

The basic operations of yum include software installation (local, network), upgrade (local, network), uninstall, and some query functions.

Once the local yum is set, it is easy to install (now suppose we use the yum that comes with fc5). If we need to install the virtual machine bochs, we can use the

# yum install bochs

If you have a relevant rpm file locally, you can use the

# yum localinstall ur.rpm

The former causes yum to search for data in existing repository (usually connect to these repository to download updated data first), and if this software is found, it will analyze its dependencies and then download and install the required software.

If you need to uninstall, you can use the

# yum remove bochs

Or

# yum erase bochs

This will also deconstruct the corresponding dependencies, for example, deleting firefox will delete R at the same time, because R depends on firefox

Update a certain software can be used

# yum update firefox

If you do not take the following program name, all software that can be upgraded will be upgraded. Outdated software that needs to be processed (such as deleted) can add the-- obsolete parameter, or use upgrade. If you need more automated operations (to avoid answering some questions), you can also add some parameters, such as

# yum-y upgrade

If you finish a system-level upgrade, you will download a lot of rpm and other things, which will take up more hard drives and can be used

# yum clean packages

Delete related rpm files, others are headers, packages, cache, metadata, all

See what rpm provides that a program can use

$yum provides / bin/rpm

And use

$yum list rpm

Rpm-related information is listed, while

$yum list info

Give a detailed description, you can use the

$yum search rpm

Get all the rpm-related programs that can be found, and the search object is the description part of each program.

For more detailed description of the parameters, please refer to the relevant man pages. A program called yumdownloader can be found in yum-utils. It can be easily downloaded, such as srpm packages.

$yumdownloader-source firefox

How do I upgrade my fc using yum?

The core part of the upgrade is very simple. First of all, you need to enable yum to manage its own version with the new repository,fc and use a rpm. You can update this package with the following command

# rpm-Uvh http://download.fedora.redhat.com/pub/fedora/linux/core/5/i386/os/Fedora/RPMS/fedora-release-5-5.noarch.rpm

After that, use yum to update fc4 related programs to fc5.

# yum-y upgrade

Note that since some self-installed programs are not replaced by relevant repository programs, it is likely to interfere with this process, such as qterm, which is not found in the original repository, so the lazy way is to find the relevant repository first and add it to the yum configuration file. The clumsy way is to uninstall these things first. After a long wait (the one I downloaded 1.5GB +), I can watch the software update one by one, then restart, and the success with the new kernel boot is almost done.

There may be some applications that can't handle the old version of the configuration file, so you just need to configure it manually. That's how my fc5 grew out of fc4.

FC itself has a FAQ about upgrading, which you can refer to.

How to configure yum to add a new repository?

This is mainly concerned with the configuration file of yum. Its main configuration file is in / etc/yum.conf, and its description can be found here.

Among them, the important one is the information related to repository. In fc5, the information of repository is stored separately, usually in / tec/yum.repos.d/, and generally a repository is written into a file, such as fedora-core.repo.

Repository that generally provides yum upgrades on the Internet will provide similar instructions, such as DAG, which provides rpm for installation. After installation, yum is configured, and you can directly use the above commands to perform system maintenance. For example, dries, you can create a dries.repo file that contains

[dries]

Name=Extra Fedora rpms dries-$releasever-$basearch

Baseurl= http://ftp.belnet.be/packages/dries.ulyssis.org/redhat/el3/en/i386/dries

Some other tools

There are also some useful tools in yum-utils, such as package-cleanup for cleaning up locally installed rpm, and tools for maintaining repository, such as repo-graph,repo-rss,repoclosure,repomanage,repoquery,reposync,repotrack and yum-builddep.

Here's a more detailed use of yum:

Yum detailed explanation

Linuxer that uses redhat,fedora must have a headache for rpm's famous dependency hell (this is also a problem with all rpm-based distributions). Foo is needed by bar,bar is needed by foo . To load and unload a piece of software, you have to work hard to sort out all the dependency problems. Several rpm search sites have become frequent places, and if you unfortunately encounter circular dependencies, you will have to stare. Sometimes add a-- nodeps parameter, it is out of sight, out of mind, but this installed software, you can guarantee normal use, so uninstall the software, you can guarantee that it will not affect the work of other software, I am afraid no one can give an affirmative answer. At this point, the hats can only look at debian's apt and secretly envy. Fortunately, these are a thing of the past. Rpm-based distributions now have package management tools like apt that automatically resolve dependencies. One of the most famous is apt4rpm, which is basically a migration of the debian system apt to the rpm distribution. But did you know that using linuxer with Redhat and Fedora, there is also a rpm package management system similar to apt, which is yum. The Fedora system already comes with it, and Redhat also has a corresponding rpm download. Compared with apt, yum is not weak at all, and even has many advantages over apt. For example, yum is built into the Fedora system, so it can use fedora's official software source to complete various official upgrades. Yum is not bad for support for third-party software sources, and most repository that supports apt can also support yum, such as freshrpms,fedora.us,livna, and so on. In addition, yum has a more detailed log to see when to upgrade, what packages are installed, and so on. The code of yum is more concise than that of apt.

1. Brief introduction to YUM:

Yum, short for Yellow dog Updater, Modified, was originally developed by Terra Soft, the developer of yellow dog, and written in python. It was also called yup (yellow dog updater) at that time, and was later improved by the Linux@Duke launch team of Duke University. The purpose of yum is to automatically upgrade, install / remove rpm packages, collect information about rpm packages, check dependencies, and automatically prompt users for resolution. The key point of yum is to have a reliable repository, as the name implies, this is a software repository, it can be a http or ftp site, it can also be a local software pool, but it must include the header,header of rpm, including all kinds of information about rpm packages, including descriptions, functions, provided files, dependencies, etc. It is the collection and analysis of these header that automates the remaining tasks.

If it is not installed, first we need to download the version of yum corresponding to our system at the following address:

Http://ayo.freshrpms.net/

For example, if I use Fedora core 4. 0, download the following package installation:

[root@localhost beinan] # rpm-ivh freshrpms-release-1.1-1.fc.noarch.rpm

Warning: freshrpms-release-1.1-1.fc.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e42d547b

Preparing... # [100%]

1:freshrpms-release # # [100%]

II. Configuration file of YUM

All configuration information for yum is stored in a configuration file called yum.conf, which is usually located in the / etc directory, which is the top priority of the entire yum system, so it is necessary to describe it in detail. The following is a yum.con file found on the Internet, let's take this as an example to illustrate.

[main]

Cachedir=/var/cache/yum

Debuglevel=2

Logfile=/var/log/yum.log

Pkgpolicy=newest

Distroverpkg=redhat-release

Tolerant=1

Exactarch=1

Retries=1

[base]

Name=Fedora Core $releasever-$basearch-Base

Baseurl= http://download.atrpms.net/mirrors/fedoracore/$releasever/$basearch/os

Http://rpmfind.net/linux/fedora/cor...er/$basearch/os

Http://mirror.clarkson.edu/pub/dist...er/$basearch/os

[updates-released]

Name=Fedora Core $releasever-$basearch-Released Updates

Baseurl= http://download.atrpms.net/mirrors/fedoracore/updates/$releasever/$basearch

Http://redhat.linux.ee/pub/fedora/l...sever/$basearch

Http://fr2.rpmfind.net/linux/fedora...sever/$basearch

[Fedora.us]

Name=Fedora.us-$basearch-Extras

Baseurl= http://fedora.linux.duke.edu/fedorax86_64/fedora.us/$releasever/$basearch/RPMS.stable

[Dag Wieers]

Name=Dag RPM Repository for Fedora Core

Baseurl= http://apt.sw.be/fedora/$releasever/en/$basearch/dag

[Livna]

Name=Livna RPM, Fedora Core $releasever-$basearch

Baseurl= http://rpm.livna.org/fedora/$releasever/$basearch/RPMS.stable

[freshrpms]

Name=FreshRPMs

Baseurl= http://ayo.freshrpms.net/fedora/linux/$releasever/$basearch/freshrpms/

Http://ftp.us2.freshrpms.net/linux/...arch/freshrpms/

The first part (this is the global setting of yum. The default generally does not need to be changed. )

[main]

The directory of the cachedir:yum cache, where yum stores downloaded rpm packages and databases, usually / var/cache/yum.

Debuglevel: debug level, 0 ── 10, default is 2

The log file for logfile:yum. The default is / var/log/yum.log.

Pkgpolicy: the policy of the package. There are two options, newest and last, this function is that if you set up multiple repository and the same software is stored in different repository at the same time, which yum should install, and if it is newest, yum will install the latest version. In the case of last, yum alphabetically sorts the server id and selects the software installation on the last server. Newest is usually chosen.

Distroverpkg: specify a package based on which yum will determine your distribution. The default is redhat-release, or it can be any rpm package installed for your own distribution.

Exactarch, there are two options 1 and 0, indicating whether to upgrade only packages that are consistent with your installation package cpu. If set to 1, then if you install an i386 rpm, yum will not upgrade with 1686 packages.

Retries, the number of retries after a network connection error. If set to 0, it will be retried indefinitely.

Tolerent, which also has options 1 and 0, indicates whether yum tolerates errors related to software packages on the command line. For example, if you want to install three packages, 3 of which have already been installed, if you set it to 1, yum will not have an error message. The default is 0.

In addition to the above, there are some options that can be added, such as

Exclude=, excludes some software from the upgrade list, you can use wildcards, and the items in the list should be separated by spaces, which is especially useful for friends who have installed patches such as beautification packages and Chinese.

Gpgchkeck= has two choices of 1 and 0, which represent whether or not to perform a gpg check. if not, it seems to be checked by default.

The second part:

Configure the repository server, this is the most exciting, with a good repository, like a big store at home, want something to run errands a little bit, by the way, this is a free mall.

All server settings should follow the following format:

[serverid]

Name=Some name for this server

Baseurl=url://path/to/repository/

Where serverid is used to distinguish between different repository, must have a unique name.

Name, which is a description of repository, supports variables like $releasever $basearch

Baseurl is the most important part of the server setup, and the software can only be obtained from it if it is set correctly. Its format is:

Baseurl=url://server1/path/to/repository/

Url://server2/path/to/repository/

Url://server3/path/to/repository/

Among them, there are three protocols supported by url: http:// ftp:// file://. After baseurl, you can follow multiple url, and you can change it to a faster mirror station, but baseurl can only have one, that is, it cannot be in the following format:

Baseurl=url://server1/path/to/repository/

Baseurl=url://server2/path/to/repository/

Baseurl=url://server3/path/to/repository/

The directory that url points to must be one level above the repository header directory, and it also supports variables such as $releasever $basearch.

After url, you can add several options, such as gpgcheck, exclude, failovermethod, etc., such as:

[updates-released]

Name=Fedora Core $releasever-$basearch-Released Updates

Baseurl= http://download.atrpms.net/mirrors/fedoracore/updates/$releasever/$basearch

Http://redhat.linux.ee/pub/fedora/linux/core/updates/$releasever/$basearch

Http://fr2.rpmfind.net/linux/fedora/core/updates/$releasever/$basearch

Gpgcheck=1

Exclude=gaim

Failovermethod=priority

Where the meaning of gpgcheck,exclude is the same as the [main] part, but only works for this server

Failovermethode has two options: roundrobin and priority, which means that when there are multiple url to choose, the order of yum selection, roundrobin is randomly selected, if the connection fails, use the next one, cycle in turn, and priority starts from the first according to the order of url. If not specified, the default is roundrobin.

Several variables

Releasever, the version of the distribution, is obtained from the distroverpkg in the [main] section. If not, the judgment is based on the redhat-release package.

$arch,cpu system, such as i686 Magi athlon, etc.

The basic system group of $basearch,cpu, such as i686 and athlon belong to i386 and alphaev6 belong to alpha.

After setting up yum.conf, we can enjoy the convenience of yum.

By the way, everything is ready, except Dongfeng. There's one more thing left undone. That is to import the GPG key of each reposity. As mentioned earlier, yum can use gpg to verify the package to ensure the integrity of the download package, so we first have to go to each repository site to find gpg key, which is usually placed in a prominent place on the home page. Download some plain text files with names such as RPM-GPG-KEY.txt, download them, and then import them with the command rpm-- import xxx.txt. It is best to import the distribution with its own GPG-KEY. Rpm-import / usr/share/doc/redhat-release-*/RPM-GPG-KEY official software upgrade.

FC3: rpm-- import / usr/share/doc/fedora-release-3/RPM-GPG-KEY-fedora

FC4: rpm-- import / usr/share/doc/fedora-release-4/RPM-GPG-KEY-fedora

So far, all the preparatory work has been completed.

Upgrade the software with YUM

Open the terminal and switch to the root user. Most of the yum operations must have the authority of the super user.

First of all, yum update, this step is necessary. Yum will download rpm's header from the server's header directory and put it in the local cache, which may take some time, but what is the cost of this time compared to the convenience brought to us by yum? Header download is complete, yum will determine whether there is an updatable software package, if so, it will ask your opinion, whether to update, or y, it is always good to up to date the system all the time, then yum starts to download the software package and use to call rpm installation, which may take a certain time, depending on the number of software to be updated and the network condition, in case the network is down, it doesn't matter, just do it again. After the upgrade, just use yum check-update every day to check whether it is up-to-date, and if so, use yum update to keep the system up-to-date and plug all loopholes found.

Upgrade a separate package with yum update packagename.

Yum also has an upgrade instruction, yum upgrade, which was originally intended to replace obsolete packages, but now it is usually used for major upgrades, such as upgrading the entire distribution by one version, and it is better to install a new system because of the implications.

1. Make a list of all updatable software

Command: yum check-update

two。 Install all updated softwar

Command: yum update

3. Install only the specified software

Command: yum install

4. Update only the specified software

Command: yum update

5. Make a list of all installable software

Command: yum list

Install and delete software with YUM

It is common to install system add and remove software, and yum is also competent for this task, as long as the software is installed by rpm.

The installation command is that yum install xxx,yum will query the database to see if there is a software package, if so, check its dependency conflict relationship, if there is no dependency conflict, then it is best to download and install; if so, it will give a prompt to ask whether you want to install the dependency at the same time, or delete the conflicting package, and you can make your own judgment.

The delete command is yum remove xxx, and just like the installation, yum queries the database and gives tips for resolving dependencies.

1. Install the software package with YUM

Command: yum install

two。 Delete a software package with YUM

Command: yum remove

Use YUM to query software information

We often encounter such a situation, want to install a software, only know that it is related to some aspect, but do not know its name. At this point, the query function of yum works. You can use commands such as yum search keyword to search, for example, we want to install an Instant Messenger, but do not know which, then you might as well use the command yum search messenger to search, yum will search the description of all available rpm, list all the description of rpm packages related to messeger, so we may get gaim,kopete and so on, and choose from.

Sometimes we come across the installation of a package, but do not know its purpose, we can use the yum info packagename instruction to get information.

1. Use YUM to find software packages

Command: yum search

two。 List all installable software packages

Command: yum list

3. List all updatable software packages

Command: yum list updates

4. List all installed packages

Command: yum list installed

5. List all packages that are installed but not within Yum Repository

Command: yum list extras

6. List the specified software packages

Command: yum list

7. Use YUM to get package information

Command: yum info

8. List information for all software packages

Command: yum info

9. List all updatable package information

Command: yum info updates

10. List all installed package information

Command: yum info installed

11. List all software packages installed but not within Yum Repository

Command: yum info extras

twelve。 List the files provided by the software package

Command: yum provides

6. Clear the YUM cache

Yum stores downloaded packages and header in cache instead of automatically deleting them. If we think they take up disk space, we can use the yum clean instruction to clear them. More accurately, we can use yum clean headers to clear header,yum clean packages, clear downloaded rpm packages, and yum clean all.

1. Clear the software packages under the cache directory (/ var/cache/yum)

Command: yum clean packages

two。 Clear the headers under the cache directory (/ var/cache/yum)

Command: yum clean headers

3. Clear the old headers under the cache directory (/ var/cache/yum)

Command: yum clean oldheaders

4. Clear the software packages under the cache directory (/ var/cache/yum) and the old headers

Command: yum clean, yum clean all (= yum clean packages; yum clean oldheaders)

Attached:

Because of Fedora's yum

The default update host is in a foreign country, that is, the official update host of Fedora

It is conceivable that the speed of downloading from abroad is so slow.

Here, we can modify the configuration file of yum

Change the connected mainframe to the Linux update mainframe of domestic universities, so that the speed will be faster.

-

/ etc/yum.conf

[base]

Name=Fedora Core $releasever-$basearch-Base baseurl= http://download.fedora.redhat.com/pub/fedora/linux/core/$releasever/$basearch/os/

[updates-released]

Name=Fedora Core $releasever-$basearch-Released Updates baseurl= http://download.fedora.redhat.com/pub/fedora/linux/core/updates/$releasever/$basearch/

Notice the red spot, which is the updated host URL that yum will connect to.

Change it to the following, you can choose the collocation freely.

Base host:

(there is a difference in case. Please test the connection first to see if the server still exists.)

Http://ftp.isu.edu.tw/pub/Linux/Fed...core/1/i386/os/

Http://linux.nctu.edu.tw/ftp/dists/...core/1/i386/os/

Ftp://ftp.isu.edu.tw/pub/Linux/Fedo...core/1/i386/os/

Ftp://linux.nctu.edu.tw/dists/fedora/core/1/i386/os/

Ftp://linux.sinica.edu.tw/fedora/linux/core/1/i386/os/

Updates host:

(there is a difference in case. Please actually test the connection to see if the server still exists.)

Http://ftp.isu.edu.tw/pub/Linux/Fed...updates/1/i386/

Http://linux.nctu.edu.tw/ftp/dists/...updates/1/i386/

Ftp://ftp.isu.edu.tw/pub/Linux/Fedo...updates/1/i386/

Ftp://linux.nctu.edu.tw/dists/fedor...updates/1/i386/

Ftp://linux.sinica.edu.tw/fedora/li...updates/1/i386/

/ 1 / in the path represents core 1

If you are using core 2, please change it to / 2 /

Save after modification. There is no need to restart the service. It will take effect immediately.

Then the update speed of yum will be very fast.

Yum base configuration settings for Fedora core 3 and 4:

Yum base configuration settings for FC3 and FC4, which are different from previous FC2

It is not set in / etc/yum.conf

The setting method is as follows:

Cd / etc/yum.repos.d/

Vi fedora.repo (set the base host and list only the areas that need to be modified)

Baseurl= http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/$releasever/$basearch/os/

# mirrorlist= http://fedora.redhat.com/download/mirrors/fedora-core-$releasever

Vi fedora-updates.repo (set the update host and list only the areas that need to be modified)

Baseurl= http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/updates/$releasever/$basearch/

# mirrorlist= http://fedora.redhat.com/download/mirrors/updates-released-fc$releasever

At this point, the study on the "basic operation of linux yum" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report