debian包管理
常用的包管理工具有:apt、apt-get、apt-cache、apt-file、aptitude、dpkg等。功能有重复的,挑顺手的即可。
1、apt
# apt --help
list - list packages based on package names
search - search in package descriptions
show - show package details
update - update list of available packages
install - install packages
remove - remove packages
upgrade - upgrade the system by installing/upgrading packages
full-upgrade - upgrade the system by removing/installing/upgrading packages
# apt search docker
Sorting... Done
Full Text Search... Done
docker/stable 1.5-1 amd64
System tray for KDE3/GNOME2 docklet applications
docker-ce/jessie,now 17.03.1~ce-0~debian-jessie amd64 [installed]
Docker: the open-source application container engine
karbon/stable 1:2.8.5+dfsg-1+b2 amd64
vector graphics application for the Calligra Suite
kdocker/stable 4.6-2 amd64
lets you dock any application into the system tray
python-docker/stable 0.5.3-1 all
Python wrapper to access docker.io's control socket
python3-docker/stable 0.5.3-1 all
Python 3 wrapper to access docker.io's control socket
ruby-docker-api/stable 1.10.10-1 all
Ruby gem to interact with docker.io remote API
vim-syntax-docker/now 1.6.2~dfsg1-1~bpo8+1 all [installed,local]
Docker container engine - Vim highlighting syntax files
# apt list docker
Listing... Done
docker/stable 1.5-1 amd64
# apt list docker-ce -a
Listing... Done
docker-ce/jessie,now 17.03.1~ce-0~debian-jessie amd64 [installed]
docker-ce/jessie 17.03.0~ce-0~debian-jessie amd64
2、apt-get
# apt-get --help
apt-get is a simple command line interface for downloading and installing packages.
The most frequently used commands are update and install.
update - Retrieve new lists of packages
upgrade - Perform an upgrade
install - Install new packages (pkg is libc6 not libc6.deb)
remove - Remove packages
autoremove - Remove automatically all unused packages
purge - Remove packages and config files
source - Download source archives
build-dep - Configure build-dependencies for source packages
dist-upgrade - Distribution upgrade, see apt-get(8)
dselect-upgrade - Follow dselect selections
clean - Erase downloaded archive files
autoclean - Erase old downloaded archive files
check - Verify that there are no broken dependencies
changelog - Download and display the changelog for the given package
download - Download the binary package into the current directory
-d Download only - do NOT install or unpack archives
-s No-act. Perform ordering simulation
-y Assume Yes to all queries and do not prompt
-f Attempt to correct a system with broken dependencies in place
3、apt-cache
# apt-cache --help
apt-cache is a low-level tool used to query information from APT's binary cache files
search - Search the package list for a regex pattern
show - Show a readable record for the package
# apt-cache search docker
karbon - vector graphics application for the Calligra Suite
docker - System tray for KDE3/GNOME2 docklet applications
kdocker - lets you dock any application into the system tray
python-docker - Python wrapper to access docker.io's control socket
python3-docker - Python 3 wrapper to access docker.io's control socket
ruby-docker-api - Ruby gem to interact with docker.io remote API
docker-ce - Docker: the open-source application container engine
vim-syntax-docker - Docker container engine - Vim highlighting syntax files
4、apt-file
# apt-file --help
update Fetch Contents files from apt-sources.
search|find <pattern> Search files in packages
list|show <pattern> List files in packages
purge Remove cache files
--ignore-case -i Ignore case distinctions
--package-only -l Only display packages name
--sources-list -s <file> sources.list location
查找命令或文件来自哪个package(包括已安装的和未安装的),dpkg -S 只会搜索已安装的package。
这里跟yum provides相比体验还是差了不少,这里匹配正则pattern,会列出所有包含关键字的文件,列出众多文件之后还需要过滤,而yum provides会直接列出包含文件的package。
# aptitude install apt-file 安装apt-file,默认没有安装
# apt-file update 更新索引
# apt-file find docker | grep docker$
ansible: /usr/share/ansible/cloud/docker
docker: /usr/bin/wmdocker
docker: /usr/share/menu/docker
docker-ce: /etc/bash_completion.d/docker
docker-ce: /etc/default/docker
docker-ce: /etc/init.d/docker
docker-ce: /usr/bin/docker
docker-ce: /usr/share/zsh/vendor-completions/_docker
kdocker: /etc/bash_completion.d/kdocker
kdocker: /usr/bin/kdocker
kdocker: /usr/share/menu/kdocker
zsh-common: /usr/share/zsh/functions/Completion/Linux/_docker
# apt-file find docker | grep dockerd$
docker-ce: /usr/bin/dockerd
5、aptitude
# aptitude --help
install - Install/upgrade packages.
remove - Remove packages.
purge - Remove packages and their configuration files.
forbid-version - Forbid aptitude from upgrading to a specific package version.
update - Download lists of new/upgradable packages.
safe-upgrade - Perform a safe upgrade.
full-upgrade - Perform an upgrade, possibly installing and removing packages.
search - Search for a package by name and/or expression.
show - Display detailed information about a package.
versions - Displays the versions of specified packages.
clean - Erase downloaded package files.
autoclean - Erase old downloaded package files.
changelog - View a package's changelog.
download - Download the .deb file for a package.
reinstall - Download and (possibly) reinstall a currently installed package.
-s Simulate actions, but do not actually perform them.
-d Only download packages, do not install or remove anything.
-P Always prompt for confirmation of actions.
-y Assume that the answer to simple yes/no questions is 'yes'.
-V Show which versions of packages are to be installed.
-v Display extra information. (may be supplied multiple times).
# aptitude search docker
p docker - System tray for KDE3/GNOME2 docklet applications
i docker-ce - Docker: the open-source application container engine
p kdocker - lets you dock any application into the system tray
p python-docker - Python wrapper to access docker.io's control socket
p python3-docker - Python 3 wrapper to access docker.io's control socket
p ruby-docker-api - Ruby gem to interact with docker.io remote API
i vim-syntax-docker - Docker container engine - Vim highlighting syntax files
# aptitude show docker-ce
Package: docker-ce
New: yes
State: installed
Automatically installed: no
Version: 17.03.1~ce-0~debian-jessie
Priority: optional
Section: admin
Maintainer: Docker <support@docker.com>
Architecture: amd64
Uncompressed Size: 87.8 M
Depends: iptables, init-system-helpers (>= 1.18~), libapparmor1 (>= 2.6~devel), libc6 (>= 2.17), libdevmapper1.02.1 (>= 2:1.02.90), libltdl7 (>= 2.4.2), libsystemd0
Recommends: aufs-tools, ca-certificates, cgroupfs-mount | cgroup-lite, git, xz-utils
Conflicts: docker (< 1.5~), docker-ee, docker-engine, docker-engine-cs, docker.io, lxc-docker, lxc-docker-virtual-package
Replaces: docker-engine
Description: Docker: the open-source application container engine
Docker is an open source project to build, ship and run any application as a lightweight container
Docker containers are both hardware-agnostic and platform-agnostic. This means they can run anywhere, from your laptop to the largest EC2 compute instance and everything in
between - and they don't require you to use a particular language, framework or packaging system. That makes them great building blocks for deploying and scaling web apps,
databases, and backend services without depending on a particular stack or provider.
Homepage: https://dockerproject.org
6、dpkg
# dpkg --help
-i|--install <.deb file name>
--unpack <.deb file name>
--configure <package>
--get-selections [<pattern> ...] Get list of selections to stdout.
-r|--remove <package> ...
-P|--purge <package> ...
-s|--status <package> ... Display package status details.
-p|--print-avail <package> ... Display available version details.
-L|--listfiles <package> ... List files `owned' by package(s).
-l|--list [<pattern> ...] List packages concisely. 列出所有已安装的软件包。
-S|--search <pattern> ... Find package(s) owning file(s). 查找文件的所属包。
--print-architecture Print dpkg architecture.
查看package包含的文件:
# dpkg -L tree
/.
/usr
/usr/bin
/usr/bin/tree
/usr/share
/usr/share/doc
/usr/share/doc/tree
/usr/share/doc/tree/copyright
/usr/share/doc/tree/TODO
/usr/share/doc/tree/changelog.Debian.gz
/usr/share/doc/tree/changelog.gz
/usr/share/doc/tree/README.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/tree.1.gz
查看package的详细信息,类似aptitude show和apt-cahce show。
# dpkg -s docker-ce
Package: docker-ce
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 85769
Maintainer: Docker <support@docker.com>
Architecture: amd64
Version: 17.03.1~ce-0~debian-jessie
Replaces: docker-engine
Depends: iptables, init-system-helpers (>= 1.18~), libapparmor1 (>= 2.6~devel), libc6 (>= 2.17), libdevmapper1.02.1 (>= 2:1.02.90), libltdl7 (>= 2.4.2), libsystemd0
Recommends: aufs-tools, ca-certificates, cgroupfs-mount | cgroup-lite, git, xz-utils
Conflicts: docker (<< 1.5~), docker-ee, docker-engine, docker-engine-cs, docker.io, lxc-docker, lxc-docker-virtual-package
Conffiles:
/etc/bash_completion.d/docker d005b0a5ba32208960d3baced35931d5
/etc/default/docker 82d6a44e99db1a3b74f7835e4f5e1b01
/etc/init.d/docker 4622ff202fe959c98f4fd993822424ab
/etc/init/docker.conf 123f7e2b4078fa11b4eecc4c4f9bdc25
Description: Docker: the open-source application container engine
Docker is an open source project to build, ship and run any application as a
lightweight container
.
Docker containers are both hardware-agnostic and platform-agnostic. This means
they can run anywhere, from your laptop to the largest EC2 compute instance and
everything in between - and they don't require you to use a particular
language, framework or packaging system. That makes them great building blocks
for deploying and scaling web apps, databases, and backend services without
depending on a particular stack or provider.
Homepage: https://dockerproject.org
7、dpkg-reconfigure 更改指定包的配置
比如,更改时区
# dpkg-reconfigure tzdata # 这里会跳出图形框,选择相应的时区即可
Current default time zone: 'Asia/Shanghai'
Local time is now: Sun Jun 18 11:29:19 CST 2017.
Universal Time is now: Sun Jun 18 03:29:19 UTC 2017.
8、debconf-show 查看指定包的当前配置
# debconf-show tzdata
* tzdata/Zones/Asia: Shanghai
tzdata/Zones/Australia:
tzdata/Zones/Pacific:
tzdata/Zones/Arctic:
tzdata/Zones/Europe:
tzdata/Zones/SystemV:
tzdata/Zones/Indian:
tzdata/Zones/Africa:
tzdata/Zones/US:
tzdata/Zones/Antarctica:
tzdata/Zones/Atlantic:
* tzdata/Zones/Etc: UTC
tzdata/Zones/America:
* tzdata/Areas: Asia
9、apt的配置文件
# apt-config --help
apt-config is a simple tool to read the APT config file.
用法:
apt-config [options] command
shell - Shell mode
dump - Show the configuration
查看当前配置
# apt-config dump
APT "";
APT::Architecture "amd64";
APT::Build-Essential "";
APT::Build-Essential:: "build-essential";
......
可以在 /etc/apt/apt.conf 中设置新的默认选项。
参考: