Using a local Ubuntu repository is recommended when you are using a VPS with the Ubuntu OS and the server is located in Indonesia. This is because the system typically uses US or global repositories by default, which may cause the VPS update download process to be slow.
To speed up the process, you can update your Ubuntu repository sources to a local repository or a repository located in Indonesia so that the update download process can be faster.
In this article, we will try to update the Ubuntu repository from us.archive.ubuntu.com to mirror.poliwangi.ac.id. If you want to use a different repository, you can find one on this page: List of Indonesian Ubuntu Repositories.
For the official Ubuntu repository, you can change the URL us.archive.ubuntu.com to [country_code].archive.ubuntu.com, for example id.arhive.ubuntu.com for Indonesia (however, it is not currently available for Indonesia, so if you use id.arhive.ubuntu.com, it will automatically use the repository located in Singapore).
How to Use a Local Ubuntu Repository
1. Log In via SSH as Root
Depending on your VPS provider, you can usually log in directly as root, or you may need to use a command to access it as root.
If you have root access, you can log in via SSH using the command ssh root@Server_IP. However, if you do not get root access immediately, you need to log in using ssh username@Server_IP or by logging in using an SSH Key.
So, what if you are not logged in as the root user by default?
If you are not logged in as the root user by default, you can use the following command to gain root access:
sudo su -After you use the command above, you will automatically have root access.
2. Create a Backup of the Resource List File
After you have root access, you need to create a backup of the resource list file so that if you encounter errors after updating the resource list, you can restore the file.
To perform a backup, you can use the following command
cp /etc/apt/sources.list /etc/apt/sources.list.baksudo nano /etc/apt/sources.list.bakIf, after running the code above, the file editor opens for the file/etc/apt/sources.list.bak, then you have successfully created a backup.
You can simply close the file editor by pressing the CTRL+X keys, and you can proceed to the next step.
3. Update the sources.list File
Since you have already backed up the sources.list file, you can now safely edit it. To edit the sources.list file, you can use the following command:
sudo nano /etc/apt/sources.listOnce you are in the sources.list file editor, press theCTRL + Backslash (CTRL+\) keys to use thefind and replace feature.
In theSearch (to replace)option, enter your current repository domain name. Here, we are usingus.archive.ubuntu.com, then press enter.
Next, in theReplace Withoption, enter the domain name of the repository you want to use. As mentioned earlier, we will use the repository from mirror.poliwangi.ac.id, then press enter.
Next, for theReplace this instance? option, you can press theA key on your keyboard to change all instances of us.archive.ubuntu.comto mirror.poliwangi.ac.id.
After all instances of us.archive.ubuntu.com have changed to mirror.poliwangi.ac.id, you can close the file editor by pressing theCTRL+Xkeys, and when theSave modified bufferoption appears, just press theY key to save, and forFile name to write you can just press enter without changing the file name.
4. Scan Packages from the New Repository
The final step before updating with the new repository is to scan for packages. This minimizes the chance of encountering "package not found" errors when you perform the update.
To perform this package scan, you can use the following command
sudo apt-get update5. Perform Updates as Usual
After the scan process is complete, you can immediately update and upgrade your packages. To update and upgrade packages, you can use the following command:
sudo apt update && apt upgrade -y
COMMENTS
Loading...