delete/disable ubuntu repository featured image

วิธีปิดการใช้งานพื้นที่เก็บข้อมูลบน Ubuntu 22.04 LTS

ในบทความนี้ ฉันจะสาธิตวิธีการต่างๆ ในการปิดการใช้งานพื้นที่เก็บข้อมูลบน Ubuntu

วิธีที่รวดเร็วและมีประสิทธิภาพในการปิดการใช้งานพื้นที่เก็บข้อมูลบน Ubuntu

ปิดการใช้งานพื้นที่เก็บข้อมูลโดยการเปลี่ยนชื่อไฟล์ในโฟลเดอร์ Sources.list.d

One swift method to disable a repository on Ubuntu 22.04 involves renaming the appropriate file located in /etc/apt/sources.list.d/. For instance, if you wish to disable the “virtualbox” repository, you can simply rename /etc/apt/sources.list.d/virtualbox.list to /etc/apt/sources.list.d/virtualbox.list-disabled. Ensure you replace “virtualbox” with the name of your target repository.

$ sudo mv /etc/apt/sources.list.d/virtualbox.list /etc/apt/sources.list.d/virtualbox.list-disabled

The drawback of this approach is that you may encounter the following error message when you run the apt command:

“N: Ignoring file ‘virtualbox.list-disabled’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension.”

ปิดการใช้งานพื้นที่เก็บข้อมูลโดยการลบไฟล์ในโฟลเดอร์ Sources.list.d

This method not only disables the repository but also helps you avoid the error message mentioned above. To disable the “virtualbox” repository, you need to move the repository configuration file from /etc/apt/sources.list.d/ to another location, such as /tmp/virtualbox.list-disabled.

$ sudo mv /etc/apt/sources.list.d/virtualbox.list /tmp/virtualbox.list-disabled

วีออยลา – no more errors when running the “apt” command!

การใช้คำสั่ง apt-add-repository

Despite its name, the apt-add-repository command can be employed for deleting a repository. You can refer to the manual page using the command man apt-add-repository for more details. The option -r หรือ --remove is used to remove a specified repository.

$ man apt-add-repository
$ sudo apt-add-repository --remove virtualbox

Unfortunately, you may encounter an error stating, “Unable to handle repository shortcut.”

บทสรุป

The swiftest and most efficient method for disabling an APT repository is to remove the repository file from the /etc/apt/sources.list.d/ directory. This approach ensures the complete removal of the repository, whereas the apt-add-repository command is more prone to errors and may require troubleshooting.