How to Set Proxy Settings in Linux Command Line or Terminal?

Reading time: 5 min read
Harsha Kiran
Written by
Harsha Kiran

Updated · Jan 23, 2024

Harsha Kiran
Founder | Joined March 2023 | LinkedIn
Harsha Kiran

Harsha Kiran is the founder and innovator of He started it as a personal passion proje... | See full bio

Florence Desiata
Edited by
Florence Desiata


Florence Desiata
Joined June 2023 | LinkedIn
Florence Desiata

Florence is a dedicated wordsmith on a mission to make technology-related topics easy-to-understand.... | See full bio

Techjury is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more.

Linux is still the third most popular desktop OS in the world. Developers like it more than the other OS because it is highly customizable. However, like other operating systems, it is not safe from threats.

That is why users add another layer of protection by using proxies. With proxies, you can enhance anonymity and safeguard sensitive information on your Linux-based devices.

Explore how to set a proxy on Linux in this article. Continue reading to find out.

🔑 Key Takeaways

  • Proxy setup in Linux is performed through desktop settings or Terminal, offering choices like temporary, permanent, or system-wide configurations.
  • Use commands like $ export http_proxy and $ export https_proxy in the Terminal for temporary proxy configurations suitable for specific sessions.
  • Modify the user's bashrc or bash_profile configuration files with export commands for HTTP and HTTPS proxies, ensuring persistent settings.
  • Edit the /etc/environment file for system-wide proxy settings, applying changes to all users. Reboot for the configurations to take effect.
  • Redirect Terminal traffic selectively, secure authenticated proxy passwords, and test proxy speed for enhanced usability.

Setting Up Proxies in Linux Command Line or Terminal

You can generally execute a proxy configuration in Linux through the desktop settings or the Terminal. It can be accomplished through the following configurations:

  • Temporary
  • Permanent
  • System-wide

Continue reading to learn how each one works.

📝Note: This guide works for all Linux distributions, like Ubuntu, CentOS, Fedora, and Debian.

Temporary Setup

The commands below will temporarily set up an environment variable for proxies. You can use any or both of these lines, depending on the protocol of your proxy IP.

$ export http_proxy=http://[proxy IP]:[port]

$ export https_proxy=https://[proxy IP]:[port]

For authenticated proxies, use this:

$ export http_proxy=http://[username]:[password]@[proxy IP]:[port]

$ export https_proxy=[username]:[password]@[proxy IP]:[port]

👍 Helpful Article

When a proxy is not set up correctly, it returns an error to inform you whether your web request is successful or not. Check out this TechJury guide to know what each proxy error means and how to address each one.  

Permanent Setup (Single User)

To configure a permanent setup, you must set up the proxy environment variables in the user’s bashrc or bash_profile configuration file. Run this command to access the file:

$ nano ~/.bashrc

It should return your configuration details. Scroll down to the very end. Paste any or both of these lines:

export http_proxy=http://[proxy IP]:[port]

export https_proxy=https://[proxy IP]:[port]

Use these commands for authenticated proxies:

export http_proxy=http://[username]:[password]@[proxy IP]:[port]

export https_proxy=[username]:[password]@[proxy IP]:[port]

Here’s how the entire setup should look:

Permanent Setup output on Terminal

Once you have confirmed the accuracy of your inputs, exit and save the changes.

After that, source your new configuration by running:

$ source ~/.bashrc

System-Wide Set Up

This third method follows the same process as how to set proxy in Linux permanently. The only difference is that the latter only serves a single user.

To access the system-wide configuration file, run this command:

$ sudo nano /etc/environment

Then, add these lines:

export http_proxy=http://[proxy IP]:[port]

export https_proxy=https://[proxy IP]:[port]

You can also do this:

export http_proxy=http://[username]:[password]@[proxy IP]:[port]

export https_proxy=[username]:[password]@[proxy IP]:[port]

Here’s how everything should look like:

System-Wide Setup output on Terminal

Exit and save. Reboot your device for the new configuration to be applied to the whole system. If you want to apply the changes immediately to your current session, you can run:

$ source /etc/environment

Once you complete the proxy setup in Linux’s Terminal, the environment variable configurations will work perfectly with various command-line tools like wget, cURL, lynx, and rsyc.

Linux Proxy Settings Tips

A successful proxy setup in Linux is just the beginning. The process extends beyond the initial configuration. Here are some best practices that you should remember after setting up a proxy for Linux:

#1: Redirect Terminal Traffic by Excluding a Command-Line Tool

Setting up the Linux proxy settings through the command line will reroute Terminal communication to the proxy server. You can exclude a specific command-line tool in this setup.

For example, use this in your wget commands to exempt it from proxies:

$ wget --no-proxy

#2: Protect Your Password for Safer Authentication

Exposing your password as plain text is not secure. This happens when you set up a proxy environment variable in the config file like this:

export https_proxy=[username]:[password]@[proxy IP]:[port]

Instead, use alternative methods like cntlm to handle proxy server authentication securely. Just install cntlm by running:

$ sudo apt-get install cntlm

The cntlm config file is located at ‘/etc/cntlm.conf’. Configure it with your proxy server information and localhost address (or ‘’) with 3128 as the port number.

After that, run this command:

$ cntlm -H -u [username] -d [your domain]

You will be asked for your password to generate an NTLM hash. Open the config file again and look for PassLM. Replace the corresponding information with the NTLM hash.

Save and exit. Then, run cntlm:

$ sudo service cntlm start

You can now use as your proxy address and port. This will automatically authenticate itself to the remote proxy server without you having to store your password in the config file.

#3: Test your Proxy Speed

Always test your proxy speed after setting it up. You can do that by running this wget command:

wget -O /dev/null


Linux users can enhance security and privacy by setting up proxies through temporary, permanent, or system-wide configurations—all through desktop settings or Terminal. Temporary setups are ideal for specific sessions, while permanent and system-wide configurations provide long-term protection.

Understanding and implementing these proxy settings can contribute to a safer and more anonymous online experience for Linux users.

FAQs on Proxy Configuration in Linux.

How do you configure a forward proxy on Linux?

Access the network settings on your Linux desktop. Find the network proxy settings and choose between manual or automatic setup. Alternatively, use the Linux Terminal to export an environment variable (export https_proxy=https://[proxy IP]:[port]).

How do you disable proxy on the Linux command line?

Run “unset http_proxy” or “unset https_proxy” depending on the proxy protocol you are disabling.

How to check proxy settings on the Linux command line?

Run “env | grep -i proxy.” It should display the proxy environment variables.


Facebook LinkedIn Twitter
Leave your comment

Your email address will not be published.