Setting system wide proxy through bash script (Temporarily)

I'm trying to temporarily set the system wide proxy option which is available as GUI in the Network Settings through bash script. I only want the proxy to be applicable while the script is running and has to reset to no proxy when the script ends. So, basically, I am looking for something like:

----Script Start----

Change Proxy to a predefined IP, port combination

Run

On close, reset proxy

----Script End-----

Now, I saw something on setting the environment variable but I am not sure how to apply this temporarily.

1 Answer

Type the following command to set proxy server in linux command line.

export http_proxy=

Put a back tick character (`) before and after that command so that bash will execute the EXPORT command.

Note: 1.2.3.4 is your proxy server ip address and 3128 is the port for example.

To remove the variable value, use this command.

unset VARIABLE_NAME

Exmaple:

unset http_proxy

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like