How to show the number of installed packages

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
8
down vote

favorite
1












What is the Debian equivalent of Fedora's yum list installed | grep wc --lines?










share|improve this question



























    up vote
    8
    down vote

    favorite
    1












    What is the Debian equivalent of Fedora's yum list installed | grep wc --lines?










    share|improve this question

























      up vote
      8
      down vote

      favorite
      1









      up vote
      8
      down vote

      favorite
      1






      1





      What is the Debian equivalent of Fedora's yum list installed | grep wc --lines?










      share|improve this question















      What is the Debian equivalent of Fedora's yum list installed | grep wc --lines?







      debian package-management






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 24 '11 at 22:45

























      asked Feb 24 '11 at 22:09









      Tshepang

      25.3k71182262




      25.3k71182262




















          7 Answers
          7






          active

          oldest

          votes

















          up vote
          10
          down vote













          According to this thread:



          To list installed packages:



          dpkg --list | wc --lines


          To see if a package is installed:



          dpkg --list | grep package





          share|improve this answer


















          • 1




            You're including the header lines and some non-installed packages (e.g. rc (uninstalled but with config files left over)) in your count.
            – Gilles
            Feb 24 '11 at 23:13

















          up vote
          6
          down vote













          dpkg -l | grep -c '^ii'


          There are subtle variants like dpkg -l | grep -c '^?i' if you want to include packages that are installed but whose removal you've requested. Another way is



          aptitude search '~i' |wc -l


          You can even poke directly into the dpkg database:



          sh -c 'set /var/lib/dpkg/info/*; echo $#'


          This one includes packages that are not installed but that have configuration files left over; you can list these with dpkg -l | grep '^rc'.






          share|improve this answer



























            up vote
            1
            down vote













            dpkg -l is nice but I actually find myself using apt-show-versions (not installed by default on Debian; install the package of the same name) a lot instead, especially when I want to process the output further (dpkg tries to be too clever with line wrapping).






            share|improve this answer



























              up vote
              1
              down vote













              Synaptic, a GUI package manager, displays the count at the bottom of its main window.



              enter image description here






              share|improve this answer



























                up vote
                1
                down vote













                What I've been using is:



                dpkg --get-selections | wc --lines


                This will give you the number of installed packages.



                If you want to find if a particular package is installed, use:



                dpkg --get-selections | grep <package>


                I believe that this will solve Gilles' complaint about including other, non-installed packages.






                share|improve this answer





























                  up vote
                  0
                  down vote













                  If you want an exact count of packages, you should not count the header lines output by dpkg-query -l, so you need a pattern to match lines starting with ii. The following one-liner gives you the number of lines starting with ii and therefore the number of installed packages:



                  dpkg-query -l | grep "^ii" | wc -l 


                  This gives the same output as



                   dpkg --get-selections | grep "[[:space:]]install" | wc -l


                  The grep pattern in the second command ignores lines that contain the string "deinstall" in the output of dpkg --get-selections.






                  share|improve this answer





























                    up vote
                    -1
                    down vote













                    For instace, you can do this:



                    dpkg-query -l | nl | tail -1 | awk 'print $1'





                    share|improve this answer




















                    • OK, it's true that nl | tail -1 | awk 'print $1' will report the number of lines in its input (except, if there is no input, it will say nothing instead of reporting 0) — but why would you recommend such a kludge when other answers are already using wc -l?
                      – G-Man
                      Jul 29 '16 at 1:58










                    • That's funny cause i didn't read previous answers! @G-Man ...but this still remains a good answer.
                      – Karim Manaouil
                      Aug 7 '16 at 2:04










                    Your Answer








                    StackExchange.ready(function()
                    var channelOptions =
                    tags: "".split(" "),
                    id: "106"
                    ;
                    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',
                    convertImagesToLinks: false,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: null,
                    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%2funix.stackexchange.com%2fquestions%2f8045%2fhow-to-show-the-number-of-installed-packages%23new-answer', 'question_page');

                    );

                    Post as a guest






























                    7 Answers
                    7






                    active

                    oldest

                    votes








                    7 Answers
                    7






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes








                    up vote
                    10
                    down vote













                    According to this thread:



                    To list installed packages:



                    dpkg --list | wc --lines


                    To see if a package is installed:



                    dpkg --list | grep package





                    share|improve this answer


















                    • 1




                      You're including the header lines and some non-installed packages (e.g. rc (uninstalled but with config files left over)) in your count.
                      – Gilles
                      Feb 24 '11 at 23:13














                    up vote
                    10
                    down vote













                    According to this thread:



                    To list installed packages:



                    dpkg --list | wc --lines


                    To see if a package is installed:



                    dpkg --list | grep package





                    share|improve this answer


















                    • 1




                      You're including the header lines and some non-installed packages (e.g. rc (uninstalled but with config files left over)) in your count.
                      – Gilles
                      Feb 24 '11 at 23:13












                    up vote
                    10
                    down vote










                    up vote
                    10
                    down vote









                    According to this thread:



                    To list installed packages:



                    dpkg --list | wc --lines


                    To see if a package is installed:



                    dpkg --list | grep package





                    share|improve this answer














                    According to this thread:



                    To list installed packages:



                    dpkg --list | wc --lines


                    To see if a package is installed:



                    dpkg --list | grep package






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Feb 24 '11 at 22:48









                    Tshepang

                    25.3k71182262




                    25.3k71182262










                    answered Feb 24 '11 at 22:15









                    Justin Ethier

                    10k83052




                    10k83052







                    • 1




                      You're including the header lines and some non-installed packages (e.g. rc (uninstalled but with config files left over)) in your count.
                      – Gilles
                      Feb 24 '11 at 23:13












                    • 1




                      You're including the header lines and some non-installed packages (e.g. rc (uninstalled but with config files left over)) in your count.
                      – Gilles
                      Feb 24 '11 at 23:13







                    1




                    1




                    You're including the header lines and some non-installed packages (e.g. rc (uninstalled but with config files left over)) in your count.
                    – Gilles
                    Feb 24 '11 at 23:13




                    You're including the header lines and some non-installed packages (e.g. rc (uninstalled but with config files left over)) in your count.
                    – Gilles
                    Feb 24 '11 at 23:13












                    up vote
                    6
                    down vote













                    dpkg -l | grep -c '^ii'


                    There are subtle variants like dpkg -l | grep -c '^?i' if you want to include packages that are installed but whose removal you've requested. Another way is



                    aptitude search '~i' |wc -l


                    You can even poke directly into the dpkg database:



                    sh -c 'set /var/lib/dpkg/info/*; echo $#'


                    This one includes packages that are not installed but that have configuration files left over; you can list these with dpkg -l | grep '^rc'.






                    share|improve this answer
























                      up vote
                      6
                      down vote













                      dpkg -l | grep -c '^ii'


                      There are subtle variants like dpkg -l | grep -c '^?i' if you want to include packages that are installed but whose removal you've requested. Another way is



                      aptitude search '~i' |wc -l


                      You can even poke directly into the dpkg database:



                      sh -c 'set /var/lib/dpkg/info/*; echo $#'


                      This one includes packages that are not installed but that have configuration files left over; you can list these with dpkg -l | grep '^rc'.






                      share|improve this answer






















                        up vote
                        6
                        down vote










                        up vote
                        6
                        down vote









                        dpkg -l | grep -c '^ii'


                        There are subtle variants like dpkg -l | grep -c '^?i' if you want to include packages that are installed but whose removal you've requested. Another way is



                        aptitude search '~i' |wc -l


                        You can even poke directly into the dpkg database:



                        sh -c 'set /var/lib/dpkg/info/*; echo $#'


                        This one includes packages that are not installed but that have configuration files left over; you can list these with dpkg -l | grep '^rc'.






                        share|improve this answer












                        dpkg -l | grep -c '^ii'


                        There are subtle variants like dpkg -l | grep -c '^?i' if you want to include packages that are installed but whose removal you've requested. Another way is



                        aptitude search '~i' |wc -l


                        You can even poke directly into the dpkg database:



                        sh -c 'set /var/lib/dpkg/info/*; echo $#'


                        This one includes packages that are not installed but that have configuration files left over; you can list these with dpkg -l | grep '^rc'.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Feb 24 '11 at 23:11









                        Gilles

                        519k12410371566




                        519k12410371566




















                            up vote
                            1
                            down vote













                            dpkg -l is nice but I actually find myself using apt-show-versions (not installed by default on Debian; install the package of the same name) a lot instead, especially when I want to process the output further (dpkg tries to be too clever with line wrapping).






                            share|improve this answer
























                              up vote
                              1
                              down vote













                              dpkg -l is nice but I actually find myself using apt-show-versions (not installed by default on Debian; install the package of the same name) a lot instead, especially when I want to process the output further (dpkg tries to be too clever with line wrapping).






                              share|improve this answer






















                                up vote
                                1
                                down vote










                                up vote
                                1
                                down vote









                                dpkg -l is nice but I actually find myself using apt-show-versions (not installed by default on Debian; install the package of the same name) a lot instead, especially when I want to process the output further (dpkg tries to be too clever with line wrapping).






                                share|improve this answer












                                dpkg -l is nice but I actually find myself using apt-show-versions (not installed by default on Debian; install the package of the same name) a lot instead, especially when I want to process the output further (dpkg tries to be too clever with line wrapping).







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Feb 24 '11 at 22:37









                                timday

                                4101514




                                4101514




















                                    up vote
                                    1
                                    down vote













                                    Synaptic, a GUI package manager, displays the count at the bottom of its main window.



                                    enter image description here






                                    share|improve this answer
























                                      up vote
                                      1
                                      down vote













                                      Synaptic, a GUI package manager, displays the count at the bottom of its main window.



                                      enter image description here






                                      share|improve this answer






















                                        up vote
                                        1
                                        down vote










                                        up vote
                                        1
                                        down vote









                                        Synaptic, a GUI package manager, displays the count at the bottom of its main window.



                                        enter image description here






                                        share|improve this answer












                                        Synaptic, a GUI package manager, displays the count at the bottom of its main window.



                                        enter image description here







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Feb 25 '11 at 8:30









                                        Tshepang

                                        25.3k71182262




                                        25.3k71182262




















                                            up vote
                                            1
                                            down vote













                                            What I've been using is:



                                            dpkg --get-selections | wc --lines


                                            This will give you the number of installed packages.



                                            If you want to find if a particular package is installed, use:



                                            dpkg --get-selections | grep <package>


                                            I believe that this will solve Gilles' complaint about including other, non-installed packages.






                                            share|improve this answer


























                                              up vote
                                              1
                                              down vote













                                              What I've been using is:



                                              dpkg --get-selections | wc --lines


                                              This will give you the number of installed packages.



                                              If you want to find if a particular package is installed, use:



                                              dpkg --get-selections | grep <package>


                                              I believe that this will solve Gilles' complaint about including other, non-installed packages.






                                              share|improve this answer
























                                                up vote
                                                1
                                                down vote










                                                up vote
                                                1
                                                down vote









                                                What I've been using is:



                                                dpkg --get-selections | wc --lines


                                                This will give you the number of installed packages.



                                                If you want to find if a particular package is installed, use:



                                                dpkg --get-selections | grep <package>


                                                I believe that this will solve Gilles' complaint about including other, non-installed packages.






                                                share|improve this answer














                                                What I've been using is:



                                                dpkg --get-selections | wc --lines


                                                This will give you the number of installed packages.



                                                If you want to find if a particular package is installed, use:



                                                dpkg --get-selections | grep <package>


                                                I believe that this will solve Gilles' complaint about including other, non-installed packages.







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Apr 13 '17 at 12:36









                                                Community

                                                1




                                                1










                                                answered Nov 26 '11 at 22:35









                                                Tynach

                                                1111




                                                1111




















                                                    up vote
                                                    0
                                                    down vote













                                                    If you want an exact count of packages, you should not count the header lines output by dpkg-query -l, so you need a pattern to match lines starting with ii. The following one-liner gives you the number of lines starting with ii and therefore the number of installed packages:



                                                    dpkg-query -l | grep "^ii" | wc -l 


                                                    This gives the same output as



                                                     dpkg --get-selections | grep "[[:space:]]install" | wc -l


                                                    The grep pattern in the second command ignores lines that contain the string "deinstall" in the output of dpkg --get-selections.






                                                    share|improve this answer


























                                                      up vote
                                                      0
                                                      down vote













                                                      If you want an exact count of packages, you should not count the header lines output by dpkg-query -l, so you need a pattern to match lines starting with ii. The following one-liner gives you the number of lines starting with ii and therefore the number of installed packages:



                                                      dpkg-query -l | grep "^ii" | wc -l 


                                                      This gives the same output as



                                                       dpkg --get-selections | grep "[[:space:]]install" | wc -l


                                                      The grep pattern in the second command ignores lines that contain the string "deinstall" in the output of dpkg --get-selections.






                                                      share|improve this answer
























                                                        up vote
                                                        0
                                                        down vote










                                                        up vote
                                                        0
                                                        down vote









                                                        If you want an exact count of packages, you should not count the header lines output by dpkg-query -l, so you need a pattern to match lines starting with ii. The following one-liner gives you the number of lines starting with ii and therefore the number of installed packages:



                                                        dpkg-query -l | grep "^ii" | wc -l 


                                                        This gives the same output as



                                                         dpkg --get-selections | grep "[[:space:]]install" | wc -l


                                                        The grep pattern in the second command ignores lines that contain the string "deinstall" in the output of dpkg --get-selections.






                                                        share|improve this answer














                                                        If you want an exact count of packages, you should not count the header lines output by dpkg-query -l, so you need a pattern to match lines starting with ii. The following one-liner gives you the number of lines starting with ii and therefore the number of installed packages:



                                                        dpkg-query -l | grep "^ii" | wc -l 


                                                        This gives the same output as



                                                         dpkg --get-selections | grep "[[:space:]]install" | wc -l


                                                        The grep pattern in the second command ignores lines that contain the string "deinstall" in the output of dpkg --get-selections.







                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited 5 hours ago

























                                                        answered 5 hours ago









                                                        Christophe Strobbe

                                                        15319




                                                        15319




















                                                            up vote
                                                            -1
                                                            down vote













                                                            For instace, you can do this:



                                                            dpkg-query -l | nl | tail -1 | awk 'print $1'





                                                            share|improve this answer




















                                                            • OK, it's true that nl | tail -1 | awk 'print $1' will report the number of lines in its input (except, if there is no input, it will say nothing instead of reporting 0) — but why would you recommend such a kludge when other answers are already using wc -l?
                                                              – G-Man
                                                              Jul 29 '16 at 1:58










                                                            • That's funny cause i didn't read previous answers! @G-Man ...but this still remains a good answer.
                                                              – Karim Manaouil
                                                              Aug 7 '16 at 2:04














                                                            up vote
                                                            -1
                                                            down vote













                                                            For instace, you can do this:



                                                            dpkg-query -l | nl | tail -1 | awk 'print $1'





                                                            share|improve this answer




















                                                            • OK, it's true that nl | tail -1 | awk 'print $1' will report the number of lines in its input (except, if there is no input, it will say nothing instead of reporting 0) — but why would you recommend such a kludge when other answers are already using wc -l?
                                                              – G-Man
                                                              Jul 29 '16 at 1:58










                                                            • That's funny cause i didn't read previous answers! @G-Man ...but this still remains a good answer.
                                                              – Karim Manaouil
                                                              Aug 7 '16 at 2:04












                                                            up vote
                                                            -1
                                                            down vote










                                                            up vote
                                                            -1
                                                            down vote









                                                            For instace, you can do this:



                                                            dpkg-query -l | nl | tail -1 | awk 'print $1'





                                                            share|improve this answer












                                                            For instace, you can do this:



                                                            dpkg-query -l | nl | tail -1 | awk 'print $1'






                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered Jul 29 '16 at 1:19









                                                            Karim Manaouil

                                                            1649




                                                            1649











                                                            • OK, it's true that nl | tail -1 | awk 'print $1' will report the number of lines in its input (except, if there is no input, it will say nothing instead of reporting 0) — but why would you recommend such a kludge when other answers are already using wc -l?
                                                              – G-Man
                                                              Jul 29 '16 at 1:58










                                                            • That's funny cause i didn't read previous answers! @G-Man ...but this still remains a good answer.
                                                              – Karim Manaouil
                                                              Aug 7 '16 at 2:04
















                                                            • OK, it's true that nl | tail -1 | awk 'print $1' will report the number of lines in its input (except, if there is no input, it will say nothing instead of reporting 0) — but why would you recommend such a kludge when other answers are already using wc -l?
                                                              – G-Man
                                                              Jul 29 '16 at 1:58










                                                            • That's funny cause i didn't read previous answers! @G-Man ...but this still remains a good answer.
                                                              – Karim Manaouil
                                                              Aug 7 '16 at 2:04















                                                            OK, it's true that nl | tail -1 | awk 'print $1' will report the number of lines in its input (except, if there is no input, it will say nothing instead of reporting 0) — but why would you recommend such a kludge when other answers are already using wc -l?
                                                            – G-Man
                                                            Jul 29 '16 at 1:58




                                                            OK, it's true that nl | tail -1 | awk 'print $1' will report the number of lines in its input (except, if there is no input, it will say nothing instead of reporting 0) — but why would you recommend such a kludge when other answers are already using wc -l?
                                                            – G-Man
                                                            Jul 29 '16 at 1:58












                                                            That's funny cause i didn't read previous answers! @G-Man ...but this still remains a good answer.
                                                            – Karim Manaouil
                                                            Aug 7 '16 at 2:04




                                                            That's funny cause i didn't read previous answers! @G-Man ...but this still remains a good answer.
                                                            – Karim Manaouil
                                                            Aug 7 '16 at 2:04

















                                                             

                                                            draft saved


                                                            draft discarded















































                                                             


                                                            draft saved


                                                            draft discarded














                                                            StackExchange.ready(
                                                            function ()
                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f8045%2fhow-to-show-the-number-of-installed-packages%23new-answer', 'question_page');

                                                            );

                                                            Post as a guest













































































                                                            Popular posts from this blog

                                                            How to check contact read email or not when send email to Individual?

                                                            Displaying single band from multi-band raster using QGIS

                                                            How many registers does an x86_64 CPU actually have?