美文网首页
ubuntu源更换

ubuntu源更换

作者: 小线亮亮 | 来源:发表于2018-07-09 16:24 被阅读0次

    1.复制源文件备份,以防万一
    我们要修改的文件是sources.list,它在目录/etc/apt/下,sources.list是包管理工具apt所用的记录软件包仓库位置的配置文件,同样类型的还有位于 同目录下sources.list.d文件下的各种.list后缀的各文件。
    命令如下:
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

    2.查看新版本信息
    命令:lsb_release -c ,得到本系统的系统代号。
    删除原有内容,添加以下内容:
    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-backports main restricted universe multiverse

    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports 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

    3.更新软件列表

    运行如下命令:

    sudo apt-get update

    4.更新软件包

    运行如下命令:

    sudo apt-get upgrade

    5.ubuntu sudo update与upgrade的作用及区别
    在UBUNTU下,我们维护一个源列表,源列表里面都是一些网址信息,这每一条网址就是一个源,这个地址指向的数据标识着这台源服务器上有哪些软件可以安装使用。

    编辑源命令:

    sudo gedit /etc/apt/sources.list
    在这个文件里加入或者注释(加#)掉一些源后,保存。这时候,我们的源列表里指向的软件就会增加或减少一部分。
    获得最近的软件包的列表:(列表中包含一些包的信息,比如这个包是否更新过)

    sudo apt-get update
    这个命令,会访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。软件包管理器里看到的软件列表,都是通过update命令更新的。
    update后,可能需要upgrade一下。

    sudo apt-get upgrade
    这个命令,会把本地已安装的软件,与刚下载的软件列表里对应软件进行对比,如果发现已安装的软件版本太低,就会提示你更新。如果你的软件都是最新版本,会提示:
    升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。

    总而言之,update是更新软件列表,upgrade是更新软件。

    注解:一般在执行 sudo apt-get upgrade 命令之前需要先执行一下 sudo apt-get update ----其实和windows下的软件检测更新是一样的,需要更新的会帮你自动更新并安装好

    在线直接安装的命令

    sudo apt-get install 软件名称

    apt-get update 指令会同步使用者端和APT 伺服器的RPM 索引清单(package list),APT 伺服器的RPM 索引清单置于base 资料夹内,使用者端电脑取得base 资料夹内的bz2 RPM 索引清单压缩档后,会将其解压置放于/var/state/apt/lists/,而使用者使用apt-get install 或apt-get dist-upgrade 指令的时候,就会将这个资料夹内的资料和使用者端电脑内的RPM 资料库比对,如此一来就可以知道那些RPM 已安装、未安装、或是可以升级的。

    相关文章

      网友评论

          本文标题:ubuntu源更换

          本文链接:https://www.haomeiwen.com/subject/qpdtpftx.html