ubuntu 命令详解及使用技巧

仅作备忘录使用,陆续补充,勿喷

  1. ubuntu 源列表

    ubuntu 系统中维护着一个源列表,每一个网址就是一个源,地址指向的数据标识着这台源服务器有哪些软件可以安装
    
    源列表地址: /etc/apt/sources.list
    注释:#
    修改完 sources.list 后保存, 执行 sudo apt update 
  2. 更换国内源

    清华大学开源镜像库:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
    ① 查看版本      sudo lsb_release -a
    ② 选择 对应版本,例如 ubuntu 18.0.4 LTS
    ③ 备份配置文件  /etc/apt/sources.list
            sudo vim /etc/apt/sources.list
            # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
            deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
            # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
            deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
            # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
            deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
            # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
            deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
            # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    
            # 预发布软件源,不建议启用
            # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
            # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    ④ 退出保存,执行更新
        sudo apt update
  3. update 与 upgrade 的区别

    sudo apt update : 更新源列表文件,并保存到本地
    sudo apt upgrade : 根据本地软件,谨慎使用,避免系统更新
  4. 添加 apt 仓库

  5. 常用指令
    sudo apt list    // 查看所有软件列表
    sudo apt list  --upgradeable   // 查看所有可更新软件列表
    sudo apt autoremove  // 自动移除依赖
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章