常用的包管理工具有: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 中设置新的默认选项。

最新文章

  1. [转]IE11下Forms身份认证无法保存Cookie的问题
  2. symfony中twig的流程控制if,for用法
  3. Oracle 跟踪事件 set event
  4. Xcode8 重新配置 CocoaPods -替换阿里源
  5. phpcms9添加301跳转
  6. 清华集训2014 day2 task1 简单回路
  7. BZOJ 3589 动态树 树链拆分+纳入和排除定理
  8. 201521123110 《Java程序设计》第9周学习总结
  9. linux下的Shell编程(5)循环
  10. [ZJOI2016]小星星
  11. Redis in .NET Core 入门:(5) Sorted SET
  12. [C#] LINQ之GroupBy
  13. java 查看线程的信息
  14. 使用PHPExcel实现数据批量导出为excel表格
  15. ASP.NET 实现多页面合并一页显示
  16. java开学考试感想及代码
  17. vue-cli 项目打包异常汇总
  18. 使用Composer管理PHP依赖关系
  19. spring属性注入
  20. codeforces 466C. Number of Ways 解题报告

热门文章

  1. 防csrf详解
  2. 从零开始的Python学习Episode 21——socket基础
  3. tensorflow-gpu与CUDA、CUDNN的版本问题
  4. jenkins部署时遇到“似乎无法联网”,导致无法安装默认插件的解决方案
  5. C++ Style Languages: C++, Objective-C, Java, C#
  6. js 基础拓展
  7. [2019BUAA软件工程]第0次个人作业
  8. 面向对象OO第15次作业总结
  9. RocEDU.阅读.写作选择书目
  10. 数据结构复习笔记(ADT栈/LIFO表)