Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Linux

ปิด Automatic Updates ใน Ubuntu อย่างปลอดภัย: คู่มือขั้นตอนละเอียด

การอัปเดต applications เป็นประจำสำคัญเพื่อป้องกันระบบจาก vulnerabilities และเก็บให้ updated กับ latest features และ security patches

ใน Ubuntu automatic updates เปิดโดยค่าเริ่มต้น และเก็บระบบ updated โดยไม่ต้อง manually update packages ผู้ใช้บางส่วนชอบ manual control over updates เพราะให้ flexibility ติดตั้ง updates ตาม preferences

มาดูวิธี disable automatic updates ใน Ubuntu

ทำไมต้อง Disable Automatic Updates บน Ubuntu?

การอัปเดตระบบ manually เป็นประจำอาจ time-consuming และ tiresome Automatic update หรือที่รู้จักในชื่อ Unattended Upgrade feature บน Ubuntu ทำให้ task นี้ง่ายขึ้น มัน automatically checks และ installs security และ other updates โดยไม่ต้อง manual intervention

แต่มันก็มี drawbacks เช่น consume bandwidth และ resources ทำให้ระบบช้าและ affect กระบวนการอื่นๆ โดยเฉพาะ peak hours ด้วยการ disable automatic updates คุณได้ manual control over เมื่อไหร่และ update ไหนที่จะรัน

เพิ่มเติม เมื่อคุณพยายามติดตั้ง packages บน Ubuntu ขณะ automatic update กำลังรันใน background คุณจะได้ error ว่า "Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend"

สิ่งนี้น่าหงุดหงิดมากเพราะไม่ให้คุณติดตั้ง package จนกว่า update จะเสร็จ เพื่อป้องกันไม่ให้เกิดซ้ำ ตัวเลือกเดียวคือ disable automatic updates

วิธี Disable Automatic Updates บน Ubuntu

Automatic updates ใน Ubuntu จัดการโดย unattended-upgrades package ซึ่ง preinstalled บน Ubuntu releases ส่วนใหญ่ เพื่อเช็คว่า Unattended Upgrades ติดตั้งและรันอยู่บนระบบ ใช้คำสั่ง:

sudo systemctl status unattended-upgrades.service

คุณเช็คได้อีกทางโดยดู current configuration ของ Unattended Upgrades:

apt-config dump APT::Periodic::Update-Package-Lists
apt-config dump APT::Periodic::Unattended-Upgrade

ถ้าเห็น output เหมือนด้านล่าง แสดงว่า automatic update เปิดอยู่

ถ้า value ของ APT::Periodic::Update-Package-Lists และ APT::Periodic::Unattended-Upgrade เป็น "0" แสดงว่า automatic updates ปิดอยู่

เพื่อ disable Unattended Upgrades บน Ubuntu รันคำสั่ง:

sudo nano /etc/apt/apt.conf.d/20auto-upgrades

จะเปิด configuration file ใน Nano editor เปลี่ยน value ของ Update-Package-Lists และ Unattended-Upgrade เป็น 0:

APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";

เมื่อเสร็จ save และปิดไฟล์

สิ่งนี้จะบอกระบบให้ disable automatic downloading และ installation ของ updates หลังจากนั้น รันคำสั่งต่อไปนี้ verify ว่า automatic updates ปิดแล้ว:

apt-config dump APT::Periodic::Update-Package-Lists
apt-config dump APT::Periodic::Unattended-Upgrade

ถ้าปิดแล้ว คุณจะได้ output ตามด้านล่าง

ในอนาคต หากคุณอยาก re-enable automatic updates เปิด file /etc/apt/apt.conf.d/20auto-upgrades และเปลี่ยน values ของ Update-Package-Lists และ Unattended-Upgrade เป็น 1

หากคุณอยาก permanently disable automatic updates feature รันคำสั่ง:

sudo apt remove unattended-upgrades

Disable Automatic Updates บน Ubuntu แบบ Graphical

คุณ disable automatic updates บน Ubuntu แบบ graphical ได้อีกด้วย กด Super key บนคีย์บอร์ด และพิมพ์ "software and updates." จาก search results เลือก Software & Updates

ภายใต้ tab Updates คุณจะเห็น options ต่างๆ สำหรับ update configuration โดย default มัน configured เช็ค updates daily หากคุณไม่อยากให้ระบบ automatically check for updates ตั้งค่า Automatically check for updates เป็น Never

เช่นกัน เปลี่ยน When there are security updates จาก Download and install automatically เป็น Display immediately นี่จะแจ้งคุณเกี่ยวกับ security updates ทันทีที่พร้อม

Settings นี้แค่ disable ระบบจากการเช็ค updates อัตโนมัติ คุณยังเช็คและติดตั้ง updates manually ได้ตลอดเวลา

ติดตั้ง Updates แบบ Manual บน Ubuntu

เพื่อ manually check และ install updates บนระบบ รัน update และ upgrade commands:

sudo apt update
sudo apt upgrade

คุณติดตั้ง updates แบบ manual บน Ubuntu graphically ได้อีกด้วย Ubuntu Software Updater tool

Package Updates ช่วย Maintain System Security

แม้ไม่แนะนำให้ disable automatic updates ใน OS ใดๆ แต่อาจมีบาง reasons ที่คุณอยากทำอยู่ดี

ไม่ว่าจะเป็นเหตุผลอะไร คุณตอนนี้ disable automatic updates ใน Ubuntu ได้ง่าย ไม่ว่าผ่าน command line หรือ graphically อย่างไรก็ตาม ตรวจสอบให้แน่ใจว่า manually update ระบบและ applications เป็นประจำเพื่อ maintain system security และ minimize risk ของ breaches