linux操作系统基础之软件安装与卸载

文章目录

    • ubuntu
      • 1. 寻找国内镜像源
      • 2. 备份Ubuntu默认的源地址
      • 3. 更新源服务器列表
      • 4. 更新源
      • 5. Ubuntu软件操作的相关命令
      • 6. sudo apt-get update 更新源
    • Centos
      • 1、备份
      • 2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
      • CentOS 5
      • 3、之后运行yum makecache生成缓存
      • 相关链接
    • 阿里云很全的文档


ubuntu

所谓的镜像源:可以理解为提供下载软件的地方,比如Android手机上可以下载软件的91手机助手;iOS手机上可以下载软件的AppStore

1. 寻找国内镜像源

https://mirrors.ustc.edu.cn/
https://opsx.alibaba.com/mirror
https://mirrors.tuna.tsinghua.edu.cn/
http://mirrors.163.com/
总之一百度 一大堆 “国内镜像源”

2. 备份Ubuntu默认的源地址

修改阿里源为Ubuntu 18.04默认的源

备份/etc/apt/sources.list
#备份
cp /etc/apt/sources.list /etc/apt/sources.list.bak

在/etc/apt/sources.list文件前面添加如下条目

#添加阿里源

  • deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
  • deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
  • deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
  • deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
  • deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
  • deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
  • deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
  • deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
  • deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
  • deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

3. 更新源服务器列表

用阿里云举例
ubuntu
域名说明
对于阿里云ECS用户,可以直接使用内部域名访问,而对于非云用户则需要使用公网域名 mirrors.aliyun.com 来访问。

图形界面配置
新手推荐使用图形界面配置: 系统设置 -> 软件和更新 选择下载服务器 -> “mirrors.aliyun.com”

手动更改
用你熟悉的编辑器打开:

/etc/apt/sources.list

替换默认的

http://archive.ubuntu.com/

mirrors.aliyun.com

以Ubuntu 14.04.5 LTS为例,最后的效果如下:

deb https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

## Not recommended
# deb https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse

ubuntu 16.04 配置如下

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
ubuntu 18.04(bionic) 配置如下
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

参考链接
官方主页: http://www.ubuntu.com/
邮件列表: http://www.ubuntu.com/support/community/mailinglists
论坛: http://ubuntuforums.org/
中文论坛: http://forum.ubuntu.org.cn/
Wiki: https://wiki.ubuntu.com/
帮助: https://help.ubuntu.com/

4. 更新源

做完此步骤之后,就可以进行apt-get install 下载了

5. Ubuntu软件操作的相关命令

6. sudo apt-get update 更新源

- sudo apt-get install package 安装包
- sudo apt-get remove package 删除包
- sudo apt-cache search package 搜索软件包
- sudo apt-cache show package  获取包的相关信息,如说明、大小、版本等
- sudo apt-get install package --reinstall   重新安装包
- sudo apt-get -f install   修复安装
- sudo apt-get remove package --purge 删除包,包括配置文件等
- sudo apt-get build-dep package 安装相关的编译环境
- sudo apt-get upgrade 更新已安装的包
- sudo apt-get dist-upgrade 升级系统
- sudo apt-cache depends package 了解使用该包依赖那些包
- sudo apt-cache rdepends package 查看该包被哪些包依赖
- sudo apt-get source package  下载该包的源代码
- sudo apt-get clean && sudo apt-get autoclean 清理无用的包
- sudo apt-get check 检查是否有损坏的依赖

Centos

CentOS

1、备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、之后运行yum makecache生成缓存

相关链接

官方主页: http://www.centos.org/
邮件列表: http://www.centos.org/modules/tinycontent/index.php?id=16
论坛: http://www.centos.org/modules/newbb/
文档: http://www.centos.org/docs/
Wiki: http://wiki.centos.org/

阿里云很全的文档

访问这个网址
https://opsx.alibaba.com/mirror
linux操作系统基础之软件安装与卸载_第1张图片

linux操作系统基础之软件安装与卸载_第2张图片

你可能感兴趣的:(#,[,Linux,])