Listing the packages on Debian/Ubuntu in one line

You can use dpkg to list all the packages that are selected on your Debian or Ubuntu system:

[sourcecode language=”plain”]# dpkg –get-selections[/sourcecode]

But today I needed a way to list only the installed packages in just one line, so I could copy their names and use apt-get to install the same packages on another system. So I used the following command:

[sourcecode language=”plain”]# dpkg –get-selections | grep "[ \t]*install$" | sed ‘s/[ \t]*install$//g’ | awk ‘BEGIN { packages = "" } { packages = packages " " $1 } END { print packages }’
acpi-support-base acpid adduser apt apt-utils […] long list of packages […] xsltproc xz-utils yelp zenity zlib1g zlib1g-dev[/sourcecode]

You can use the output above to easily install the same packages on another system using apt-get install <packages>.


Notice: Trying to get property 'comment_ID' of non-object in /home/esdrasbeleza/sites/esdrasbeleza.com/wp-includes/comment-template.php on line 670

Notice: Trying to get property 'user_id' of non-object in /home/esdrasbeleza/sites/esdrasbeleza.com/wp-includes/comment-template.php on line 28

Notice: Trying to get property 'comment_ID' of non-object in /home/esdrasbeleza/sites/esdrasbeleza.com/wp-includes/comment-template.php on line 48
Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.