ubunto|ubunto apt config proxy 配置代理或者运行在代理网络的环境下
2019独角兽企业重金招聘Python工程师标准>>>
文章图片
问题描述:
如果你是在主机 代理网络的环境下,并且客户端你有创建了虚拟机的Linux ,你会发现很多时候并不能在虚拟机下载更新软件。
比如:unbutu 下面apt-get update很多时候都是失败的。
解决方法:
对于ubuntu 可以采用如下方法。
1、在/etc/apt/文件夹下面新建立 apt.conf 文件
然后添加
ubuntu@ubuntu:~$ cat /etc/apt/apt.conf
Acquire::http::Proxy "http://Username:Password@proxy.xxx.xxx.xxx.xxx:8080";
说明:如果代理没有密码,可以不用写,直接如下。
Acquire::http::Proxy "http://proxy.xxx.xxx.xxx.xxx:8080";
2、配置环境变量
【ubunto|ubunto apt config proxy 配置代理或者运行在代理网络的环境下】在/etc/environment 中添加
export http_proxy=http://username:password@host:port/
export https_proxy=https://username:password@host:port/
3、然后运行sudo
sudo add-apt-repository XXX##如果有代理的情况下加不上可以 在不适用代理的网络里面加 比如guest网络
-E, --preserve-env
Indicates to the security policy that the user wishes to preserve their existing environment variables.The security
policy may return an error if the user does not have permission to preserve the environment.
add-apt-repository
adds a PPA to your list of sources, so that Ubuntu knows to look for updates from that PPA as well as from the official Ubuntu sources. Usually this is used to allow developers to provide updates more quickly than those in the official Ubuntu repositories.apt-get update
tells apt-get to update its database of what packages can be installed and where to install them from. In this case, apt-get will see your newly-added PPA and discover that ppa:maco.m/ruby has the newest version of rubygems that it knows about, so it will make a note to install rubygems from the PPA next time someone asks to install it.apt-get install
causes apt-get to find the package in its database and download and install the indicated file. In this case, it will find the rubygems package, download it from ppa:maco.m/ruby, and install it.实例:
更新 ubutu 的openjdk8 步骤如下:
可以参考http://ubuntuhandbook.org/index.php/2015/01/install-openjdk-8-ubuntu-14-04-12-04-lts/
sudo add-apt-repository ppa:openjdk-r/ppa ##
如果有代理的情况下加不上可以 在不适用代理的网络里面加 比如guest网络 下面 先加上这个
sudo apt-get update
sudo apt-get install openjdk-8-jdk
sudo update-alternatives --config java
##
如果你安装好了,对于你的系统中有多个jdk版本的话,需要运行。##enter the number for which JDK to use of your choice.
5. sudo update-alternatives --config javac
## 如果你安装好了,对于你的系统中有多个jdk版本的话,需要运行。
转载于:https://my.oschina.net/u/2308739/blog/657406
推荐阅读
- vue-cli|vue-cli 3.x vue.config.js 配置
- retrofit2-kotlin-coroutines-adapter|retrofit2-kotlin-coroutines-adapter 超时引起的崩溃
- 自定义MyAdapter
- java|java b2b2c shop 多用户商城系统源码- config 修改配置
- The|The Help week 3
- 词(apt)
- linux|apt update和apt upgrade命令 - 有什么区别()
- Mybatis|Mybatis Plus 分页插件
- 如梦似锦年|Chapter|如梦似锦年|Chapter 3 私人秘书
- 【弗朗特之门】Chapter.02-10