- 工作中常用命令
1.apt-file
The apt-file tool can list, and search for, individual files in the software packages used by APT. It’s similar to using dpkg -L, but apt-file can search all available packages, not just the ones already installed. It accomplishes this by maintaining a local cache of package contents.
Example1:
$ sudo apt install apt-file
$ sudo apt-file update && apt-file update //To update both the system-wide cache and your user cache.
$ sudo apt-file search chinime //search the file
org.deepin.chineseime: /opt/apps/org.deepin.chineseime/files/bin/chinime-hw
org.deepin.chineseime: /opt/apps/org.deepin.chineseime/files/bin/chinime-qim
org.deepin.chineseime: /opt/apps/org.deepin.chineseime/files/bin/chinime-sett
org.deepin.chineseime: /opt/apps/org.deepin.chineseime/files/bin/chinime-setw
org.deepin.chineseime: /opt/apps/org.deepin.chineseime/files/bin/chinime-spe-sym
Example2:
$ sudo apt-file list org.deepin.chineseime
2.APT upgrade 和 dist-upgrade 的差別
-
upgrade: 系統將現有的 Package 升級, 如果有相依性的問題, 而此相依性 需要安裝其它新的 Package 或 影響到其它 Package 的相依性時, 此 Package 就不會被升級, 會保留下來.
-
dist-upgrade: 可以聰明的解決相依性的問題, 如果有相依性問題, 需要 安裝/移除 新的 Package, 就會試著去 安裝/移除 它. (所以通常這個會被認為是有點風險的升級)
upgrade
upgrade is used to install the newest versions of all packages
currently installed on the system from the sources enumerated in
/etc/apt/sources.list. Packages currently installed with new
versions available are retrieved and upgraded; under no
circumstances are currently installed packages removed, or packages
not already installed retrieved and installed. New versions of
currently installed packages that cannot be upgraded without
changing the install status of another package will be left at
their current version. An update must be performed first so that
apt-get knows that new versions of packages are available.
dist-upgrade
dist-upgrade in addition to performing the function of upgrade,
also intelligently handles changing dependencies with new versions
of packages; apt-get has a "smart" conflict resolution system, and
it will attempt to upgrade the most important packages at the
expense of less important ones if necessary. So, dist-upgrade
command may remove some packages. The /etc/apt/sources.list file
contains a list of locations from which to retrieve desired package
files. See also apt_preferences(5) for a mechanism for overriding
the general settings for individual packages.
Basically upgrade will only upgrade existing packages from one version to another. It will not install or remove packages, even if doing so is required to upgrade others. In the case of kernel updates, upgrading the linux-generic package requires installing the new linux-3.0.0-13-generic package, and since upgrade refuses to install or remove packages, it refuses to upgrade linux-generic.
Sometimes various incompatibilities between packages will require some packages to be removed in order to upgrade others, and that will also require dist-upgrade. Kernel updates will always require dist-upgrade because of how they are handled. Rather than have a kernel package that gets updated, an entirely new kernel package is created each time, and the kernel metapackage is updated to depend on the new kernel package instead of the old. This was done so that you keep the old kernel versions around so that in case there is a problem with booting the new kernel, you can choose the old one from the boot menu and recover.
3.更新或升级操作:
apt-get update # 更新源
apt-get upgrade # 更新所有已安装的包
apt-get dist-upgrade # 发行版升级(如,从10.10到11.04)
4,安装或重装类操作:
apt-get install <pkg> # 安装软件包<pkg>,多个软件包用空格隔开
apt-get install --reinstall <pkg> # 重新安装软件包<pkg>
apt-get install -f <pkg> # 修复安装(破损的依赖关系)软件包<pkg>
5.卸载类操作:
apt-get remove <pkg> # 删除软件包<pkg>(不包括配置文件)
apt-get purge <pkg> # 删除软件包<pkg>(包括配置文件)
6.下载清除类操作:
apt-get source <pkg> # 下载pkg包的源代码到当前目录
apt-get download <pkg> # 下载pkg包的二进制包到当前目录
apt-get source -d <pkg> # 下载完源码包后,编译
apt-get build-dep <pkg> # 构建pkg源码包的依赖环境(编译环境?)
apt-get clean # 清除缓存(/var/cache/apt/archives/{,partial}下)中所有已下载的包
apt-get autoclean # 类似于clean,但清除的是缓存中过期的包(即已不能下载或者是无用的包)
apt-get autoremove # 删除因安装软件自动安装的依赖,而现在不需要的依赖包
7.查询类操作:
apt-cache stats # 显示系统软件包的统计信息
apt-cache search <pkg> # 使用关键字pkg搜索软件包
apt-cache show <pkg_name> # 显示软件包pkg_name的详细信息
apt-cache depends <pkg> # 查看pkg所依赖的软件包
apt-cache rdepends <pkg> # 查看pkg被那些软件包所依赖
refer to
- https://www.computerhope.com/unix/apt-file.htm