How to check if installed linux

How to find out if package is installed in Linux

Debian / Ubuntu Linux

Use dpkg command. It is a package manager for Debian/Ubuntu Linux. Suppose you want to find out package apache-perl or sudo is installed or not, type command:
$ dpkg -s apache-perl
Sample outputs:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Another example:
$ dpkg -s sudo
Sample outputs:

Use file /var/lib/dpkg/available to find out all package names available to you. Or you can use following command (list all packages in /var/lib/dpkg/status):
$ dpkg-query -l
You can also try to match package name using wild cards:
$ dpkg-query -l ‘libc6*’
Once you’ve found package name, use the following command to get exact status (whether it is installed or not):
$ dpkg-query -W -f=’$ $\n’ apache-perl
Sample outputs:

Red Hat Enterprise / Fedora Linux / Suse Linux / Cent OS

Under Red Hat/Fedora/CentOS/Suse Linux use the rpm command:
$ rpm -qa | grep For example find out package mutt installed or not:
$ rpm -qa | grep mutt
Output:

If you do not see or get any outputs (package name along with version), it means the package is not installed at all. You can display or list all installed packages with the following command:
$ rpm -qa
$ rpm -qa | less
You can conditionally do something if a rpm command succeeded or failed to find package using bash shell if command:

On a CentOS/RHEL version 6.x/7.x and above use the following yum command to tell whether a package named htop is installed:
$ yum list installed
$ yum list installed htop
Sample outputs:

If you are using Fedora Linux, try the following dnf command:
$ dnf list installed
$ dnf list installed htop

See also:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

This is my first massage over here& i hope i will get full support.

How to open usermap.cfg file on NetApp server?- As i have to check whether unix user login is mapped correctly with Windows login.

As the main problem which few of the users are having is as below —

They are NOT able to map from Windows any network
drive (unix accounts) due to they have not access to their share drive.

It ask me for login and password, BUT earliear it never asked me for my windows login and password . It’s been working till the end of the year 2006.

Please suggest solutions—–

Many thanks in Advance

just a small addition –

on Gentoo Linux just do a:

or
cat /var/lib/portage/world

on CentOS or other “yum”-based systems:

yum list installed

how to see the programs and features in redhat linux (e.g– in windows we can check the same through control panel–progrmas)

@john: On RedHat – which is a rpm package management based distribution – you should can use i.e.:

to list all installed packages or

to get out details about the installed package.

how do i verify packages that are installed without using rpm, i mean recently i installed squid using make, make all, configure configure-install

after this, how do I check this package is installed?

…this is not possible as installing “by hand” (make install) has nothing to do with a “package” nor package management.

To find out if i.e. squid was installed just try to locate the squid binary by where, locate or find, even if you build and install software from sources by make.

If you use a port management system from i.e. pkgsrc, getoo portage or even FreeBSD the port management counts each modified and installed file of a port to make it possible to see which file belongs to which port (package) or which are installed etc.

this might be another story.

Thank you very much, I have another issue, I have Installed texlive but I still get an error message in my crm ” pdf latex not installed”, so do you know how check if any software is installed or not ? It’s different from packages, isn’t it ?

If you have a list of packages you want to query, it’s much easier to just list them instead of using grep:

rpm -q automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel

Why such a complicated command for rpm-based systems? On my machine (Fedora 20), I can just run rpm -q $, and it’s *much* faster since it doesn’t need to list every package on the system and then grep through it:

[blong@blong-desktop tmp]$ rpm -q vala; echo $?
vala-0.22.1-1.fc20.x86_64
0
[blong@blong-desktop tmp]$ rpm -q missing-package; echo $?
package missing-package is not installed
1

Is this a new feature?

In Debian based distros like Ubuntu, you can find out if a package is installed with:

apacheInstalled=$(dpkg -s apache2 | grep ‘Status: install ok installed’| wc -l)
#change apache2 to the package you are checking for. returns 1 if installed, 0 otherwise.
#script does not have to be running as root… but to change installed stuff… it would.

Источник

How do I check if a package is installed on my server?

I recently installed Ubuntu Server edition 13.10 (Saucy Salamander). But I have run into a bit of problem.

At the end of the installation, it asks about several extra packages whether you want them or not, like OpenSSH server and virtual machine host. Here’s what I’m looking at:

Now, my problem is that I can’t remember if I have checked the «virtual machine host» checkbox. How do I check if my server has the corresponding packages?

What packages come with the virtual machine host?

, e.g. $ apt-cache policy dillo

13 Answers 13

Are you looking to know about all dpkg commands with options? Have a read from the below link.

To List all Installed Packages

Here less is a simple text reader used to scroll through the list of packages in a new buffer that opens in the existing terminal window. The list will not be mixed with other terminal commands and output. Hit q to return to the terminal prompt. See man less for more info.

To check whether a package is installed or not:

To check if the package is installed or not (for example, vlc ). If installed, launch the package:

Show the location where the package is installed. The -S (capital S) stands for «search»

