- 15+ examples for yum update command
- How does yum update work?
- Update without gpg checking
- Update from a local repo
- Show patches
- Update a single package
- Update all but one package
- Exclude multiple packages
- Check when last yum update ran
- Rollback (revert) update
- Clean up a failed yum update (Troubleshooting)
- Skip errors
- Get a list of packages that need an update
- Difference between yum check updates and list update
- Notify when updates are available
- What port does yum update use
- Yum update vs. upgrade
- RHEL/CentOS: yum Update All Packages Except the Linux Kernel
- yum syntax to update all except Kernel
- Examples
- How do I prevent yum from Updating the Kernel permanently?
15+ examples for yum update command
Yum is a package manager used on Red Hat, CentOS, and other Linux distributions that use RPM Package Manager. Yum is used to install, update, delete, or otherwise manipulate the packages installed on these Linux systems.
In this tutorial, we will cover the yum update command – what it is, how to use it, and all the different commands you may need to know when you wish to upgrade the installed packages on your system.
Table of Contents
How does yum update work?
You can use the yum update command to update applications installed on a system. If you run the command without any package names specified, it will update all packages on the system.
When running this command, yum will begin by checking its repositories for an updated version of the software your system currently has installed. The screenshot below shows the type of output you’ll typically see when first issuing the yum update command.
As you can see, the output from yum first lists the repositories it’s querying, which are the default ones for CentOS: AppStream, Base, and Extras. Below that, yum lists the various packages which it has found updates for.
At the tail end of this output, yum will display the “Transaction Summary,” which shows the total number of packages that are to be installed and upgraded.
In this example, 166 packages are being upgraded, and 6 new packages are being installed.
In case you’re wondering why new packages are being installed when we are only supposed to be upgrading applications, some new software packages may have become part of this Linux distribution, or some upgraded applications may rely on extra packages that are not yet installed.
Once you review the list of software that yum plans to upgrade, you can confirm these changes by typing “y” and hitting enter.
Yum will then perform the upgrades, which may take some time depending on the speed of your connection and the system itself.
Once it has finished, you’ll get a final summary, which will list all the packages that were successfully upgraded, as well as any errors that may have been encountered.
Update without gpg checking
You can use the GPG keys to verify the authenticity of an RPM package. The –nogpgcheck option in yum will instruct it to skip checking GPG signatures on packages. This is useful in cases where you have an unsigned package, or you just don’t have the GPG key.
This is a quick solution if you encounter an error like “Package NameOfPackage.rpm is not signed .. install failed!” when running the normal yum update command. The –nogpgcheck option will ignore this warning and proceed with upgrading the package anyway.
Update from a local repo
It’s possible to set up local repositories for yum to query when it does an update. This is often done if you want to use yum to update packages that aren’t included in the default repos, or if you need to upgrade an offline system.
First, place all your updated RPM files in a new folder. In this example, we’ll use /root/rpms.
Next, navigate to the following directory where you can see all the repo files for yum:
To set up a local repo, create a new file in this directory.
Inside your repo file, configure it in this format, changing the lines as necessary:
The big difference between a local repo and a remote repo is in the “baseurl” line, where the file:// protocol is specifying a local file, as opposed to the remote protocols http:// or ftp://
After saving the file, set the correct permissions:
The repository should now be ready to use. Be sure clear yum’s cache before attempting a yum update command:
Show patches
Yum can display available security patches, without installing them, with this command:
If it doesn’t return any output, like in the screenshot above, this means there are no security patches available for any software on your system.
Update a single package
If you need to update a certain package without running an update for every application installed, just specify the name of the package in your yum update command.
Multiple packages can be specified, separated by a space. You need to have the name of the package typed perfectly in order for yum to find it in its repositories; if you’re not sure of a package name, first check what packages are currently eligible for updates:
Update all but one package
If you need to run the yum update command to update all packages but you wish to exclude a package, you can specify the –exclude option.
A common situation where administrators may find this necessary is with kernel updates since these are major updates that could cause unpredictable errors on a production server. However, they may still want to run the command to update less sensitive applications.
To exclude a package (in this example, those related to the kernel):
The asterisk acts as a wildcard, in case there are multiple related packages, or you don’t know the full name of the package.
Exclude multiple packages
You can exclude multiple packages with more –exclude flags.
Use this flag as in the example above, or the -x flag, as many times as needed.
Check when last yum update ran
To see a list of yum transactions, with the date and time they were running, use the yum history command.
In the screenshot above, you can see that the last time yum updated software was on January 4 th .
Rollback (revert) update
A great feature of yum is that it allows you to undo a recent update, thus restoring the upgraded packages to their previous versions.
Each yum action (install, update, erase, etc.) is assigned a transaction ID, and this ID must be specified when undoing a yum update. To see a list of transaction IDs for recent yum operations, use this command:
In the screenshot above, you can see the last operation run with yum was to install the httpd package. Undoing an installation or an update works the same way, so in this example, we will undo this recent installation of httpd. As shown in the screenshot, this transaction has an ID of 7.
To undo this change and roll back the program to its previous version, issue this command:
As usual, yum will summarize the changes to be made and ask if you’d like to proceed with a Y/N prompt. Enter Y, and the specified transaction will be undone.
Clean up a failed yum update (Troubleshooting)
If one or more packages fail to upgrade successfully when you run the yum update command, the system can end up with duplicate packages installed (2 versions of the same program).
Sometimes, following the rollback instructions in the section above can fix the problem. If that doesn’t work, you can remove duplicate packages on your system with this command:
Yum stores a cache of information for packages, metadata, and headers. If you encounter an error, clearing yum’s cache is a good first step in troubleshooting. Use the following command to do that:
Skip errors
When updating or installing a package, that package may require additional software in order to run correctly. Yum is aware of these dependencies and will try to resolve them during updates by installing or upgrading the extra packages that are needed.
If yum has trouble installing the necessary dependencies, it produces an error and doesn’t proceed further. This is a problem if you have other packages that need to be updated.
To instruct yum to proceed with updating other packages and skipping the ones with broken dependencies, you can specify the –skip-broken command in your yum update command.
Get a list of packages that need an update
Running the yum update command as normal, with no additional options, will output a list of available updates.
If you’d like to see some additional information about the package updates available, type this command:
To see information about security updates that are available for the system, type this command:
Difference between yum check updates and list update
Although the two commands sound similar, so there is a difference between checking for updates and listing updates in yum.
The command to list updates, shown above, will list all the packages in the repositories that have an update available. Keep in mind that some of the packages in the repositories may not even be installed on your system.
The command to check for updates, seen above, is a way to check for updates without prompting for interaction from the user. This is the command you would opt for if you were coding a script to check for updates, for example.
The check-update command will return an exit value of 100 if there are packages that have updates available, and it will return an exit value of 0 if there are no available updates.
A value of 1 is returned if an error is encountered. Use these exit codes to code your script accordingly.
Notify when updates are available
There are a few packages that can help manage yum updates on your system. Some can even notify administrators when yum has updates that are available to be installed. One such service is called yum-cron.
Install yum-cron using yum:
Set the yum-cron service to start at boot:
Configure the settings for yum-cron inside the configuration file using vi or your preferred text editor:
In this file, you can specify if the updates should be automatically applied or not. If you’d only like to receive notifications, fill out the email information inside the configuration file. Yum-cron will then send you an email anytime there are updates available for your system.
What port does yum update use
Yum uses port 80 when checking for updates. If you look inside the repository files on your system, you’ll see that all of the links inside begin with http.
If you need to create a rule in your firewall to allow yum to function, you need to allow port 80.
Yum update vs. upgrade
So far, we have only talked about the yum update command in this tutorial, but there’s another very similar command: yum upgrade.
There is a small difference between these two commands. Yum update will update the packages on your system, but skip removing obsolete packages.
Yum upgrade will also update all the packages on your system, but it will also remove the obsolete packages.
This inherently makes yum update the safer option, since you don’t have to worry about accidentally removing a necessary package when updating your software.
Use some discretion when issuing the yum upgrade command, since it may not preserve some packages that you are still using.
At last, I hope you find the tutorial useful.
Источник
RHEL/CentOS: yum Update All Packages Except the Linux Kernel
I am a new CentOS Linux user running my community site on production server. I want to update all packages except the Linux kernel on CentOS Linux. How can I prevent the yum command from updating the Linux kernel on CentOS/RHEL/Scientific/Fedora Linux server?
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | yum |
Est. reading time | 5m |
You can easily run yum update command to updates everything but the kernel using the exclude directive. This option define list of packages to exclude from updates or installs. This should be a space separated list. Shell globs using wildcards * and ?) are allowed.
yum syntax to update all except Kernel
yum —exclude=packgeName\* update
yum —exclude=packgeName1\* —exclude=packgeName2\* update
yum -x ‘packageName*’ update
yum -x ‘packageName1*’ -x ‘packageName2*’ update
Examples
To prevent yum command from updating the Kernel type:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
How do I prevent yum from Updating the Kernel permanently?
Edit /etc/yum.conf file, enter:
# vi /etc/yum.conf
Append/modify exclude directive line under [main] section, enter:
Save and close the file. Now, you can just run the following without passing the -x or –exclude option to yum command:
# yum -y update
See also
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
It suggest leaving out the ‘-y’ option in the example or at least explain its use lest someone expecting to be prompted ends up surprised.
Thanks it is useful article, I agree with Chris if we do without -y then we can verify the packages.
i need a help. I want to upgrade the packages & kernel in the servers that are running
Eg: if there are around 200 packages now who to upgrade them at once. kindly reply me
I tried this on a vm, unfortunately the kernel was still updated anyway.
Источник