This comprehensive guide shows you how to export a SOCKS5 proxy on Linux, configure it for different applications, and ensure a secure and private browsing experience.
A SOCKS5 proxy is a versatile tool that can be used to route internet traffic through a remote server, offering a high level of privacy and security. Linux users often turn to SOCKS5 proxies for use cases such as web scraping, bypassing geo-blocked content, or securing network traffic. In this article, we will guide you through the process of exporting and configuring a SOCKS5 proxy in Linux for both temporary and permanent use.
SOCKS5 is the latest version of the SOCKS protocol, which allows clients to connect to servers through a proxy. It supports a variety of authentication methods, offers better security than HTTP proxies, and can handle any kind of traffic — whether it's HTTP, HTTPS, or even UDP traffic. The ability to tunnel virtually all types of traffic makes SOCKS5 particularly useful for bypassing firewalls or geo-restrictions.

Here, we will show you how to configure a SOCKS5 proxy on Linux for a temporary session and also explain how to make it permanent.
For quick use, you can set up the SOCKS5 proxy for the current session. This will route all traffic from applications that respect environment variables (such as curl, wget, and others) through the proxy.
Setting the Environment Variables
Open your terminal.
Set the proxy by exporting the following environment variables:
1
2export http_proxy="socks5://<proxy_address>:proxy_port"
3export https_proxy="socks5://<proxy_address>:proxy_port"
4export ftp_proxy="socks5://<proxy_address>:proxy_port"
5export no_proxy="localhost,127.0.0.1"
6
7Replace proxy_address with the IP address or hostname of your SOCKS5 proxy server, and proxy_port with the port number your proxy uses. For example, if your SOCKS5 proxy is located at 127.0.0.1 on port 1080, the command would be:
1
2export http_proxy="socks5://127.0.0.1:1080"
3export https_proxy="socks5://127.0.0.1:1080"
4export ftp_proxy="socks5://127.0.0.1:1080"
5export no_proxy="localhost,127.0.0.1"
6
71
2echo $http_proxy
3echo $https_proxy
4
5These should output something like socks5://127.0.0.1:1080, confirming the proxy has been applied.
Once the export commands are run, the proxy configuration is active for the current session. This means any application that checks environment variables will now use the SOCKS5 proxy to route traffic.
You can test whether the proxy is working by running commands like curl or wget. For instance:
1
2curl http://example.com
3
4This will route the request through the SOCKS5 proxy.
If you'd like your SOCKS5 proxy configuration to persist across multiple terminal sessions, you will need to modify your shell’s configuration file. This ensures that the proxy settings are applied every time you open a new terminal session.
Steps to Set the Proxy Permanently
1
2nano ~/.bashrc
3
4For Zsh, open .zshrc:
1
2nano ~/.zshrc
3
41
2export http_proxy="socks5://127.0.0.1:1080"
3export https_proxy="socks5://127.0.0.1:1080"
4export ftp_proxy="socks5://127.0.0.1:1080"
5export no_proxy="localhost,127.0.0.1"
6
7Save and exit the text editor (Ctrl + O to save, then Ctrl + X to exit in nano).
Apply the changes by sourcing the configuration file:
1
2source ~/.bashrc # For Bash
3# OR
4source ~/.zshrc # For Zsh
5
6Now, your SOCKS5 proxy will be applied automatically to every new terminal session, without needing to manually export the proxy each time.
After exporting the SOCKS5 proxy, most applications that rely on environment variables will automatically route their traffic through the proxy.
1
2curl --proxy socks5://127.0.0.1:1080 http://example.com
3
41
2wget -e use_proxy=yes -e http_proxy=socks5://127.0.0.1:1080 http://example.com
3
4Browsers (Firefox/Chrome): For browsers, you might need to configure the SOCKS5 proxy directly in the browser settings. For Firefox, go to Preferences > General > Network Settings, and configure the SOCKS5 proxy.
Other Applications: For other software like git, rsync, and various command-line tools, they will usually pick up the proxy from the environment variables.
While SOCKS5 is very flexible, there are some potential pitfalls to watch out for:
By following these steps, you can easily configure a SOCKS5 proxy in Linux for your system or specific applications. Whether you need it temporarily or permanently, the flexibility of environment variables allows for easy adjustments. SOCKS5 proxies provide robust privacy and security features, making them a popular choice for users who value anonymity, need to bypass restrictions, or want to secure their internet traffic.
Now that you know how to export and configure a SOCKS5 proxy in Linux, you can route your traffic with ease. If you encounter any issues or need further help, feel free to reach out!