CentOS Update

29/12/2020
Keeping your packages up to date is important to prevent running into known and already fixed bugs as well as patching any security vulnerabilities that might have been found by the distribution and package maintainers. Its not hard to do so lets get right to it.

The first command you want to know is yum check-update. If you are not familiar with yum, read our primer on yum first and then come back here. The check-update command will print out a list of any packages for which an update is available. For scripting purposes it will also return an exit value of 100 if updates are required, 0 if no updates are required or 1 if an error occurred.

Here is an example of how to check for updates in CentOS:

yum check-update > /dev/null
RC=$?
if [ $RC -eq 100 ]; then
   echo "Updates are needed"
elif [ $RC -eq 0 ]; then
   echo "No updates are needed"
else
   echo "An error occurred in the package update check, try again"
fi

yum check update centos

And here is an example of printing out the updates as needed:

yum check-update > ./output
RC=$?
if [ $RC -eq 100 ]; then
    cat ./output
fi

We can also check updates for a single package with yum update and NOT specifying Y, for yes, when asked. If you do press Y, for yes, the update will proceed for the specified package. For example I will do a check on the package vim-minimal now:

yum update vim-minimal

If you want to proceed and update all packages, then go ahead and run yum update and do not provide any package names. It will find all out of date packages and update them all after you confirm Y for yes at the prompt.

# yum update

yum update

After the update is complete you can re-run the check script above and expect to see nothing to update.

yum check-update > /dev/null
RC=$?
if [ $RC -eq 100 ]; then
   echo "Updates are needed"
elif [ $RC -eq 0 ]; then
   echo "No updates are needed"
else
   echo "An error occurred in the package update check, try again"
fi

CentOS no update needed

Conclusion

Its important to keep your CentOS system up to date. You can use the above methodology to help.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

[Graylog] [LAB] [Phần 11] Cấu hình Graylog server tích hợp cảnh báo qua Slack

Chắc là mọi người đã biết đến Slack nơi tạo ra một room chat để mọi người có thể chia sẻ...
30/12/2020

[Graylog] [LAB] [Phần 9] Cấu hình graylog gửi cảnh báo qua email

Là một System Admin bạn luôn phải lưu ý vấn đề bảo mật của hệ thống. Khi có hoạt động đăng...
30/12/2020

Hướng dẫn cài đặt DirectAdmin lên máy chủ CentOS 6,7,8

Công cụ quản trị: DirectAdmin Phiên bản: Tất cả các phiên bản Dành cho: root (tài khoản có quyền...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024