To use Grep to search:

apt -qq list PACKAGE can also be used for checking whether the PACKAGE is installed.

If installed it’ll print something like (with [installed] at the end of the line):

If not installed the output will be:

This command is the Debian package manager.

You can list all the installed packages with

You can see details for a specific package with

And to learn if it is installed, use

You can learn which package contains the software you want with

In your case you should use this command to search the package name you want

to show detailed information about installed and installable versions of a package.

I’ve found a way to check for package installation with just dpkg-query command and no pipes.

I searched for such solution while writing a task for ansible playbook.

You can do something like this:

This is just one another way to do the thing.

Simpler solution:

There is now an apt list command that lists available packages, and the —installed command will show only installed packages. You can also search for a specific package with

Or to see only the matching installed packages

There are also the —upgradeable and —all-versions flags.

If you do not know the exact package name, you can use apt search followed by part of it to see a list of related packages. This will allow you to use a partial name or regex term(s) to filter a list of available packages, but it does not have the nifty flags for filtering that apt list has.

Also see man apt for more information.

, the —installed part is mandatory

I am writing a new answer as Tasksel ‘Task names’ DO NOT show up in dpkg or apt queries. Meaning the other answers are incomplete (or wrong).

«I can’t remember If I have checked the ‘virtual machine host’ checkbox..»

Check if there is an asterisk by the name after re-running sudo tasksel (or an ‘ i ‘ if running tasksel —list-tasks ).

If you do not see this, then you probably do not have the ‘tasksel meta-package’ installed.

«..How do I check if my server has the corresponding packages?»

If you want to find out what is installed under the Virtual Machine Host tasksel meta-package:

(in your case tasksel —list-tasks | grep virt is enough)

This gives the proper task name and an indication as to whether it is installed.

In your case this tasksel name is virt-host .

«What packages come with the virtual machine host?»

From the last command, find the tasksel task name. This is needed for the next command:

This lists the individual Tasksel meta-package (denoted by appended ‘^’) that make up the name. In your case it’s virt-host^ .

Once you find proper meta-name you can use apt:

(or apt-cache show . if apt show doesn’t work.)

This will show all packages making up the given meta package.

This will tell you if the individual package is installed/uninstalled (noted by 2nd letter: ‘i’ status means installed). Do this for all packages listed under the task/meta package.

This should answer the original questions.

Side note: /usr/share/tasksel/descs/ubuntu-tasks.desc also holds descriptions of Tasksel meta-packages. If you: grep «virt» /usr/share/tasksel/descs/ubuntu-tasks.desc it will show the proper APT meta-package name. (In your case this is ubuntu-virt-server ). You can also use apt commands with this meta-name.

If you are wanting to remove tasksel packages, this gets into the weeds a bit. Please consult this Ask Ubuntu answer or any number of other answers out there.

Please note that «meta» apt packages do not match Tasksel package names. Please consult the Tasksel Community Page for more info.

Источник

How to check if the package is installed on Linux

Published: March 15, 2017 | Modified: June 19, 2020

Learn to check if the package is installed on the Linux server or not. Verify if the package available on the server along with its installed date.

Package installation on Linux sometimes fails with error package is already installed; nothing to do . To avoid this you need to first check if the package is installed on system or not and then attempt its installation. In this article, we will be seeing different ways we can check if the package is installed on the server and also check its installation date.

Package management related reads :

Different ways to check if package is installed or not :

On RPM based system

RPM-based systems like Red Hat, CentOS, etc, we can use rpm query command like below :

We are using -qa i.e. query all options which will list all installed packages on the system. We are grepping out our desired (telnet in this example) package name. If the output is blank then the package is not installed. If it’s installed then the respective name will be shown (like above). To understand what these numbers in package name mean read package naming conventions.

Or even directly querying the package name will yield you the same result as the second example above.

If the system is configured with YUM then it can list all installed packages for you and you can grep out your desired package from it.

On APT based systems

APT based systems like Debian, Ubuntu, etc, dpkg command can be used to verify if the package is installed –

Column wise fields in output are Name, Version, Architecture, Description.

If you have an apt repository configured then you can try to install emulation of the desired package. If it’s installed then the respective message will be shown in output (highlighted line below). If it’s not installed then output just emulates installation process and exits without actually installing. –

Package installation date

One of the Linux interview questions is how to find the package installation date? or how to check when the package was installed in Linux? Answer is –

On YUM based systems

rpm command has a direct option of sorting packages with their installed date —last . Grep your desired package and you will get its installed date.

On APT based systems

Here there is no direct command which shows installation date. You have to grep ‘install’ word through installer log files /var/log/dpkg.log to get the installation date. If logrotate is configured on the system then use wild card * to search through all rotated and current log files.

If you observe this file does not exist on your server then install operation wasn’t performed on that system after its setup. On the very first install operation (using apt-get or dpkg ) this file will get created and start logging installation details.

Источник

Читайте также:  Восстановление стандартных иконок windows
Оцените статью