知乎專欄 | 多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者” |
目錄
包管理工具
$ apt-cache 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
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/目錄
Searching a software package
$ apt-cache search package
列出軟件包的詳細信息:
$ apt-cache show package
列出軟件包的依賴關係:
$ apt-cache depends package
列出軟件包, 以及逆向依賴的軟件包的詳細版本信息:
$ apt-cache showpkg package
刪除系統中的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.