Linux 从终端更改 Ubuntu 12.04 中的系统代理设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10234872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing system proxy settings in Ubuntu 12.04 from terminal
提问by devorus
I've been working in Ubuntu 12.04 and one of the things that I am trying to implement in a Bash script is modifying the proxy settings of the system. To clarify, this would be a script that sets up each VM that I make with the programs and packages that I need. I can find and edit the Proxy settings manually through System Settings and selecting Network, but my intention is to automate this part.
我一直在 Ubuntu 12.04 中工作,我试图在 Bash 脚本中实现的一件事是修改系统的代理设置。澄清一下,这将是一个脚本,用于设置我使用我需要的程序和包制作的每个 VM。我可以通过系统设置和选择网络手动查找和编辑代理设置,但我的目的是自动化这部分。
The code that I have tried up to now has been:
到目前为止,我尝试过的代码是:
gconftool --set /system/http_proxy/host --type string *host*
gconftool --set /system/http_proxy/port --type int *port*
gconftool --set /system/http_proxy/use_http_proxy --type bool true
gconftool --set /system/http_proxy/use_same_proxy --type bool true
gconftool --set /system/proxy/mode --type string manual
I have also tried the above with gconftool-2
. Any help would be appreciated.
我也试过上面的gconftool-2
. 任何帮助,将不胜感激。
采纳答案by Jiri
You must use new gsettings
tool and not old gconftool, with a bit different keys:
您必须使用新gsettings
工具而不是旧 gconftool,其键位略有不同:
gsettings set org.gnome.system.proxy.socks host '127.0.0.1'
gsettings set org.gnome.system.proxy.socks port 3128
gsettings set org.gnome.system.proxy mode 'manual'
# to disable proxy:
# gsettings set org.gnome.system.proxy mode 'none'