Proxy Settings in Linux

Setting up a proxy on a Linux system can vary depending on the distribution you are using and whether you want to set the proxy for the entire system, a specific user, or just for a specific application like a web browser. 

Setup Proxy in Linux

For Permanent Use (Persistent Across Reboots)

1. Open a terminal.

2. Use your preferred text editor to open or create a .bash_profile.bashrc, or .profile file in your home directory. For example, you can use nano:

3. Add the following lines to the file

4. Save the file and exit the text editor (in nano, press CTRL + X, then Y to confirm, and Enter to save).

5. To apply the changes immediately, you can source the file:

For Temporary Use (Session-Only)

You can set environment variables for the current session only. Open a terminal and use the following commands:

Replace PROXY_SERVER and PORT with your proxy server’s IP address or hostname and the port number.

Application-Specific Proxy Settings

For applications like web browsers or package managers (e.g., apt for Ubuntu/Debian or yum/dnf for Fedora), you may need to configure proxy settings within the application’s configuration files or settings menus.

For example, to set a proxy for apt, you would create or edit a file at /etc/apt/apt.conf.d/ and add the following lines:

After setting up the proxy, you may need to restart your network or your computer for the changes to take effect. Additionally, be aware that some applications or services may not honor the system-wide proxy settings and may require individual configuration.

How to Disable Proxy

Disabling a Temporary Proxy

If you set the proxy using environment variables for the current session using the export command, you can disable it by unsetting those variables. Open a terminal and run:

This will only affect the current session. If you open a new terminal window, those variables won’t be set unless you’ve added them to a startup file like .bashrc or .profile.

Disabling a Permanent Proxy

If you’ve made permanent changes to your environment variables in files like .bashrc.bash_profile, or .profile, you’ll need to edit those files again and remove the lines that set the proxy variables. For example:

1. Open the file with a text editor:

2. Find and remove the lines that set the http_proxyhttps_proxyftp_proxy, and no_proxy variables.

3. Save the file and exit the editor.

4. To apply the changes, either source the file again with source ~/.bashrc or log out and log back in.

Disabling Proxy for Applications

If you set the proxy for specific applications like apt, you will need to edit the application’s configuration files. For example, to disable the proxy for apt, you would do the following:

1. Open the apt configuration file:

Replace your-proxy-file with the actual filename you used to set the proxy.

2. Comment out the proxy lines by adding a # at the beginning of each line or remove them entirely.

3. Save the file and exit the editor.

Disabling System-Wide Network Proxy

If you configured a system-wide network proxy using a GUI tool like “Network Settings” in GNOME, KDE, or another desktop environment:

1. Open the network settings via your desktop environment’s settings manager.

2. Navigate to the network proxy settings.

3. Change the settings to “None” or “Direct Internet Connection.”

4. Apply or save the changes.

After disabling the proxy settings, you might need to restart your networking service or your computer to ensure that all applications recognize the change.