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












146















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



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



Enter image description here



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?










share|improve this question





























    146















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



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



    Enter image description here



    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?










    share|improve this question



























      146












      146








      146


      44






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



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



      Enter image description here



      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?










      share|improve this question
















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



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



      Enter image description here



      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?







      server package-management virtual






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 15 '17 at 19:05









      Peter Mortensen

      1,03721016




      1,03721016










      asked Feb 19 '14 at 21:12









      D.ZouD.Zou

      89321016




      89321016






















          8 Answers
          8






          active

          oldest

          votes


















          201














          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 terminal prompt. See "man less" for more info.



          dpkg -l | less


          To check whether a package is installed or not:



          dpkg -l {package_name}
          dpkg -l vlc


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



          dpkg -l | grep vlc


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



          sudo dpkg -S {package_name}
          sudo dpkg -S skype


          To use Grep to search:



          dpkg -l | grep {keywords}
          dpkg -l | grep pdf





          share|improve this answer





















          • 1





            What is the diference between this and dpkg-query -l "packagename"

            – heypaleblue
            May 24 '15 at 17:56






          • 4





            Do not depend on the exit code of dpkg -l packagename, as it might return with a 0 exit code even if the package is not fully installed - see: github.com/bitrise-io/bitrise/issues/433

            – Viktor Benei
            Oct 25 '16 at 18:08











          • dpkg -l | cut -d " " -f 3 | grep "^vlc" to show all package names that start with vlc

            – anatoly techtonik
            Apr 14 '17 at 18:49











          • FYI, this doesn't work for meta packages since they don't correlate directly to a dpkg. Your response does answer the question as asked though.

            – mtalexan
            Oct 11 '17 at 19:15



















          28














          Use dpkg



          This command is the debian package manager.



          You can list all the installed packages with



          dpkg -l


          You can see details for a specific package with



          dpkg -p packagename


          And to learn if it is installed ,use



          dpkg -s packagename | grep Status


          You can learn which package contains the software you want with



          apt-cache search name*  


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



          apt-cache search virtual machine host 





          share|improve this answer































            24














            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):



            $ apt -qq list awscli
            awscli/stable,now 1.4.2-1 all [installed]


            If not installed the output will be:



            $ apt -qq list awscli
            awscli/stable 1.4.2-1 all





            share|improve this answer





















            • 1





              You can put a star on the end of the package name for a wildcard.

              – Brannon
              Oct 22 '16 at 3:09






            • 2





              You can also use the --installed option for that command to limit to matches which are actually installed.

              – mtalexan
              Oct 11 '17 at 19:17






            • 2





              What's the -qq for? It seems to work identically without it, and that option isn't in the manual man apt

              – Gabriel Staples
              Mar 8 '18 at 0:09








            • 3





              @GabrielStaples It looks like the apt list command isn't yet fully documented. Some quick testing on 16.04 seems to indicate that -q is a synonym for --quiet option. The first -q prevents the word "Done" being printed. The second also prevents "Listing... " from being printed.

              – Anthony Geoghegan
              Apr 3 '18 at 11:39





















            13














            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.



            So, yo can do something like this:



            /usr/bin/dpkg-query --show --showformat='${db:Status-Status}n' '<your package name>'


            This is just one another way to do the thing.






            share|improve this answer


























            • pipes in ansible can be used with the shell module.

              – sjas
              Aug 27 '17 at 9:51



















            4














            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:



            tasksel --list-tasks



            (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:



            tasksel --task-packages virt-host



            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:



             apt show virt-host^ | grep "Package:"


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



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



            Then:



             dpkg -l {each individual pkg name listed above}


            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 https://askubuntu.com/a/88897/169878 or any number of other answers out there.



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






            share|improve this answer





















            • 1





              Both questions are answered correctly. If you downvote, give a reason, or tell me why they are not.

              – bshea
              Oct 23 '16 at 14:54



















            3














            Use tasksel (sudo apt-get install tasksel if you don't already have it) and run tasksel --list-tasks.



            tasksel will print out a list of the tasks, and there will be an i next to each task that is installed, and a u next to each task that is not installed.



            If you wish to install the task, use tasksel install <task>. The name of the task you are looking for is virt-host.



            The software selection items are called "tasks".






            share|improve this answer


























            • thanks for telling me the name of the task, that was one of my problems, wasn't sure which package to look for.

              – D.Zou
              Feb 20 '14 at 22:11



















            1














            Simpler solution:



            There is now an apt list command that lists installed packages. You can also search for a specific package with



            apt list <package>


            See man apt for more information. 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.






            share|improve this answer































              0














              If someone is interested, i created a little script with which you can automatically install from a list of packages or applications or simply check if they are already installed:



              #!/bin/bash
              apt -qq list YOUR_LIST_GOES_HERE | grep -v "installed" | awk -F/ '{print $1}' > /root/list.txt
              packages=$(cat /root/list.txt)
              grep -q '[^[:space:]]' < /root/list.txt
              CHECK_LIST=$?
              if [[ $CHECK_LIST -eq 1 ]]; then
              echo "Your packages are already installed"
              else
              echo "Installing packages"
              apt-get install -y $packages
              fi


              Hope it helps someone.






              share|improve this answer























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "89"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f423355%2fhow-do-i-check-if-a-package-is-installed-on-my-server%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                8 Answers
                8






                active

                oldest

                votes








                8 Answers
                8






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                201














                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 terminal prompt. See "man less" for more info.



                dpkg -l | less


                To check whether a package is installed or not:



                dpkg -l {package_name}
                dpkg -l vlc


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



                dpkg -l | grep vlc


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



                sudo dpkg -S {package_name}
                sudo dpkg -S skype


                To use Grep to search:



                dpkg -l | grep {keywords}
                dpkg -l | grep pdf





                share|improve this answer





















                • 1





                  What is the diference between this and dpkg-query -l "packagename"

                  – heypaleblue
                  May 24 '15 at 17:56






                • 4





                  Do not depend on the exit code of dpkg -l packagename, as it might return with a 0 exit code even if the package is not fully installed - see: github.com/bitrise-io/bitrise/issues/433

                  – Viktor Benei
                  Oct 25 '16 at 18:08











                • dpkg -l | cut -d " " -f 3 | grep "^vlc" to show all package names that start with vlc

                  – anatoly techtonik
                  Apr 14 '17 at 18:49











                • FYI, this doesn't work for meta packages since they don't correlate directly to a dpkg. Your response does answer the question as asked though.

                  – mtalexan
                  Oct 11 '17 at 19:15
















                201














                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 terminal prompt. See "man less" for more info.



                dpkg -l | less


                To check whether a package is installed or not:



                dpkg -l {package_name}
                dpkg -l vlc


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



                dpkg -l | grep vlc


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



                sudo dpkg -S {package_name}
                sudo dpkg -S skype


                To use Grep to search:



                dpkg -l | grep {keywords}
                dpkg -l | grep pdf





                share|improve this answer





















                • 1





                  What is the diference between this and dpkg-query -l "packagename"

                  – heypaleblue
                  May 24 '15 at 17:56






                • 4





                  Do not depend on the exit code of dpkg -l packagename, as it might return with a 0 exit code even if the package is not fully installed - see: github.com/bitrise-io/bitrise/issues/433

                  – Viktor Benei
                  Oct 25 '16 at 18:08











                • dpkg -l | cut -d " " -f 3 | grep "^vlc" to show all package names that start with vlc

                  – anatoly techtonik
                  Apr 14 '17 at 18:49











                • FYI, this doesn't work for meta packages since they don't correlate directly to a dpkg. Your response does answer the question as asked though.

                  – mtalexan
                  Oct 11 '17 at 19:15














                201












                201








                201







                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 terminal prompt. See "man less" for more info.



                dpkg -l | less


                To check whether a package is installed or not:



                dpkg -l {package_name}
                dpkg -l vlc


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



                dpkg -l | grep vlc


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



                sudo dpkg -S {package_name}
                sudo dpkg -S skype


                To use Grep to search:



                dpkg -l | grep {keywords}
                dpkg -l | grep pdf





                share|improve this answer















                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 terminal prompt. See "man less" for more info.



                dpkg -l | less


                To check whether a package is installed or not:



                dpkg -l {package_name}
                dpkg -l vlc


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



                dpkg -l | grep vlc


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



                sudo dpkg -S {package_name}
                sudo dpkg -S skype


                To use Grep to search:



                dpkg -l | grep {keywords}
                dpkg -l | grep pdf






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Aug 30 '15 at 8:47









                Jürgen Paul

                5874914




                5874914










                answered Feb 20 '14 at 9:12









                Babin LonstonBabin Lonston

                4,11011723




                4,11011723








                • 1





                  What is the diference between this and dpkg-query -l "packagename"

                  – heypaleblue
                  May 24 '15 at 17:56






                • 4





                  Do not depend on the exit code of dpkg -l packagename, as it might return with a 0 exit code even if the package is not fully installed - see: github.com/bitrise-io/bitrise/issues/433

                  – Viktor Benei
                  Oct 25 '16 at 18:08











                • dpkg -l | cut -d " " -f 3 | grep "^vlc" to show all package names that start with vlc

                  – anatoly techtonik
                  Apr 14 '17 at 18:49











                • FYI, this doesn't work for meta packages since they don't correlate directly to a dpkg. Your response does answer the question as asked though.

                  – mtalexan
                  Oct 11 '17 at 19:15














                • 1





                  What is the diference between this and dpkg-query -l "packagename"

                  – heypaleblue
                  May 24 '15 at 17:56






                • 4





                  Do not depend on the exit code of dpkg -l packagename, as it might return with a 0 exit code even if the package is not fully installed - see: github.com/bitrise-io/bitrise/issues/433

                  – Viktor Benei
                  Oct 25 '16 at 18:08











                • dpkg -l | cut -d " " -f 3 | grep "^vlc" to show all package names that start with vlc

                  – anatoly techtonik
                  Apr 14 '17 at 18:49











                • FYI, this doesn't work for meta packages since they don't correlate directly to a dpkg. Your response does answer the question as asked though.

                  – mtalexan
                  Oct 11 '17 at 19:15








                1




                1





                What is the diference between this and dpkg-query -l "packagename"

                – heypaleblue
                May 24 '15 at 17:56





                What is the diference between this and dpkg-query -l "packagename"

                – heypaleblue
                May 24 '15 at 17:56




                4




                4





                Do not depend on the exit code of dpkg -l packagename, as it might return with a 0 exit code even if the package is not fully installed - see: github.com/bitrise-io/bitrise/issues/433

                – Viktor Benei
                Oct 25 '16 at 18:08





                Do not depend on the exit code of dpkg -l packagename, as it might return with a 0 exit code even if the package is not fully installed - see: github.com/bitrise-io/bitrise/issues/433

                – Viktor Benei
                Oct 25 '16 at 18:08













                dpkg -l | cut -d " " -f 3 | grep "^vlc" to show all package names that start with vlc

                – anatoly techtonik
                Apr 14 '17 at 18:49





                dpkg -l | cut -d " " -f 3 | grep "^vlc" to show all package names that start with vlc

                – anatoly techtonik
                Apr 14 '17 at 18:49













                FYI, this doesn't work for meta packages since they don't correlate directly to a dpkg. Your response does answer the question as asked though.

                – mtalexan
                Oct 11 '17 at 19:15





                FYI, this doesn't work for meta packages since they don't correlate directly to a dpkg. Your response does answer the question as asked though.

                – mtalexan
                Oct 11 '17 at 19:15













                28














                Use dpkg



                This command is the debian package manager.



                You can list all the installed packages with



                dpkg -l


                You can see details for a specific package with



                dpkg -p packagename


                And to learn if it is installed ,use



                dpkg -s packagename | grep Status


                You can learn which package contains the software you want with



                apt-cache search name*  


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



                apt-cache search virtual machine host 





                share|improve this answer




























                  28














                  Use dpkg



                  This command is the debian package manager.



                  You can list all the installed packages with



                  dpkg -l


                  You can see details for a specific package with



                  dpkg -p packagename


                  And to learn if it is installed ,use



                  dpkg -s packagename | grep Status


                  You can learn which package contains the software you want with



                  apt-cache search name*  


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



                  apt-cache search virtual machine host 





                  share|improve this answer


























                    28












                    28








                    28







                    Use dpkg



                    This command is the debian package manager.



                    You can list all the installed packages with



                    dpkg -l


                    You can see details for a specific package with



                    dpkg -p packagename


                    And to learn if it is installed ,use



                    dpkg -s packagename | grep Status


                    You can learn which package contains the software you want with



                    apt-cache search name*  


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



                    apt-cache search virtual machine host 





                    share|improve this answer













                    Use dpkg



                    This command is the debian package manager.



                    You can list all the installed packages with



                    dpkg -l


                    You can see details for a specific package with



                    dpkg -p packagename


                    And to learn if it is installed ,use



                    dpkg -s packagename | grep Status


                    You can learn which package contains the software you want with



                    apt-cache search name*  


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



                    apt-cache search virtual machine host 






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 20 '14 at 9:10









                    onurbekirogluonurbekiroglu

                    55145




                    55145























                        24














                        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):



                        $ apt -qq list awscli
                        awscli/stable,now 1.4.2-1 all [installed]


                        If not installed the output will be:



                        $ apt -qq list awscli
                        awscli/stable 1.4.2-1 all





                        share|improve this answer





















                        • 1





                          You can put a star on the end of the package name for a wildcard.

                          – Brannon
                          Oct 22 '16 at 3:09






                        • 2





                          You can also use the --installed option for that command to limit to matches which are actually installed.

                          – mtalexan
                          Oct 11 '17 at 19:17






                        • 2





                          What's the -qq for? It seems to work identically without it, and that option isn't in the manual man apt

                          – Gabriel Staples
                          Mar 8 '18 at 0:09








                        • 3





                          @GabrielStaples It looks like the apt list command isn't yet fully documented. Some quick testing on 16.04 seems to indicate that -q is a synonym for --quiet option. The first -q prevents the word "Done" being printed. The second also prevents "Listing... " from being printed.

                          – Anthony Geoghegan
                          Apr 3 '18 at 11:39


















                        24














                        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):



                        $ apt -qq list awscli
                        awscli/stable,now 1.4.2-1 all [installed]


                        If not installed the output will be:



                        $ apt -qq list awscli
                        awscli/stable 1.4.2-1 all





                        share|improve this answer





















                        • 1





                          You can put a star on the end of the package name for a wildcard.

                          – Brannon
                          Oct 22 '16 at 3:09






                        • 2





                          You can also use the --installed option for that command to limit to matches which are actually installed.

                          – mtalexan
                          Oct 11 '17 at 19:17






                        • 2





                          What's the -qq for? It seems to work identically without it, and that option isn't in the manual man apt

                          – Gabriel Staples
                          Mar 8 '18 at 0:09








                        • 3





                          @GabrielStaples It looks like the apt list command isn't yet fully documented. Some quick testing on 16.04 seems to indicate that -q is a synonym for --quiet option. The first -q prevents the word "Done" being printed. The second also prevents "Listing... " from being printed.

                          – Anthony Geoghegan
                          Apr 3 '18 at 11:39
















                        24












                        24








                        24







                        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):



                        $ apt -qq list awscli
                        awscli/stable,now 1.4.2-1 all [installed]


                        If not installed the output will be:



                        $ apt -qq list awscli
                        awscli/stable 1.4.2-1 all





                        share|improve this answer















                        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):



                        $ apt -qq list awscli
                        awscli/stable,now 1.4.2-1 all [installed]


                        If not installed the output will be:



                        $ apt -qq list awscli
                        awscli/stable 1.4.2-1 all






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Oct 23 '16 at 15:01









                        muru

                        1




                        1










                        answered Sep 11 '16 at 13:54









                        Viktor BeneiViktor Benei

                        34124




                        34124








                        • 1





                          You can put a star on the end of the package name for a wildcard.

                          – Brannon
                          Oct 22 '16 at 3:09






                        • 2





                          You can also use the --installed option for that command to limit to matches which are actually installed.

                          – mtalexan
                          Oct 11 '17 at 19:17






                        • 2





                          What's the -qq for? It seems to work identically without it, and that option isn't in the manual man apt

                          – Gabriel Staples
                          Mar 8 '18 at 0:09








                        • 3





                          @GabrielStaples It looks like the apt list command isn't yet fully documented. Some quick testing on 16.04 seems to indicate that -q is a synonym for --quiet option. The first -q prevents the word "Done" being printed. The second also prevents "Listing... " from being printed.

                          – Anthony Geoghegan
                          Apr 3 '18 at 11:39
















                        • 1





                          You can put a star on the end of the package name for a wildcard.

                          – Brannon
                          Oct 22 '16 at 3:09






                        • 2





                          You can also use the --installed option for that command to limit to matches which are actually installed.

                          – mtalexan
                          Oct 11 '17 at 19:17






                        • 2





                          What's the -qq for? It seems to work identically without it, and that option isn't in the manual man apt

                          – Gabriel Staples
                          Mar 8 '18 at 0:09








                        • 3





                          @GabrielStaples It looks like the apt list command isn't yet fully documented. Some quick testing on 16.04 seems to indicate that -q is a synonym for --quiet option. The first -q prevents the word "Done" being printed. The second also prevents "Listing... " from being printed.

                          – Anthony Geoghegan
                          Apr 3 '18 at 11:39










                        1




                        1





                        You can put a star on the end of the package name for a wildcard.

                        – Brannon
                        Oct 22 '16 at 3:09





                        You can put a star on the end of the package name for a wildcard.

                        – Brannon
                        Oct 22 '16 at 3:09




                        2




                        2





                        You can also use the --installed option for that command to limit to matches which are actually installed.

                        – mtalexan
                        Oct 11 '17 at 19:17





                        You can also use the --installed option for that command to limit to matches which are actually installed.

                        – mtalexan
                        Oct 11 '17 at 19:17




                        2




                        2





                        What's the -qq for? It seems to work identically without it, and that option isn't in the manual man apt

                        – Gabriel Staples
                        Mar 8 '18 at 0:09







                        What's the -qq for? It seems to work identically without it, and that option isn't in the manual man apt

                        – Gabriel Staples
                        Mar 8 '18 at 0:09






                        3




                        3





                        @GabrielStaples It looks like the apt list command isn't yet fully documented. Some quick testing on 16.04 seems to indicate that -q is a synonym for --quiet option. The first -q prevents the word "Done" being printed. The second also prevents "Listing... " from being printed.

                        – Anthony Geoghegan
                        Apr 3 '18 at 11:39







                        @GabrielStaples It looks like the apt list command isn't yet fully documented. Some quick testing on 16.04 seems to indicate that -q is a synonym for --quiet option. The first -q prevents the word "Done" being printed. The second also prevents "Listing... " from being printed.

                        – Anthony Geoghegan
                        Apr 3 '18 at 11:39













                        13














                        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.



                        So, yo can do something like this:



                        /usr/bin/dpkg-query --show --showformat='${db:Status-Status}n' '<your package name>'


                        This is just one another way to do the thing.






                        share|improve this answer


























                        • pipes in ansible can be used with the shell module.

                          – sjas
                          Aug 27 '17 at 9:51
















                        13














                        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.



                        So, yo can do something like this:



                        /usr/bin/dpkg-query --show --showformat='${db:Status-Status}n' '<your package name>'


                        This is just one another way to do the thing.






                        share|improve this answer


























                        • pipes in ansible can be used with the shell module.

                          – sjas
                          Aug 27 '17 at 9:51














                        13












                        13








                        13







                        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.



                        So, yo can do something like this:



                        /usr/bin/dpkg-query --show --showformat='${db:Status-Status}n' '<your package name>'


                        This is just one another way to do the thing.






                        share|improve this answer















                        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.



                        So, yo can do something like this:



                        /usr/bin/dpkg-query --show --showformat='${db:Status-Status}n' '<your package name>'


                        This is just one another way to do the thing.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Aug 4 '16 at 14:37









                        Community

                        1




                        1










                        answered Sep 1 '15 at 19:47









                        DenKorenDenKoren

                        13112




                        13112













                        • pipes in ansible can be used with the shell module.

                          – sjas
                          Aug 27 '17 at 9:51



















                        • pipes in ansible can be used with the shell module.

                          – sjas
                          Aug 27 '17 at 9:51

















                        pipes in ansible can be used with the shell module.

                        – sjas
                        Aug 27 '17 at 9:51





                        pipes in ansible can be used with the shell module.

                        – sjas
                        Aug 27 '17 at 9:51











                        4














                        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:



                        tasksel --list-tasks



                        (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:



                        tasksel --task-packages virt-host



                        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:



                         apt show virt-host^ | grep "Package:"


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



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



                        Then:



                         dpkg -l {each individual pkg name listed above}


                        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 https://askubuntu.com/a/88897/169878 or any number of other answers out there.



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






                        share|improve this answer





















                        • 1





                          Both questions are answered correctly. If you downvote, give a reason, or tell me why they are not.

                          – bshea
                          Oct 23 '16 at 14:54
















                        4














                        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:



                        tasksel --list-tasks



                        (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:



                        tasksel --task-packages virt-host



                        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:



                         apt show virt-host^ | grep "Package:"


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



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



                        Then:



                         dpkg -l {each individual pkg name listed above}


                        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 https://askubuntu.com/a/88897/169878 or any number of other answers out there.



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






                        share|improve this answer





















                        • 1





                          Both questions are answered correctly. If you downvote, give a reason, or tell me why they are not.

                          – bshea
                          Oct 23 '16 at 14:54














                        4












                        4








                        4







                        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:



                        tasksel --list-tasks



                        (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:



                        tasksel --task-packages virt-host



                        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:



                         apt show virt-host^ | grep "Package:"


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



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



                        Then:



                         dpkg -l {each individual pkg name listed above}


                        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 https://askubuntu.com/a/88897/169878 or any number of other answers out there.



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






                        share|improve this answer















                        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:



                        tasksel --list-tasks



                        (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:



                        tasksel --task-packages virt-host



                        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:



                         apt show virt-host^ | grep "Package:"


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



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



                        Then:



                         dpkg -l {each individual pkg name listed above}


                        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 https://askubuntu.com/a/88897/169878 or any number of other answers out there.



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







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jun 28 '18 at 20:49

























                        answered Oct 19 '16 at 15:17









                        bsheabshea

                        44738




                        44738








                        • 1





                          Both questions are answered correctly. If you downvote, give a reason, or tell me why they are not.

                          – bshea
                          Oct 23 '16 at 14:54














                        • 1





                          Both questions are answered correctly. If you downvote, give a reason, or tell me why they are not.

                          – bshea
                          Oct 23 '16 at 14:54








                        1




                        1





                        Both questions are answered correctly. If you downvote, give a reason, or tell me why they are not.

                        – bshea
                        Oct 23 '16 at 14:54





                        Both questions are answered correctly. If you downvote, give a reason, or tell me why they are not.

                        – bshea
                        Oct 23 '16 at 14:54











                        3














                        Use tasksel (sudo apt-get install tasksel if you don't already have it) and run tasksel --list-tasks.



                        tasksel will print out a list of the tasks, and there will be an i next to each task that is installed, and a u next to each task that is not installed.



                        If you wish to install the task, use tasksel install <task>. The name of the task you are looking for is virt-host.



                        The software selection items are called "tasks".






                        share|improve this answer


























                        • thanks for telling me the name of the task, that was one of my problems, wasn't sure which package to look for.

                          – D.Zou
                          Feb 20 '14 at 22:11
















                        3














                        Use tasksel (sudo apt-get install tasksel if you don't already have it) and run tasksel --list-tasks.



                        tasksel will print out a list of the tasks, and there will be an i next to each task that is installed, and a u next to each task that is not installed.



                        If you wish to install the task, use tasksel install <task>. The name of the task you are looking for is virt-host.



                        The software selection items are called "tasks".






                        share|improve this answer


























                        • thanks for telling me the name of the task, that was one of my problems, wasn't sure which package to look for.

                          – D.Zou
                          Feb 20 '14 at 22:11














                        3












                        3








                        3







                        Use tasksel (sudo apt-get install tasksel if you don't already have it) and run tasksel --list-tasks.



                        tasksel will print out a list of the tasks, and there will be an i next to each task that is installed, and a u next to each task that is not installed.



                        If you wish to install the task, use tasksel install <task>. The name of the task you are looking for is virt-host.



                        The software selection items are called "tasks".






                        share|improve this answer















                        Use tasksel (sudo apt-get install tasksel if you don't already have it) and run tasksel --list-tasks.



                        tasksel will print out a list of the tasks, and there will be an i next to each task that is installed, and a u next to each task that is not installed.



                        If you wish to install the task, use tasksel install <task>. The name of the task you are looking for is virt-host.



                        The software selection items are called "tasks".







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Oct 23 '16 at 15:01









                        muru

                        1




                        1










                        answered Feb 19 '14 at 21:31









                        Blake RBlake R

                        1191




                        1191













                        • thanks for telling me the name of the task, that was one of my problems, wasn't sure which package to look for.

                          – D.Zou
                          Feb 20 '14 at 22:11



















                        • thanks for telling me the name of the task, that was one of my problems, wasn't sure which package to look for.

                          – D.Zou
                          Feb 20 '14 at 22:11

















                        thanks for telling me the name of the task, that was one of my problems, wasn't sure which package to look for.

                        – D.Zou
                        Feb 20 '14 at 22:11





                        thanks for telling me the name of the task, that was one of my problems, wasn't sure which package to look for.

                        – D.Zou
                        Feb 20 '14 at 22:11











                        1














                        Simpler solution:



                        There is now an apt list command that lists installed packages. You can also search for a specific package with



                        apt list <package>


                        See man apt for more information. 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.






                        share|improve this answer




























                          1














                          Simpler solution:



                          There is now an apt list command that lists installed packages. You can also search for a specific package with



                          apt list <package>


                          See man apt for more information. 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.






                          share|improve this answer


























                            1












                            1








                            1







                            Simpler solution:



                            There is now an apt list command that lists installed packages. You can also search for a specific package with



                            apt list <package>


                            See man apt for more information. 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.






                            share|improve this answer













                            Simpler solution:



                            There is now an apt list command that lists installed packages. You can also search for a specific package with



                            apt list <package>


                            See man apt for more information. 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.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 25 at 0:32









                            sk8forethersk8forether

                            335




                            335























                                0














                                If someone is interested, i created a little script with which you can automatically install from a list of packages or applications or simply check if they are already installed:



                                #!/bin/bash
                                apt -qq list YOUR_LIST_GOES_HERE | grep -v "installed" | awk -F/ '{print $1}' > /root/list.txt
                                packages=$(cat /root/list.txt)
                                grep -q '[^[:space:]]' < /root/list.txt
                                CHECK_LIST=$?
                                if [[ $CHECK_LIST -eq 1 ]]; then
                                echo "Your packages are already installed"
                                else
                                echo "Installing packages"
                                apt-get install -y $packages
                                fi


                                Hope it helps someone.






                                share|improve this answer




























                                  0














                                  If someone is interested, i created a little script with which you can automatically install from a list of packages or applications or simply check if they are already installed:



                                  #!/bin/bash
                                  apt -qq list YOUR_LIST_GOES_HERE | grep -v "installed" | awk -F/ '{print $1}' > /root/list.txt
                                  packages=$(cat /root/list.txt)
                                  grep -q '[^[:space:]]' < /root/list.txt
                                  CHECK_LIST=$?
                                  if [[ $CHECK_LIST -eq 1 ]]; then
                                  echo "Your packages are already installed"
                                  else
                                  echo "Installing packages"
                                  apt-get install -y $packages
                                  fi


                                  Hope it helps someone.






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    If someone is interested, i created a little script with which you can automatically install from a list of packages or applications or simply check if they are already installed:



                                    #!/bin/bash
                                    apt -qq list YOUR_LIST_GOES_HERE | grep -v "installed" | awk -F/ '{print $1}' > /root/list.txt
                                    packages=$(cat /root/list.txt)
                                    grep -q '[^[:space:]]' < /root/list.txt
                                    CHECK_LIST=$?
                                    if [[ $CHECK_LIST -eq 1 ]]; then
                                    echo "Your packages are already installed"
                                    else
                                    echo "Installing packages"
                                    apt-get install -y $packages
                                    fi


                                    Hope it helps someone.






                                    share|improve this answer













                                    If someone is interested, i created a little script with which you can automatically install from a list of packages or applications or simply check if they are already installed:



                                    #!/bin/bash
                                    apt -qq list YOUR_LIST_GOES_HERE | grep -v "installed" | awk -F/ '{print $1}' > /root/list.txt
                                    packages=$(cat /root/list.txt)
                                    grep -q '[^[:space:]]' < /root/list.txt
                                    CHECK_LIST=$?
                                    if [[ $CHECK_LIST -eq 1 ]]; then
                                    echo "Your packages are already installed"
                                    else
                                    echo "Installing packages"
                                    apt-get install -y $packages
                                    fi


                                    Hope it helps someone.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Dec 17 '18 at 14:39









                                    Claudio TaccognaClaudio Taccogna

                                    31928




                                    31928






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Ask Ubuntu!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f423355%2fhow-do-i-check-if-a-package-is-installed-on-my-server%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Human spaceflight

                                        Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

                                        File:DeusFollowingSea.jpg