I'm very new to ubuntu and I'm trying to find a command that tells what packages and the versions are installed on my "sandbox" I'm looking to bundle this as a output file
-
@serg Not a duplicate. That question is about apps accessible from the Dash (i.e. GUI programs). OP is asking about packages (which would include CLI programs). – wjandrea Jul 21 '16 at 01:09
-
@wjandrea still a duplicate , this has been asked before. Just need to find the right link – Sergiy Kolodyazhnyy Jul 21 '16 at 01:10
-
Exactly where it is showing the version information as well or am I missing this? – Kenny Jul 21 '16 at 01:23
3 Answers
I know you can use dpkg --get-selections | awk '{print $1}'
to see all installed packages. but not sure about the versions i'll let you know if i find somthing else

- 903
- 1
- 9
- 27
-
1
-
-
@Kenny It's easier to copy and paste instead of typing it yourself. That's actually an "L". – wjandrea Jul 21 '16 at 01:24
-
Your question may be marked as a duplicate because you're expected to do some of your own research before posting on StackExchange sites. But, because the possible duplicate (How to list all installed packages) doesn't touch on version info, here's your answer:
dpkg -l | grep "^ii" | awk '{print $2,$3}'
or
dpkg -l | awk '/^ii/ {print $2,$3}'
Decoded:
dpkg -l
list all packages, including ones which have been removed.
grep "^ii"
print only lines that start with "ii" (to exclude packages which have been removed, usually marked "rc"). Note that installed packages may not always be in "ii" status. This command will check: dpkg -l | grep -v "^ii" | grep -v "^rc" | tail -n +6
awk '{print $2,$3}'
print the second and third columns (package name and version, respectively).
p.s. I wrote some comments about this before but my code was wrong.
-
2FYI there's no need to pipe through both grep and awk -
dpkg -l | awk '/^ii/ {print $2,$3}'
should be equivalent – steeldriver Jul 21 '16 at 02:51
Although selecting fields from the output of dpkg -l
certainly works, the more fundamental dpkg-query
command allows the output fields and format to be customized without resorting to additional text processing tools. As it happens, plain
dpkg-query -W
with no explicit format string gives exactly a tab-separated list of package names and versions (equivalent to dpkg -l | awk '{print $2,$3}'
) as noted in man dpkg-query
:
-W, --show [package-name-pattern...]
Just like the --list option this will list all packages matching
the given pattern. However the output can be customized using
the --showformat option. The default output format gives one
line per matching package, each line having the name (extended
with the architecture qualifier for Multi-Arch same packages)
and installed version of the package, separated by a tab.
If you want a prettier output more akin to that of dpkg -l
you could use something like
dpkg-query -W -f='${binary:Package;-25}\t${Version}\n'
to left-justify the package names in a field of width 25 columns, or
dpkg-query -W -f='${db:status-abbrev}\t${binary:Package;-25}\t${Version}\n'
to include the ii
etc. status flags at the start of each line.

- 136,215
- 21
- 243
- 336