2021-11-01 Ubuntu软件包管理

软件源

        软件源在系统中的位置为:/etc/apt/sources.listsources.list文件即为软件源文件。

        cat /etc/apt/sources.list:查sources.list文件的内容。

# 查看"sources.list"文件
fu@fu-virtual-machine:~$ cat /etc/apt/sources.list
#deb cdrom:[Ubuntu 20.04.3 LTS _Focal Fossa_ - Release amd64 (20210819)]/ focal main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal main restricted
# ... 此后还有很多行

        sudo nano /etc/apt/sources.list:使用nano文编编辑器编辑sources.list文件。

软件包管理

        (1)本地软件包管理
        负责本地软件包管理的命令是:dpkg,该命令只能用于管理deb包。

        dpkg -i 应用程序的包:该命令会将你指定的应用程序安装到系统中。
        dpkg -l:该命令会列出所有的软件包(包括未安装的)。
        dpkg -r 软件包:改命令会将指定的软件卸载并删除软件包。

        (2)在线软件包管理

        apt-get命令:
        apt-get install 软件包:从软件园中获取并安装软件包
        apt-get update:同步本地软件包与软件源中的版本,一般来说,本地默认的软件包版本较低,需要同软件源中的软件包版本同步。
        apt-get update:更新所有软件包到最新版。(如果没有更新,第一种可能是因为没有执行apt-get update,第二种可能是系统中的软件包版本和软件源中的版本一样)
        apt-get autoremove 软件包:以对其他软件包危害最小的方式卸载并删除你指定的软件包。

 
        snap包管理工具:
        snap find 软件包:搜寻指定的软件包。
        snap list:列出当前系统中安装的软件包。
        snap refresh 软件包:更新指定的软件包,如果没有指定软件包,就更新所有的软件包。
        snap remove 软件包:删除指定的软件包。

编译源代码安装软件包

        (1)下载gcc编译工具:sudo apt-get install gcc
        (2)下载源码包:wget 连接
        (3)重命名并解压:tar -zxvf 压缩包
        (4)使用configure脚本生成Makefile文件:configure --prefix=安装目录
        (5)make命令编译:make
        (6)安装依赖
        (7)使用make安装:sudo make install

Guess you like

Origin blog.csdn.net/D___H/article/details/121080254