zoukankan      html  css  js  c++  java
  • Linux

    参考:https://blog.csdn.net/wang_shen_tao/article/details/78676560#%E5%9C%A8ubuntu%E4%B8%8A%E6%9B%B4%E6%8D%A2%E6%B8%85%E5%8D%8E%E6%BA%90

    Linux两大主流 RPM 和 DPKG 介绍

    Linux 开发商先在固定的硬件平台与操作系统平台上面将需要安装或升级的软件编译好, 然后将这个软件的所有相关文件打包成为一个特殊格式的文件,

    在这个软件文件内还包含了预先侦测系统与相依软件的脚本, 并提供记载该软件提供的所有文件资讯等。最终将这个软件文件释出。

    用户端取得这个文件后,只要透过特定的命令来安装, 那么该软件文件就会依照内部的脚本来侦测相依的前驱软件是否存在,

    若安装的环境符合需求,那就会开始安装, 安装完成后还会将该软件的资讯写入软件管理机制中,以达成未来可以进行升级、移除等动作。

    目前在 Linux 界软件安装方式最常见的有2种,分别是

    • DPKG

      这个机制最早由 Debian Linux 社群所开发出来的,透过 dpkg 的机制, Debian 提供的软件就能够简单的安装起来,同时还能提供安装后的软件资讯,实在非常不错。

      只要是衍生於 Debian 的其他 Linux distributions 大多使用 dpkg 这个机制来管理软件的, 包括 B2D, Ubuntu 等等。

    • RPM

      这个机制最早是由 Red Hat 这家公司开发出来的,后来实在很好用,因此很多 distributions 就使用这个机制来作为软件安装的管理方式。

      包括 Fedora, CentOS, SuSE 等等知名的开发商都是用这。

    目前新的 Linux 开发商都有提供『线上升级』机制,透过这个机制, 原版光盘就只有第一次安装时需要用到而已,其他时候只要有网络,你就能够取得原本开发商所提供的任何软件了呢!

    在 dpkg 管理机制上就开发出 APT 的线上升级机制,RPM 则依开发商的不同,有 Red Hat 系统的 yum , SuSE 系统的 Yast Online Update (YOU)。

    distribution 代表 软件管理机制 使用命令 线上升级机制(命令)
    Red Hat/Fedora RPM rpm, rpmbuild YUM(yum)
    Debian/Ubuntu DPKG dpkg APT(apt-get)

    Linux换源

    因为在线安装需要在服务器上下载需要软件和依赖关系文件,所以下载的速度很影响使用体验。

    一般来说,Linux默认的源安装和更新速度很慢,所以安装好系统一般会选择换源。

    个人常用的源:

    清华源

    163源

    阿里云源

    下面分别举例在 Ubuntu16.04 和 Centos7 上如何换源

    1、在 Ubuntu16.04 上更换清华源

    Ubuntu 16.04的软件源配置文件是 /etc/apt/sources.list。

    将系统自带的该文件做个备份,将该文件替换为下面内容,即可使用 TUNA 的软件源镜像。(其他版本sourcelist 参看 网页)

    先备份在编辑

    1 mv /etc/apt/sources.list /etc/apt/sources.list.bakup
    2 sudo vim /etc/apt/sources.list
     1 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
     2 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
     3 # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
     4 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
     5 # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
     6 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
     7 # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
     8 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
     9 # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
    10 
    11 # 预发布软件源,不建议启用
    12 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
    13 # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

    访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。使用update命令更新。

    1 sudo apt-get update 

    2、在 Centos7 上更换 163 源(网易云源)

    Centos7的源文件是/etc/yum.repos.d/CentOS-Base.repo。同理先备份,然后再替换文件即可。

    首先备份

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

    再下载Centos,并且将其改成默认源文件

    1 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
    2 mv CentOS7-Base-163.repo /etc/yum.repos.d/CentOS-Base.repo 

    运行命令先清除缓存,再生成缓存

    1 yum clean all
    2 yum makecache

    3、在 Centos7 上更换阿里源

    备份操作同上

    下载适合当前系统的 Centos-Base.repo 到 /etc/yum.repos.d/

     1 CentOS 5
     2 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
     3 或者
     4 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
     5 CentOS 6
     6 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
     7 或者
     8 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
     9 CentOS 7
    10 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    11 或者
    12 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

    之后操作同上

     

    关于update和upgrade

    1、Ubuntu下

    sudo apt-get update

    这个命令,会访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。

    我们在新立得软件包管理器里看到的软件列表,都是通过update命令更新的。

    sudo apt-get upgrade

    这个命令,会把本地已安装的软件,与刚下载的软件列表里对应软件进行对比,如果发现已安装的软件版本太低,就会提示你更新。

    如果源里面有系统更新,直接给你把系统升级。有网友表示会导致原来软件无法使用。

    2、Centos下

    yum makecache

    等同于 sudo apt-get update

    yum -y update

    升级所有包,改变软件设置和系统设置,系统版本内核都升级。

    yum -y upgrade

    升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变。

    博客园文作者:Citrusliu 博文地址:https://www.cnblogs.com/citrus
  • 相关阅读:
    PHP 速度测试函数
    ajax的简单应用之快速入门
    PHP漏洞详解
    jQuery Ajax 实例 全解析
    2007年最后的一天
    近来心情格外的郁闷
    使用 Ajax 实现 lightbox
    GridView删除,编辑应用
    完美的wsus客户端注册表文件
    VISTA桌面显示Internet Explorer
  • 原文地址:https://www.cnblogs.com/citrus/p/13677917.html
Copyright © 2011-2022 走看看