This is a fancy way of saying we want to use someone else’s computer as our middleman when downloading packages from the internet. Why would you do this? Well, maybe your workplace has strict firewall rules that don’t allow direct connections to certain websites or servers. Or perhaps you just prefer using a proxy for privacy reasons. Whatever the case may be, here’s how we can set it up in Ubuntu:
1. Open up your terminal (you know, that black screen with white text) and type this command: `sudo nano /etc/apt/sources.list`
2. This will open a file called “sources.list” using the Nano editor. If you’re not familiar with Nano, it’s basically like Notepad but for Linux. You can use arrow keys to move around and type stuff in.
3. Scroll down until you see this line: `deb http://archive.ubuntu.com/ubuntu bionic main restricted`
4. Add the following lines below it (make sure they’re indented properly):
# This script adds two new lines to the sources.list file in Nano, allowing for the installation of packages from a trusted repository.
# The first line adds a deb (binary) source with the trusted=yes option, indicating that the repository is trusted and packages can be installed from it.
deb [trusted=yes] http://example.com/repo stable main
# The second line adds a deb-src (source) source with the trusted=yes option, indicating that the repository is trusted and source code can be downloaded from it.
deb-src [trusted=yes] http://example.com/repo stable main
5. Replace “http://example.com/repo” with the URL of your proxy server (you can usually find this information from your network administrator). The “stable” and “main” parts are optional, but they specify which version of packages to use and what type of software is included in them respectively.
6. Save and close the file by pressing Ctrl + X, then Y, followed by Enter. This will save any changes you made without exiting Nano.
7. Next, we need to add our proxy server’s credentials (if required) using this command: `echo “Acquire::http::Proxy \”http://username:password@proxy-server:port/\””; echo “Acquire::https::Proxy \”http://username:password@proxy-server:port/\”” | sudo tee -a /etc/apt/apt.conf.d/01proxy`
8. Replace “username”, “password”, and “proxy-server” with your actual credentials (if you have any) and the URL of your proxy server’s address, respectively. The port number is usually 3128 for HTTP or 443 for HTTPS connections.
9. Save and close the file by pressing Ctrl + X, then Y, followed by Enter. This will save any changes you made without exiting Nano.
10. Finally, update your package list using this command: `sudo apt-get update`
11. Wait for a few seconds while APT downloads the latest information from your proxy server and updates its local database of available packages.
12. That’s it! You should now be able to install software using your network proxy without any issues. If you encounter any problems, feel free to ask me in the comments section below or on Twitter @linux_nerd.