Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to just temporarily disable apt proxy setting for installing packages

Apt is able to use proxy to install additional packages along with dependencies. I'm working on a Python project and I needed some extra package that provides a library.

---> sudo apt-get update
Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Could not resolve 'proxy.internal'
Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease
  Could not resolve 'proxy.internal'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Could not resolve 'proxy.internal'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Could not resolve 'proxy.internal'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Could not resolve 'proxy.internal'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Could not resolve 'proxy.internal'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Could not resolve 'proxy.internal'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Could not resolve 'proxy.internal'
W: Some index files failed to download. They have been ignored, or old ones used instead.

How to temporarily disable proxy (without altering the permanent options/settings)? Preferably, from the command line.

like image 359
ww12 Avatar asked Oct 17 '25 08:10

ww12


1 Answers

The quickest method for temporarily disabling proxy configuration without altering the permanent settings is to use the command line option like below:

sudo apt-get -o Acquire::http::proxy=false install <package>

This gives the user the mobility between open/public/home network and corporate environments with proxy. From manual page:

   -o, --option
       Set a Configuration Option; This will set an arbitrary configuration option. The syntax is -o
       Foo::Bar=bar.  -o and --option can be used multiple times to set different options.
like image 141
ww12 Avatar answered Oct 19 '25 08:10

ww12