2010-10-05 16:55:44 +0000 2010-10-05 16:55:44 +0000
22
22
Advertisement

Linux命令行关闭代理

Advertisement

当我在Ubuntu中使用命令行终端时,你能告诉我关闭代理的命令行吗?

Advertisement
Advertisement

答案 (7)

28
28
28
2011-02-21 07:27:47 +0000

就像其他答案说的那样,有一些程序根本不看系统,你可能要单独设置它们。例如wget有很多代理选项,可以在执行过程中忽略或调整环境代理配置。下面是一些可以设置系统代理的地方。

  • 我的系统看起来如何,请注意,你必须为你的网络环境改变指定的系统配置。

有些Linux系统使用/etc/environment

$ cat /etc/environment 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
http_proxy="http://192.168.1.250:8080/"
ftp_proxy="ftp://192.168.1.250:8080/"
https_proxy="https://192.168.1.250:8080/"

没有统一的设置,其他的使用env

$ env | grep -i proxy
NO_PROXY=localhost,127.0.0.0/8,127.0.1.1
http_proxy=http://192.168.1.250:8080/
FTP_PROXY=ftp://192.168.1.250:8080/
ftp_proxy=ftp://192.168.1.250:8080/
all_proxy=socks://192.168.1.250:8080/
ALL_PROXY=socks://192.168.1.250:8080/
HTTPS_PROXY=https://192.168.1.250:8080/
https_proxy=https://192.168.1.250:8080/
no_proxy=localhost,127.0.0.0/8,127.0.1.1
HTTP_PROXY=http://192.168.1.250:8080/

我会查看~/.bashrc,以便在系统启动时自动应用设置。

$ man env
$ man set
$ # The file section near the end of the bash manual.
$ man bash 

FILES
       /bin/bash
              The bash executable
       /etc/profile
              The systemwide initialization file, executed for login shells
       /etc/bash.bashrc
              The systemwide per-interactive-shell startup file
       /etc/bash.bash.logout
              The systemwide login shell cleanup file, executed when a login
              shell exits
       ~/.bash_profile
              The personal initialization file, executed for login shells
       ~/.bashrc
              The individual per-interactive-shell startup file
       ~/.bash_logout
              The individual login shell cleanup file, executed when a login
              shell exits
       ~/.inputrc
              Individual readline initialization file

0x2

6
6
6
2016-05-03 16:49:09 +0000

你可以在bash中一次性设置或取消设置所有变量。

$ export {http,https,ftp}_proxy="http://proxy-server:port"
$ unset {http,https,ftp}_proxy

$ export {HTTP,HTTPS,FTP}_PROXY="http://proxy-server:port"
$ unset {HTTP,HTTPS,FTP}_PROXY

你也可以给你的~/.bashrc添加一个快捷方式。

# Set Proxy
function setproxy() {
    export {http,https,ftp}_proxy="http://proxy-server:port"
    export {HTTP,HTTPS,FTP}_PROXY="http://proxy-server:port"
}

# Unset Proxy
function unsetproxy() {
    unset {http,https,ftp}_proxy
    unset {HTTP,HTTPS,FTP}_PROXY
}

别忘了重新加载.bashrc:

$ . ~/.bashrc

$ source ~/.bashrc

更多细节请访问[S]hell Hacks.

3
Advertisement
3
3
2013-05-10 13:12:55 +0000
Advertisement
export http_proxy=

你可以通过运行

echo $http_proxy

来检查它们是否消失了,它应该会返回一行空白。

3
3
3
2011-08-05 06:23:06 +0000

如果您想更改 GUI 程序的代理,如果他们使用 Gnome 的 “系统 "代理设置,您可能会获得一些成功。这些是可从控制面板中设置的代理设置。

您可以使用 gconftool 查看并更改当前设置。

$ gconftool-2 -a /system/http_proxy
  ignore_hosts = [localhost,127.0.0.0/8,*.local]
  authentication_user =
  authentication_password =
  use_authentication = false
  use_http_proxy = true
  port = 8080
  host = http://myproxy.mydomain.org/

要关闭代理–将use/http/_proxy设置为false:

$ gconftool-2 -t bool -s /system/http_proxy/use_http_proxy false

你可以使用上面的-a行检查结果。或者设置一个新的代理。

$ gconftool-2 -t string -s /system/http_proxy/host "http://newproxy.mydomain.org/"
$ gconftool-2 -t int -s /system/http_proxy/port 8088
1
Advertisement
1
1
2016-05-27 07:18:15 +0000
Advertisement

如果上面写的都不行。

1、进入系统设置。 2. 进入 “网络"。 3. 转到网络代理,即使选择的是 "无",也要转到 "手动 "并删除所有保存的代理。 4. 在整个系统中应用。

这对我来说很有效!

1
1
1
2018-05-03 22:41:11 +0000

要在一行中禁用当前会话的所有代理变量:

unset `env | grep proxy | cut -d= -f1`
```。
0
Advertisement
0
0
2019-02-07 05:00:29 +0000
Advertisement

你可以删除/etc/environment中的所有{http/proxy, https/proxy}等,只要sudo gedit /etc/environment,然后手动删除所有这些代理并保存。

Advertisement