13.06.2017 · To check if packagename was installed, type: dpkg -s <packagename>. You can also use dpkg-query that has a neater output for your purpose, and accepts wild cards, too. dpkg-query -l <packagename>. To find what package owns the command, try: dpkg -S `which <command>`.
See Bash Pitfall 10. But, don't use which. It is a non-standard, external command that looks for a file in PATH. It behaves differently on different systems, and you can't really rely on a useful output or exit status. The shell already provides better ways of checking if a command exists and will work consistently on any system, so better ...
Jun 13, 2017 · To check if packagename was installed, type: dpkg -s <packagename>. You can also use dpkg-query that has a neater output for your purpose, and accepts wild cards, too. dpkg-query -l <packagename>. To find what package owns the command, try: dpkg -S `which <command>`.
11.10.2015 · I use the following code in my work called the Easy Bash, which helps install the most popular packages quicky on Ubuntu servers. This code will check the listed packages installed or not. #!/usr/bin/env bash packages= ("curl" "gnupg2" "ca-certificates" "lsb-release") for pkg in $ {packages [@]}; do is_pkg_installed=$ (dpkg-query -W ...
To check if a given package is installed in Debian / Ubuntu, type ... package not installed # to display list of all installed packages rpm -qa rpm -qa | ...
The dpkg -s command returns the status of installed packages. For example, on my system, if I run it for firefox which is installed and nedit which isn't, ...
See Bash FAQ 81. In this case though, you don't need to test if gimp exists, just running gimp -version, or querying dpkg about the version of the gimp package (see dpkg-query(1)), will already tell you whether it exists or not. if [ "$(gimp -version)" != 2.8 ]
May 22, 2018 · My objective is to only install this npm package if it's not already available. This continues to to execute even when I've installed the module globally. if [ npm list -g widdershins &> /...
19.12.2017 · Note that one single package can contain various commands. I'd say the most notable cases are coreutils and util-linux. So to check if a command or package is installed, you'd need to follow different approaches. For example (assuming a recent version of Bash): check_command () { local 'command' 'not_found' for command; do if ! type ...
Check if some apt packages are installed with dpkg -s and install them otherwise. See: Check if an apt-get package is installed and then install it if it's not on Linux. It was previously mentioned at: How can I check if a program exists from a Bash script? Share. Improve this answer. Follow edited Jan 16 '20 at 3:39. Peter ...
This command returns some human-readable output, but more importantly returns an exit status code; 0 indicates the package is installed, 1 indicates the package is not installed (does not check whether the package is valid, so yum list installed herpderp-beepbopboop will return a "1" just as yum list installed traceroute will if you don't have ...
Dec 19, 2017 · gnutls-dev is a single command/utility; libgnutls-dev is a package; Note that one single package can contain various commands. I'd say the most notable cases are coreutils and util-linux. So to check if a command or package is installed, you'd need to follow different approaches. For example (assuming a recent version of Bash):
If you install and remove a package, next you use dpkg-query package ; echo $? will be 0 also if the package is not installed. – Pol Hallen. Sep 22 '17 at 21:36.