知乎专栏 |
目录
包管理工具
apt 命令默认从cdrom安装
注释/etc/apt/sources.list中的deb cdrom项, apt会从互联网上安装
netkiller@Linux-server:~$ sudo vi /etc/apt/sources.list # deb cdrom:[Ubuntu-Server 6.10 _Edgy Eft_ - Release i386 (20061025.1)]/ edgy main restrictedapt-setup
安装是首先会下载包到/var/cache/apt/archives/目录
$ apt policy tcpdump tcpdump: Installed: 4.0.0-6ubuntu3 Candidate: 4.0.0-6ubuntu3 Version table: *** 4.0.0-6ubuntu3 0 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages 100 /var/lib/dpkg/status root@homeassistant:~# apt policy tcpdump tcpdump: Installed: (none) Candidate: 4.99.0-2+deb11u1 Version table: 4.99.3-1~bpo11+1 100 100 https://mirrors.tuna.tsinghua.edu.cn/debian bullseye-backports/main arm64 Packages 4.99.0-2+deb11u1 500 500 https://mirrors.tuna.tsinghua.edu.cn/debian bullseye/main arm64 Packages
neo@netkiller:~$ apt madison docker docker | 1.5-2 | http://mirrors.ustc.edu.cn/ubuntu cosmic/universe amd64 Packages docker | 1.5-2 | http://mirrors.ustc.edu.cn/ubuntu cosmic/universe i386 Packages
$ sudo apt install package
wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb apt install ./homeassistant-supervised.deb
root@homeassistant:~# apt list --installed Listing... Done adduser/oldstable,oldstable,now 3.118 all [installed] apparmor/oldstable,now 2.13.6-10 arm64 [installed] apt-transport-https/oldstable,oldstable,now 2.2.4 all [installed] apt-utils/oldstable,now 2.2.4 arm64 [installed] apt/oldstable,now 2.2.4 arm64 [installed] armbian-bsp-cli-rk3318-box/now 22.05.0-trunk arm64 [installed,upgradable to: 23.02.2] armbian-config/bullseye,bullseye,bullseye,now 23.02.2 all [installed] armbian-firmware/now 22.05.0-trunk all [installed,upgradable to: 23.02.2] base-files/now 11.1+deb11u3 arm64 [installed,upgradable to: 11.1+deb11u7] base-passwd/oldstable,now 3.5.51 arm64 [installed]
neo@netkiller ~ % apt list --upgradable Listing... Done dh-python/groovy,groovy 4.20200925 all [upgradable from: 4.20191017ubuntu7] iptables/groovy-updates 1.8.5-3ubuntu2.20.10.1 amd64 [upgradable from: 1.8.5-3ubuntu1] krb5-locales/groovy-updates,groovy-updates,groovy-security,groovy-security 1.17-10ubuntu0.1 all [upgradable from: 1.17-10] libgssapi-krb5-2/groovy-updates,groovy-security 1.17-10ubuntu0.1 amd64 [upgradable from: 1.17-10] libgssapi-krb5-2/groovy-updates,groovy-security 1.17-10ubuntu0.1 i386 [upgradable from: 1.17-10] libip4tc2/groovy-updates 1.8.5-3ubuntu2.20.10.1 amd64 [upgradable from: 1.8.5-3ubuntu1] libip6tc2/groovy-updates 1.8.5-3ubuntu2.20.10.1 amd64 [upgradable from: 1.8.5-3ubuntu1] libk5crypto3/groovy-updates,groovy-security 1.17-10ubuntu0.1 amd64 [upgradable from: 1.17-10] libk5crypto3/groovy-updates,groovy-security 1.17-10ubuntu0.1 i386 [upgradable from: 1.17-10] libkrb5-3/groovy-updates,groovy-security 1.17-10ubuntu0.1 amd64 [upgradable from: 1.17-10] libkrb5-3/groovy-updates,groovy-security 1.17-10ubuntu0.1 i386 [upgradable from: 1.17-10] libkrb5support0/groovy-updates,groovy-security 1.17-10ubuntu0.1 amd64 [upgradable from: 1.17-10] libkrb5support0/groovy-updates,groovy-security 1.17-10ubuntu0.1 i386 [upgradable from: 1.17-10] libldap-2.4-2/groovy-updates,groovy-security 2.4.53+dfsg-1ubuntu1.2 amd64 [upgradable from: 2.4.53+dfsg-1ubuntu1.1] libldap-common/groovy-updates,groovy-updates,groovy-security,groovy-security 2.4.53+dfsg-1ubuntu1.2 all [upgradable from: 2.4.53+dfsg-1ubuntu1.1] libxtables12/groovy-updates 1.8.5-3ubuntu2.20.10.1 amd64 [upgradable from: 1.8.5-3ubuntu1] linux-generic/groovy-updates 5.8.0.29.34 amd64 [upgradable from: 5.8.0.28.33] linux-headers-generic/groovy-updates 5.8.0.29.34 amd64 [upgradable from: 5.8.0.28.33] linux-image-generic/groovy-updates 5.8.0.29.34 amd64 [upgradable from: 5.8.0.28.33] linux-libc-dev/groovy-updates 5.8.0-29.31 amd64 [upgradable from: 5.8.0-28.30]
删除系统中的foo软件包
$ sudo apt remove foo
删除系统中的package软件包及其配置文件
$ sudo apt remove --purge package
sudo apt-get install unattended-upgrades
/etc/apt/apt.conf.d/50unattended-upgrades
Notifications
sudo apt-get install apticron
/etc/apticron/apticron.conf
EMAIL="root@example.com"
Ubuntu 16.04 升级到 16.10 过程中SSH中断 我猜测do-release-upgrade 一定会有恢复方案,应该是screen. 经过查看果然是 screen 开始尝试恢复screen 提示 neo@netkiller:~$ screen -ls No Sockets found in /var/run/screen/S-neo. 后来想到应该是root而不是当前用户,再次查看 neo@netkiller:~$ sudo screen -ls [sudo] password for neo: There is a screen on: 1955.ubuntu-release-upgrade-screen-window (11/25/2016 07:44:50 PM) (Detached) 1 Socket in /var/run/screen/S-root. 的确如猜测一样,现在回复窗口吧。 neo@netkiller:~$ sudo screen -r 1955 继续
备份 /etc/apt/sources.list 文件,然后覆盖即可
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 cp /etc/apt/sources.list /etc/apt/sources.list.backup cat > /etc/apt/sources.list << EOF 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 EOF
$ dpkg -L netkiller|more /. /opt /opt/neo /opt/neo/netkiller-1.0 /opt/neo/netkiller-1.0/linux /opt/neo/netkiller-1.0/linux/docbook.css /opt/neo/netkiller-1.0/linux/apas03.html /opt/neo/netkiller-1.0/linux/shell
$ sudo dpkg -l netkiller $ dpkg -l netkiller Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Description +++-==============-==============-============================================ un netkiller <none> (no description available)
系统上装了哪些软件包
要查看 Debian 系统上安装的所有软件包的状态, 运行 dpkg --list 输出每个软件包的一行简单介绍, 2字符的状态标志, 包名, 所安装版本, 和简要描述. 查看以 "foo" 开头的软件包的状态, 执行: dpkg --list 'foo*' 要得到某个软件包的更详细信息, 执行: dpkg --status packagename
List of installed software packages
$ dpkg-query -W
Description of installed software packages
$ dpkg -l
找出一个文件的归属包
dpkg --search cachemgr squid3-cgi: /usr/lib/cgi-bin/cachemgr3.cgi squid3-cgi: /usr/share/man/man8/cachemgr3.cgi.8.gz squid3-cgi: /etc/squid3/cachemgr.conf
$ dpkg -X dmd_2.057-0_amd64.deb dmd_2.057-0_amd64
$ dpkg -e dmd_2.057-0_amd64.deb $ find DEBIAN/ DEBIAN/ DEBIAN/conffiles DEBIAN/md5sum DEBIAN/control
在你的目录下创建DEBIAN目录与control文件
mkdir DEBIAN/ cat >> DEBIAN/control <<EOF Package: netkiller Version: 1.0-0 Architecture: amd64 Maintainer: Neo Chen <netkiller@msn.com> Installed-Size: 51196 Depends: libc6-dev, gcc, gcc-multilib, libc6 (>= 2.11), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.1.1) Section: devel Priority: optional Description: Netkiller ebook . Main designer: Neo Chen . Homepage: http://netkiller.github.com/ . EOF
$ dpkg -b dlang dlang.deb dpkg-deb: building package `netkiller' in `dlang.deb'. $ dpkg --info dlang.deb new debian package, version 2.0. size 263266 bytes: control archive= 371 bytes. 354 bytes, 14 lines control Package: netkiller Version: 1.0-0 Architecture: amd64 Maintainer: Neo Chen <netkiller@msn.com> Installed-Size: 51196 Depends: libc6-dev, gcc, gcc-multilib, libc6 (>= 2.11), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.1.1) Section: devel Priority: optional Description: Netkiller ebook . Main designer: Neo Chen . Homepage: http://netkiller.github.com/ . $ dpkg --contents dlang.deb drwxr-xr-x neo/neo 0 2012-02-06 11:22 ./ -rw-r--r-- neo/neo 144 2012-02-01 16:35 ./hello.lst -rwxr-xr-x neo/neo 321 2012-01-08 21:25 ./test.d -rw-r--r-- neo/neo 207 2012-02-01 15:57 ./d4py.d -rwxr-xr-x neo/neo 919366 2012-02-01 16:28 ./hello -rw-r--r-- neo/neo 6452 2012-02-01 16:28 ./hello.o -rwxr--r-- neo/neo 80 2012-01-08 21:28 ./hello.d
升级到最新开发版
$ sudo do-release-upgrade $ lsb_release -a
升级到最新开发版
vim /etc/update-manager/release-upgrades 文件,把里面的 Prompt=lts 改为 Prompt=normal
sudo do-release-upgrade -d
$ tar xxx.tar.gz $ cd xxx $ ./configure $ make
$ sudo apt-get install checkinstall
http://www.debian.org/doc/manuals/maint-guide/index.zh-cn.html
http://www.debian.org/doc/manuals/maint-guide/
Architecture: any | amd64 | i386 The generated binary package is an architecture dependent one usually in a compiled language.
Architecture: all The generated binary package is an architecture independent one usually consisting of text, images, or scripts in an interpreted language.