[英]How to set proxy for terminal in ubuntu?
My scenario:我的场景:
I am trying to install python and postgresql in my newly installed ubuntu which runs through virtualbox on windows 7. It uses my companys network and I have set the proxy in the network settings of ubuntu.我正在尝试在我新安装的 ubuntu 中安装 python 和 postgresql,它通过 Windows 7 上的 virtualbox 运行。它使用我公司的网络,并且我已经在 ubuntu 的网络设置中设置了代理。
I can browse and download using mozilla(ubuntu) with no problem.我可以毫无问题地使用 mozilla(ubuntu) 浏览和下载。
Problem:问题:
But when I try to install packages using terminal, it just stops at 0%.但是当我尝试使用终端安装软件包时,它只是停在 0% 处。 It tries various IP's, still at 0% my terminals screenshot它尝试了各种 IP,仍然是 0%我的终端屏幕截图
[update] - it ended in unable to connect to IP [更新] - 最终无法连接到 IP
Tried:尝试:
I have already tried export proxy settings through我已经尝试通过导出代理设置
sudo -H gedit /etc/profile.d/proxy.sh须藤 -H gedit /etc/profile.d/proxy.sh
and updated the file with并更新了文件
export http_proxy= http://username:password@proxyhost:port/导出 http_proxy= http://username:password@proxyhost:port/
(also I've set for https) (我也设置了 https)
Please let me know what's the problem going on ?请让我知道发生了什么问题?
This will be very simple .这将非常简单。 I have created a python 3 script for this我为此创建了一个 python 3 脚本
download it and run it .下载并运行它。 You can set and remove system wide proxy very quickly.您可以非常快速地设置和删除系统范围的代理。
steps: 1) Download in zip and extract it.步骤: 1) 以 zip 格式下载并解压缩。 2) open terminal and navigate to the folder where you have extracted the file. 2)打开终端并导航到您提取文件的文件夹。 3) type the following commands 3)输入以下命令
chmod +x proxy.py chmod +x 代理.py
sudo ./proxy.py须藤./proxy.py
cheers!.干杯!。
To Set Proxy in Ubuntu:在 Ubuntu 中设置代理:
Edit the /etc/apt/apt.conf file and add the following:编辑/etc/apt/apt.conf文件并添加以下内容:
Acquire::http::proxy "http://ProxyHOST:ProxyPORT/";
Acquire::https::proxy "https://ProxyHOST:ProxyPORT/";
Hope it Helps.. :)希望能帮助到你.. :)
Open Terminal Then go to directory /etc/apt/apt.conf.d using打开终端然后使用目录/etc/apt/apt.conf.d
cd /etc/apt/apt.conf.d
and then create a new file named proxy.conf with root privileges using然后使用 root 权限创建一个名为 proxy.conf 的新文件
sudo gedit proxy.conf
Now copy and paste the following现在复制并粘贴以下内容
Acquire::https::proxy "http://username:password@Port_ip:Port_Number/";
Acquire::ftp::proxy "ftp://username:password@Port ip:Port_Number/";
Be sure to replace Port_ip and Port Number with the one provided by your office or network administrator请务必将 Port_ip 和 Port Number 替换为您的办公室或网络管理员提供的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.