Rocky Linux system updates are handled through the `dnf` package manager, which replaces the older `yum` command. If you are wondering how to update Rocky Linux, the process is straightforward and secure. Keeping your system current ensures you have the latest security patches, bug fixes, and performance improvements.
This guide walks you through every step, from checking your current version to performing major version upgrades. You will learn both command-line and graphical methods, along with best practices to avoid common pitfalls.
Understanding Rocky Linux Updates
Rocky Linux is a community-driven enterprise Linux distribution, designed to be binary-compatible with Red Hat Enterprise Linux (RHEL). Updates come from official repositories maintained by the Rocky Linux project. These updates include security errata, software enhancements, and kernel patches.
The update process uses `dnf`, which stands for Dandified YUM. It handles dependency resolution, package downloads, and installation automatically. You can run updates manually or schedule them with cron or systemd timers.
Why Regular Updates Matter
Regular updates protect your system from vulnerabilities. Cyber threats evolve quickly, and outdated software is a primary attack vector. Updates also fix software bugs that can cause crashes or data loss. Additionally, new features and hardware support are often included in updates.
Skipping updates for long periods can make major version upgrades more difficult. It is best to update at least once a month, or more frequently for production servers.
How To Update Rocky Linux
Now let’s get into the exact steps for updating your Rocky Linux system. This section covers both the command-line method and the graphical interface option.
Step 1: Check Your Current Version
Before updating, know what version you are running. Open a terminal and run:
cat /etc/rocky-release
This shows the release version, like “Rocky Linux release 9.3 (Blue Onyx)”. You can also use:
hostnamectl
This gives you the operating system and kernel details. Knowing your version helps you understand which updates are applicable.
Step 2: Update The Package Cache
The `dnf` command uses a local cache of repository metadata. Refresh it to ensure you have the latest package lists:
sudo dnf check-update
This command downloads the latest metadata and shows available updates without installing them. It is a safe way to preview what will be updated.
Step 3: Perform A Full System Update
To update all packages to their latest versions, run:
sudo dnf update
This command upgrades all installed packages. It will prompt you to confirm the list of packages to be updated. Review the list, then type ‘y’ and press Enter.
Alternatively, you can use:
sudo dnf upgrade
In most cases, `update` and `upgrade` do the same thing. However, `upgrade` also considers obsoletes and may replace packages with newer versions from different repositories.
Step 4: Handle Kernel Updates
When the kernel is updated, you need to reboot to load the new kernel. After the update completes, run:
sudo reboot
If you cannot reboot immediately, the old kernel continues to run. The new kernel will be used after the next reboot. You can check the installed kernels with:
rpm -q kernel
Rocky Linux keeps the last three kernels by default, allowing you to boot into an older one if needed.
Step 5: Verify The Update
After rebooting, verify that the update was applied correctly:
uname -r
This shows the current kernel version. Compare it with the version from the update list. Also check the release file again:
cat /etc/rocky-release
If the version number changed, the update was successful.
Updating Rocky Linux Using The GUI
If you prefer a graphical interface, Rocky Linux includes the GNOME Software Center. This method is ideal for desktop users or those less comfortable with the command line.
Open Software Center
Click on “Activities” in the top-left corner, then search for “Software”. Open the Software application. It may take a moment to load the repository data.
Check For Updates
In the Software Center, go to the “Updates” tab. It will show a list of available updates. You can review each package and its changelog.
Install Updates
Click the “Update All” button to install all updates. You may be prompted for your password. The system will download and install the updates automatically. After completion, you may need to reboot if the kernel was updated.
The GUI method is simpler but gives you less control over individual packages. For servers, the command line is recommended.
Automating Rocky Linux Updates
Manual updates are fine for small systems, but for multiple servers, automation saves time. You can use `dnf-automatic` or systemd timers to schedule updates.
Using Dnf-automatic
Install the package:
sudo dnf install dnf-automatic
Edit the configuration file:
sudo nano /etc/dnf/automatic.conf
Set `apply_updates = yes` to automatically install updates. You can also configure email notifications. Then enable and start the timer:
sudo systemctl enable --now dnf-automatic.timer
This runs updates daily. Check the timer status with:
sudo systemctl status dnf-automatic.timer
Using A Cron Job
Alternatively, add a cron job to run updates weekly. Edit the root crontab:
sudo crontab -e
Add a line like:
0 2 * * 0 /usr/bin/dnf update -y
This runs every Sunday at 2 AM. The `-y` flag automatically answers yes to prompts. Be cautious with automatic updates on production systems, as they can cause unexpected reboots or service interruptions.
Handling Major Version Upgrades
Upgrading from Rocky Linux 8 to 9, or 9 to 10 in the future, is a more involved process. It is not a simple `dnf update`. Here is a high-level overview.
Pre-Upgrade Steps
First, backup all important data. Create a full system backup or at least a snapshot of your virtual machine. Review the release notes for the target version to understand breaking changes.
Ensure your current system is fully updated:
sudo dnf update
Reboot if needed. Then install the upgrade utility:
sudo dnf install dnf-plugin-system-upgrade
Download The Upgrade
For Rocky Linux 8 to 9, run:
sudo dnf system-upgrade download --releasever=9
This downloads all necessary packages. It may take a long time depending on your internet speed. Resolve any dependency conflicts that appear.
Reboot Into The Upgrade
After the download completes, initiate the upgrade:
sudo dnf system-upgrade reboot
The system will reboot and perform the upgrade in a special environment. Do not interrupt this process. It can take 30 minutes to several hours.
Post-Upgrade Tasks
After the upgrade completes, the system will reboot into the new version. Verify the version:
cat /etc/rocky-release
Check for any leftover packages or configuration issues. You may need to update third-party repositories or applications manually.
Common Update Issues And Solutions
Even with careful planning, updates can sometimes fail. Here are common problems and how to fix them.
Dependency Conflicts
If `dnf` reports dependency errors, try:
sudo dnf distro-sync
This synchronizes installed packages with the repository versions. Alternatively, remove conflicting packages with:
sudo dnf remove
Then re-run the update.
Repository Errors
If repositories are not reachable, check your internet connection. Sometimes mirrors are down. You can switch to a different mirror by editing repository files in `/etc/yum.repos.d/`. Enable the `baseurl` and comment out `mirrorlist` if needed.
Clear the dnf cache:
sudo dnf clean all
Then try again.
Disk Space Issues
Updates require free disk space. Check available space with:
df -h
If space is low, remove old kernels:
sudo dnf remove --oldinstallonly
This keeps only the current and one previous kernel. Also clean package cache:
sudo dnf clean packages
Best Practices For Rocky Linux Updates
Follow these guidelines to keep your system stable and secure.
- Always backup critical data before major updates.
- Test updates on a non-production system first.
- Read changelogs for security updates to understand risks.
- Reboot after kernel updates to apply changes.
- Monitor system logs after updates for errors.
- Use a staging environment for mission-critical servers.
- Keep third-party repositories up to date separately.
By following these practices, you minimize downtime and avoid unexpected issues.
Frequently Asked Questions
How Often Should I Update Rocky Linux?
For security, update at least monthly. Production servers may benefit from weekly updates. Always apply critical security patches immediately.
Can I Update Rocky Linux Without Internet?
Yes, you can use a local repository mirror or download packages manually. Set up a local `dnf` repository on your network for offline updates.
What Is The Difference Between Dnf Update And Dnf Upgrade?
In practice, both commands update packages. `dnf upgrade` also handles obsoletes and may replace packages with newer versions from different repositories. For most users, `dnf update` is sufficient.
Will Updating Rocky Linux Break My Applications?
Rarely, but it can happen if an application depends on specific package versions. Always test updates in a staging environment. Use version pinning for critical packages if needed.
How Do I Roll Back An Update In Rocky Linux?
Use `dnf history` to see past transactions. Then use `dnf history undo
Conclusion
Knowing how to update Rocky Linux is essential for system security and stability. The `dnf` package manager makes the process simple, whether you use the command line or the GUI. Regular updates protect your system from vulnerabilities and keep software running smoothly.
For production environments, automate updates with `dnf-automatic` or cron, but always test first. Major version upgrades require careful planning and backups. By following the steps in this guide, you can maintain a healthy Rocky Linux system with minimal effort.
Remember to reboot after kernel updates and verify the update was applied. With these practices, your Rocky Linux system will remain secure and performant for years to come.