To update installed packages for security on CentOS 8/9, you can use the yum command as the root user or with sudo.
- Update the package index by running the command
sudo yum update
. This command will update all installed packages to the latest version. - You can also update specific packages by providing the package name after the update command. For example,
sudo yum update httpd
will update the Apache httpd package. - Another option is to update only security-related packages by running the command
sudo yum update --security
. - To check for updates on a regular basis, you can use the command
sudo yum check-update
or install yum-cron package and configure it to automatically update your system withsudo yum install yum-cron; sudo systemctl enable --now yum-cron
.
Note: Before updating packages, it is recommended to take a backup of your system and important files, and test updates in a development environment.