如何为linux系统设置全局的默认网络代理

方法1:更改全局配置文件/etc/profile

all_proxy="all_proxy=socks://proxy.xxx.com.cn:80/"
ftp_proxy="ftp_proxy=http://proxy.xxx.com.cn:80/"
http_proxy="http_proxy=http://proxj.xxx.com.cn:80/"
https_proxy="https_proxy=http://proxy.xxx.com.cn:80/"
no_proxy="no_proxy=localhost,127.0.0.0/8,::1,.xxx.intra"

for var in "$all_proxy" "$ftp_proxy" "$http_proxy" "$https_proxy" "$no_proxy";do
      echo $var >> /etc/profile
done

for var in "all_proxy" "ftp_proxy" "http_proxy" "https_proxy" "no_proxy";do
      echo "export $var" >> /etc/profile
done

 方法2:仅针对Gnome或MATE桌面系统, 根据GSetttings配置原理添加override文件

[org.gnome.system.proxy]
ignore-hosts=['localhost', '127.0.0.0/8', '::1'']

[org.gnome.system.proxy.ftp]
host='proxy.xxx.com.cn'
port=80

[org.gnome.system.proxy.http]
host='proxy.xxx.com.cn'
port=80

[org.gnome.system.proxy.https]
host='proxy.xxx.com.cn'
port=80

[org.gnome.system.proxy.socks]
host='proxy.xxx.com.cn'
port=80

  note:命令行下查询Gsetting数据库键值的方法

[cxy@localhost-live x86_64]$ gsettings get org.gnome.system.proxy
org.gnome.system.proxy         org.gnome.system.proxy.ftp     org.gnome.system.proxy.http    org.gnome.system.proxy.https   org.gnome.system.proxy.socks 
[cxy@localhost-live x86_64]$ gsettings get org.gnome.system.proxy
org.gnome.system.proxy         org.gnome.system.proxy.ftp     org.gnome.system.proxy.http    org.gnome.system.proxy.https   org.gnome.system.proxy.socks 
[cxy@localhost-live x86_64]$ gsettings get org.gnome.system.proxy.http
org.gnome.system.proxy.http    org.gnome.system.proxy.https   
[cxy@localhost-live x86_64]$ gsettings get org.gnome.system.proxy.http 
authentication-password  authentication-user      enabled                  host                     port                     use-authentication       
[cxy@localhost-live x86_64]$ gsettings get org.gnome.system.proxy.http host
'proxy.xxx.com.cn'

[cxy@localhost-live x86_64]$ gsettings
用法:
gsettings --version
gsettings [--schemadir SCHEMADIR] COMMAND [ARGS...]

命令:
help 显示此信息
list-schemas 列出安装了的方案
list-relocatable-schemas 列出可重定向的方案
list-keys 列出某个方案中的键
list-children 列出某个方案的子对象
list-recursively 递归地列出键和值
range 查询某个键的范围
describe 查询某个键的描述
get 获取某个键值
set 设置某个键值
reset 重设某个键值
reset-recursively 重设指定方案中的所有值
writable 检查某个键是否可写
monitor 监视更改

使用 'gsettings help 命令' 查看详细的帮助。

  

 

posted @ 2018-08-02 15:11  无边身尊者  阅读(11025)  评论(0编辑  收藏  举报