Getting Started with Python for the Internet of Things
上QQ阅读APP看书,第一时间看更新

There's more...

We also need to allow the proxy settings to be used by some programs, which use superuser permissions while accessing the network (this will depend on the program; most don't need this). We need to add the commands into a file stored in /etc/sudoers.d/ by performing the following steps:

  1. Use the following command to open a new sudoer file:
sudo visudo -f /etc/sudoers.d/proxy  
  1. Enter the following text in the file (on a single line):
Defaults env_keep += "http_proxy HTTP_PROXY https_proxy HTTPS_PROXY ftp_proxy FTP_PROXY"  
  1. Once done, save and exit by pressing Ctrl + X, Y, and Enter; don't change the proxy.tmp filename (this is normal for visudo; it will change it to proxy when finished).
  2. If prompted What now?, there is an error in the command. Press X to exit without saving and retype the command.
  3. After a reboot (using sudo reboot), you will be able to use the following commands to enable and disable the proxy respectively:
proxyenable
proxydisable  
It is important to use visudo here, as it ensures the permissions of the file are created correctly for the sudoers directory (read only by the root user).