How to see the Current State of package (Ubuntu)?
Two commands can be used to see the current state of a package.
- dpkg
- dpkg-query
Let’s assume that the package vim is currently installed.
Current state of a package Using dpkg
dpkg –list can be used to know the status of a package.
$ dpkg --list vim Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Description +++-====================================-====================================-======================================================================================== ii vim 2:7.2.330-1ubuntu3 Vi IMproved - enhanced vi editor
As you can see the current state is ii. If you know how to interpret the status, you can be sure that the vim package is currently installed.
Let’s see the status of a package which is removed (configuration file is not removed)
$ dpkg --list usplash Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Description +++-====================================-====================================-======================================================================================== rc usplash 0.5.49 Userspace bootsplash utility
The state is rc, the package is removed, but the config files are not removed.
Current state of a package Using dpkg-query
Let’s explore more about a package using dpkg-query. dpkg-query gives more elaborate information about a package.
$ dpkg-query -s vim Package: vim Status: install ok installed Priority: optional Section: editors Installed-Size: 1672 Maintainer: Ubuntu DevelopersArchitecture: i386 Version: 2:7.2.330-1ubuntu3 Replaces: vim-common (<< 1:7.1-175+1) Provides: editor Depends: vim-common (= 2:7.2.330-1ubuntu3), vim-runtime (= 2:7.2.330-1ubuntu3), libacl1 (>= 2.2.11-1), libc6 (>= 2.11), libgpm2 (>= 1.20.4), libncurses5 (>= 5.6+20071006-3), libpython2.6 (>= 2.6), libselinux1 (>= 1.32) Suggests: ctags, vim-doc, vim-scripts Conflicts: vim-common (<< 1:7.1-175+1) Description: Vi IMproved - enhanced vi editor Vim is an almost compatible version of the UNIX editor Vi. . Many new features have been added: multi level undo, syntax highlighting, command line history, on-line help, filename completion, block operations, folding, Unicode support, etc. . This package contains a version of vim compiled with a rather standard set of features. This package does not provide a GUI version of Vim. See the other vim-* packages if you need more (or less). Homepage: http://www.vim.org/ Original-Maintainer: Debian Vim Maintainers
Our main focus of line is
Status: install ok installed
This clearly signifies that the package is installed. Let’s see an example for a status “rc”
$ dpkg-query -s usplash Package: usplash Status: deinstall ok config-files Priority: optional Section: misc Installed-Size: 220 Maintainer: Ubuntu Core DevelopersArchitecture: i386 Version: 0.5.49 Config-Version: 0.5.49 Depends: libc6 (>= 2.4), libusplash0 (>= 0.5.34), debconf (>= 0.5) | debconf-2.0, initramfs-tools (>= 0.92bubuntu50), upstart (>= 0.6.3-4) Recommends: usplash-theme-ubuntu | usplash-theme Breaks: gdm (<< 2.28.0-0ubuntu8), kdm (<< 4:4.3.1-0ubuntu14) Conffiles: /etc/console-tools/config.d/usplash 513c621bee5c1b6d3f6d87c5a60e214a /etc/kbd/config.d/usplash 513c621bee5c1b6d3f6d87c5a60e214a /etc/init/usplash.conf d10375f18e767272acfaef49bedc8752 Description: Userspace bootsplash utility Usplash is a userspace application that uses the Linux framebuffer interface to draw a splash screen at boot. It has a companion utility that is able to send commands to usplash, allowing information about the bootup sequence to be displayed in a more attractive way.
Let's focus on the line
Status: deinstall ok config-files
The files are marked for removal, but the config files are still present in the system. Refer status of packages.
Comments: