How to show the number of installed packages
Clash Royale CLAN TAG#URR8PPP
up vote
8
down vote
favorite
What is the Debian equivalent of Fedora's yum list installed | grep wc --lines
?
debian package-management
add a comment |
up vote
8
down vote
favorite
What is the Debian equivalent of Fedora's yum list installed | grep wc --lines
?
debian package-management
add a comment |
up vote
8
down vote
favorite
up vote
8
down vote
favorite
What is the Debian equivalent of Fedora's yum list installed | grep wc --lines
?
debian package-management
What is the Debian equivalent of Fedora's yum list installed | grep wc --lines
?
debian package-management
debian package-management
edited Feb 24 '11 at 22:45
asked Feb 24 '11 at 22:09
Tshepang
25.3k71182262
25.3k71182262
add a comment |
add a comment |
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
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
add a comment |
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'
.
add a comment |
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).
add a comment |
up vote
1
down vote
Synaptic, a GUI package manager, displays the count at the bottom of its main window.
add a comment |
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.
add a comment |
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
.
add a comment |
up vote
-1
down vote
For instace, you can do this:
dpkg-query -l | nl | tail -1 | awk 'print $1'
OK, it's true thatnl | 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 reporting0
) — but why would you recommend such a kludge when other answers are already usingwc -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
add a comment |
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
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
add a comment |
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
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
add a comment |
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
According to this thread:
To list installed packages:
dpkg --list | wc --lines
To see if a package is installed:
dpkg --list | grep package
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
add a comment |
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
add a comment |
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'
.
add a comment |
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'
.
add a comment |
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'
.
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'
.
answered Feb 24 '11 at 23:11
Gilles
519k12410371566
519k12410371566
add a comment |
add a comment |
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).
add a comment |
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).
add a comment |
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).
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).
answered Feb 24 '11 at 22:37
timday
4101514
4101514
add a comment |
add a comment |
up vote
1
down vote
Synaptic, a GUI package manager, displays the count at the bottom of its main window.
add a comment |
up vote
1
down vote
Synaptic, a GUI package manager, displays the count at the bottom of its main window.
add a comment |
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.
Synaptic, a GUI package manager, displays the count at the bottom of its main window.
answered Feb 25 '11 at 8:30
Tshepang
25.3k71182262
25.3k71182262
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Apr 13 '17 at 12:36
Community♦
1
1
answered Nov 26 '11 at 22:35
Tynach
1111
1111
add a comment |
add a comment |
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
.
add a comment |
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
.
add a comment |
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
.
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
.
edited 5 hours ago
answered 5 hours ago
Christophe Strobbe
15319
15319
add a comment |
add a comment |
up vote
-1
down vote
For instace, you can do this:
dpkg-query -l | nl | tail -1 | awk 'print $1'
OK, it's true thatnl | 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 reporting0
) — but why would you recommend such a kludge when other answers are already usingwc -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
add a comment |
up vote
-1
down vote
For instace, you can do this:
dpkg-query -l | nl | tail -1 | awk 'print $1'
OK, it's true thatnl | 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 reporting0
) — but why would you recommend such a kludge when other answers are already usingwc -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
add a comment |
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'
For instace, you can do this:
dpkg-query -l | nl | tail -1 | awk 'print $1'
answered Jul 29 '16 at 1:19
Karim Manaouil
1649
1649
OK, it's true thatnl | 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 reporting0
) — but why would you recommend such a kludge when other answers are already usingwc -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
add a comment |
OK, it's true thatnl | 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 reporting0
) — but why would you recommend such a kludge when other answers are already usingwc -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
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password