一、为系统设置代理
编辑文件/etc/profile,增加如下两行
1 2
   | export http_proxy=http://proxy.com:8080/ export https_proxy=http://proxy.com:8080/
   | 
 
然后更新一下环境文件:
二、为yum配置代理
在/etc/yum.conf后面添加以下内容:
如果代理不需要用户名密码认证:
1
   | proxy=http://proxy.com:8080/
   | 
 
如果需要认证
1 2 3
   | proxy=http://proxy.com:8080/ proxy_username=代理服务器用户名 proxy_password=代理服务器密码
   | 
 
然后更新一下环境文件:
1 2
   | #使用source后者source yum.conf source /etc/yum.conf
   | 
 
三、为wget代理设置:
编辑文件为:/etc/wgetrc
添加下面两行:
1 2
   | http_proxy=http://192.168.199.168:7890/ https_proxy=http://192.168.199.168:7890/
   | 
 
然后更新一下环境文件:
1 2
   | #使用source后者source /etc/wgetrc source /etc/wgetrc 
   | 
 
四、网页上网
网页上网设置代理很简单,在firefox浏览器下 Edit–>>Preferences–>>Advanced–>>Network
在Connection下点击Settings,里面的manual proxy configuration里设置IP和PORT即可
bash代理
1 2 3 4 5 6
   | $ vi ~/.bashrc # http代理 export https_proxy=http://192.168.199.168:7890 http_proxy=http://192.168.199.168:7890 ftp_proxy=192.168.199.168:7890 all_proxy=socks5://192.168.199.168:7890
  # 非代理白名单 export no_proxy="localhost, 127.0.0.1, ::1, 192.168.*.*, 10.*.*.*, *.local"
   | 
 
或者通过设置alias简写来简化操作,每次要用的时候输入setproxy,不用了就unsetproxy。
1 2
   | alias proxy="export ALL_PROXY=socks5://127.0.0.1:7890"  alias unsetproxy="unset ALL_PROXY"
   | 
 
取消系统代理:
1
   | unset  http_proxy  https_proxy  all_proxy 
   | 
 
一般下载数据集时,记得取消代理。
取消bash代理设置
1
   | unset http_proxy; unset https_proxy; unset ftp_proxy; unset all_proxy
   | 
 
apt代理
1 2 3 4 5
   | $ sudo vi /etc/apt/apt.conf Acquire::http::Proxy "http://127.0.0.1:7890"; Acquire::https::Proxy "http://127.0.0.1:7890"; Acquire::ftp::Proxy "http://127.0.0.1:7890"; Acquire::socks5::proxy "socks5://127.0.0.1:7890/";
   | 
 
git代理配置
1 2 3 4 5 6 7 8
   | # 添加git代理 git config --global http.proxy http://127.0.0.1:7890 git config --global https.proxy https://127.0.0.1:7890
  # 取消git代理 git config --global --unset http.proxy git config --global --unset https.proxy
 
   |