Checking for installed packages and if not found install
check if a package installed
linux check if package is installed
check if a package is installed in bash
dnf check if package is installed
debian check if package is installed bash
python check if apt package is installed
check if sshpass is installed
I need to check for installed packages and if not installed install them.
Example for RHEL, CentOS, Fedora:
rpm -qa | grep glibc-static glibc-static-2.12-1.80.el6_3.5.i686
How do I do a check in BASH?
Do I do something like?
if [ "$(rpm -qa | grep glibc-static)" != "" ] ; then
And what do I need to use for other distributions? apt-get?
Try the following code :
if ! rpm -qa | grep -qw glibc-static; then yum install glibc-static fi
or shorter :
rpm -qa | grep -qw glibc-static || yum install glibc-static
For debian likes :
dpkg -l | grep -qw package || apt-get install package
For archlinux :
pacman -Qq | grep -qw package || pacman -S package
Install a list of packages only if they aren't already installed, apt-get will fairly silently skip over any package that is installed already so I'm not sure why it needs to get special treatment? ie: root@bun:~# apt-get -y install vlc I've found all solutions above can produce a false positive if a package is installed and then removed yet the installation package remains on the system. To replicate: Install package apt-get install curl Remove package apt-get remove curl. Now test above answers. The following command seems to solve this condition:
Based on @GillesQuenot and @Kidbulra answers, here's an example how to loop over multiple packages, and install if missing:
packageList="git gcc python-devel" for packageName in $packageList; do rpm --quiet --query $packageName || sudo yum install -y $packageName done
How To Find If A Package Is Installed Or Not In Linux And Unix, Find if a package is installed or not using “has” utility The “has” utility will check the presence of various command line tools on the path and also reports their installed version. Now check if a package is available or not like below. If you see the tick mark (✔), the package is installed. Check and list installed packages with yum command From the dnf/yum man page : The list command dumps lists of packages depending on the packages’ relation to the system. A package is installed if it is present in the RPMDB, and it is available if it is not installed but it is present in a repository that DNF knows about.
if [ $(yum list installed | cut -f1 -d" " | grep --extended '^full name of package being checked$' | wc -l) -eq 1 ]; then echo "installed"; else echo "missing" fi
I use this because it returns installed / missing without relying on an error state (which can cause problems in scripts taking a "no tolerance" approach to errors via
set -o errexit
How do I see what packages are installed on Ubuntu Linux?, How do you check if apt get package is installed? I need to check for installed packages and if not installed install them. Example for RHEL, CentOS, Fedora: rpm -qa | grep glibc-static glibc-static-2.12-1.80.el6_3.5.i686 How do I do a check i
If you are doing this against downloaded RPMs. you can do it by.
rpm -Uvh package-name-version-tag.rpm
How to check and list installed packages in CentOS Linux, How do you check if a yum package is installed? Though @maloneypatr function works fine, but it is quite silent and does not respond on success of packages loaded. I built below function that does make some checks on user entry and also respond on the number of packages being successfully installed.
How to Find Out if a Package is Installed on Linux or Not , How do you check if the package is installed in Linux? It will be slow when thousands of packages are installed, so do not use it to find out if a named package is installed (use find.package or system.file) nor to find out if a package is usable (call requireNamespace or require and check the return value) nor to find details of a small number of packages (use packageDescription ).
Installing & Updating Packages in R | NSF NEON, Explains how to list all installed packages on Linux based system using rpm, yum and dnf It is used to build, install, query, verify, update, and erase individual software Want to find out the installation date of a specific package, for example nginx, run: # rpm -q --last nginx package nginx is not installed Occasionally, you may want to check the packages installed on your system. In this article, I will demonstrate how list installed packages on Fedora. Yum package manager was used on Fedora 22 and its previous version, now (Fedora 27) we have dnf tool for package management.
Linux rpm List Installed Packages Command, How do I find out if a package installed on my Linux based system using the command line option? dpkg-query: package 'apache-perl' is not installed and no Package: sudo Status: install ok installed Priority: important Section: Check Debian/Ubuntu Linux package version using apt-get/aptitude In some cases, especially during manual installation of an update using standalone installer, you may need to first check if a specific update (a prerequisite update) is installed on your system. This article explains how to check if a specific Windows Update ( KBnnnnnn ) is installed in your computer or not.
- Why not just make them required by your packages and have the package manager deal with all that?
- It's just a simple bash install script to automate some things. :)
- Silent + only whole words, not just part of words
- Hi all, I was using this code in something else and found that this does not differentiate partial matches. in my case (RedHat) I had a package
file-libsinstalled but not
filewhich was what I wanted; when I put
rpm -qa | grep -qw file || yum install -y file, then
filedidn't install. The best solution is not to use
grepat all. Just use something like this:
rpm --quiet --query file || yum install -y file