15

I want to have a list of all packages that are installed on my server, but the command

dpkg --get-selections > ~/Package.list

doesn't do anything! When I execute it there is no file called "package.list" in the root folder.

user180429
  • 159
  • 1
  • 1
  • 3

6 Answers6

22

You have to run the same command (there's no need to run it as root)

dpkg --get-selections > ~/InstalledPackages.list

Then you can

cat ~/InstalledPackages.list

to see the content.

Now, if you are not sure how's ~ been processed, you can

cd ~
pwd

And that's it.

0R10N
  • 2,126
  • 3
  • 17
  • 20
  • Well if i execute cat InstalledPackages.list i can see the file but with filezilla i am unable to find i want to export it to my pc – user180429 Aug 01 '13 at 11:09
  • I mean no disrespect, but maybe you're looking in the wrong directory. Try cd ~ and then pwd, just to make sure you're working in the right directory. If you're pointing FileZilla to the right directory and the file isn't there, then you must check permissions for your file and the parent directory. Easy way, move it to /tmp/ – 0R10N Aug 01 '13 at 11:18
  • Glad to help :) – 0R10N Aug 01 '13 at 11:27
  • Is it safe to edit this Package.list? The reason is that I need to restore all packages on my fresh Ubuntu, but I am suspicious that some among these packages broke my system in the first place. Can I somehow edit them out? – Heisenberg Nov 18 '13 at 04:54
  • I don't recommend to edit this list. I'm just saying that you can run a command that lists your packages and save it to a file. Editing that file won't change anything. – 0R10N Nov 18 '13 at 12:18
  • 1
    How can I use this list to install exactly the same packages on a different machine (but same model)? – ubuplex Jun 04 '15 at 06:44
11

Use dpkg-query, this command is precisely intended to what you need: request on packages data‑base. A quick man dpkg-query will tell you more, however, you may try dpkg-query --list or dpkg-query -- show.

Hibou57
  • 1,195
5

What's with these answers lol all this question is asking is a simple dpkg output list,

 dpkg --list | less

 dpkg -l | more 

 dpkg-query -l | tail

 dpkg-query --list | head

 diff <(ps aux| grep x) <(pgrep x)

 apt-file list "package"
3

You said you've looked in the root folder, but with the "~" you are clearly pointing to the home folder. The root would be /Package.list, or -/Package.list. Check in the home folder.

EDIT: As I can see now, even though my answer was correct, it might have been unclear to a fresh user. I'm sorry for introducing additional confusion. @0R10N thanks for good example :)

denuviel
  • 119
  • 1
  • 8
3

If you would like to get the versions of some installed packages, you can pipe commands like this:

dpkg --get-selections | awk '/php/{print $1}' | xargs dpkg-query --show $1

your output would look like the following:

libapache2-mod-php5     5.3.2-1ubuntu4.29
php5-cli        5.3.2-1ubuntu4.29
php5-common     5.3.2-1ubuntu4.29
php5-gd 5.3.2-1ubuntu4.29
php5-mcrypt     5.3.2-0ubuntu1
php5-mysql      5.3.2-1ubuntu4.29
php5-xsl        5.3.2-1ubuntu4.29
phpmyadmin      4:3.3.2-1ubuntu1
muru
  • 197,895
  • 55
  • 485
  • 740
bigboy1
  • 31
0

try this, may work, it work for me.

dpkg -l
Yahya
  • 146