Trong khi sử dụng Ubuntu, câu lệnh thường xuyên phải gõ là sudo apt-get update. Lệnh đó dùng để update các repository của các phần mềm, nhằm update, upgrade các phần mềm đó. Tuy nhiên, do lỗi khách quan và chủ quan, có thể bị một số lỗi sau:
1. 404 Not Found
![Hình 2](https://storage.googleapis.com/s-global.top/trachanh.vn/loi-khong-update-duoc-ubuntu.jpg)
![Hình 2](https://storage.googleapis.com/s-global.top/trachanh.vn/loi-khong-update-duoc-ubuntu-75x75.jpg)
Lý do: Thông thường có 3 lý do bị lỗi này:
- Sau khi upgrade phần mềm và enabled lại PPA software-source không tồn tại.
- Add link PPA bị sai.
- PPA đã thêm vào từ trước, nhưng nhà cung cấp xóa link cũ đi.
Thông thường, các PPA software-source lưu tại /etc/apt/source.list hoặc các file đuôi .list trong thư mục /etc/apt/source.list.d/
Cách khắc phục: Xóa các repository đã cũ. Như hình trên, bạn có thể bỏ qua các link lỗi trong khi cập nhật, sau khi cập nhật trình update sẽ thống kê các lỗi ở dưới như hình thứ 2. Như trong hình, link http://ppa.launchpad.net/psyke83/ppa/ubuntu/dists/trusty/main/binary-amd64/Packages đã bị xóa. Trong đó, phần màu đỏ (psyke83/ppa) là tên của phần mềm. Để xóa phần mềm bạn gõ lệnh sau:
sudo add-apt-repository -remove ppa:psyke83/ppa
Sau khi xóa hết, bạn chạy lại lệnh sudo apt-get update.
2.GPG Error
Thông thường lỗi sẽ có dạng như sau:
W: GPG error: http://no.archive.ubuntu.com oneiric Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 W: GPG error: http://no.archive.ubuntu.com oneiric-updates Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 W: GPG error: http://no.archive.ubuntu.com oneiric-proposed Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 W: A error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://security.ubuntu.com oneiric-security Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5x
Lý do: khi add các respository, các key GPG bị thiếu.
Cách khắc phục: Dựa theo thông tin báo lỗi, nếu thiếu GPG key nào ta sẽ add key đó bằng lệnh: sudo apt-key adv -recv-keys -keyserver keyserver.ubuntu.com <key>
3. Hash Sum mismatch
Lý do:
Cách khắc phục: Chạy lần lượt các lệnh sau. (Chú ý, bạn nên backup các file trong thư mục /var/lib/apt/lists/ trước khi thực hiện)
apt-get clean rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/partial/* apt-get clean apt-get update apt-get upgrade