How to set proxy for apt ubuntu?

Setting a proxy for APT (Advanced Package Tool) in Ubuntu is a straightforward process that allows you to download packages through a proxy server. This can be particularly useful in environments where direct internet access is restricted or when you want to improve your download speeds. In this guide, we’ll walk you through the steps to configure APT to use a proxy server.

Step 1: Identify Your Proxy Server

Before configuring APT, you need to know the details of your proxy server, including the IP address and port number. A common format for a proxy server is:

http://username:[email protected]:port

If your proxy does not require authentication, you can skip the username and password.

Step 2: Configure APT to Use the Proxy

You will need to create or modify the configuration file for APT. Open a terminal window and use a text editor like nano or vim to edit the APT configuration file:

sudo nano /etc/apt/apt.conf.d/99proxy

In this file, you can specify your proxy settings. Add the following lines, replacing the placeholder values with your actual proxy details:

For an HTTP proxy:

Acquire::http::Proxy "http://username:[email protected]:port/";

If your proxy does not require authentication, use:

Acquire::http::Proxy "http://proxyserver.com:port/";
Acquire::https::Proxy "http://proxyserver.com:port/";

Step 3: Save and Exit

After you have entered the proxy configuration, save the changes and exit the text editor. In nano, you can do this by pressing CTRL + X, then Y, and finally Enter.

Step 4: Update APT and Install Packages

Now that you have configured the proxy, you can update your package list and install packages using APT. Run the following commands:

sudo apt update

If everything is set up correctly, APT will use the specified proxy to connect to the repositories and download package information.

Step 5: Testing Your Configuration

To ensure that your proxy settings are working properly, you can try installing a package. For example, to install curl, run:

sudo apt install curl

If the installation proceeds without errors, your proxy configuration is working correctly.

By following these steps, you have successfully configured APT to use a proxy in Ubuntu. This setup will help you manage package installations and updates in environments where direct internet access is restricted. For more tips and tutorials, visit DropVPS.com!

Share:

More Posts

How to Install Maven on macOS 2025

What you will read?1 Check for Java Installation2 Install Homebrew (If Not Installed)3 Install Maven via Homebrew4 Verify Environment Variables (Optional)5 Create a Sample Maven

How to Use Google SMTP Server

What you will read?1 Step 1: Enable SMTP Access in Gmail2 Step 2: Secure Connection with TLS3 Step 3: Send an Email via SMTP4 Step

how to install wine on RHEL

What you will read?1 Check RHEL version and CPU architecture2 Update system and install base tools3 Verify subscription and enable CodeReady Builder4 Enable EPEL repository5

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments