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:

# dpkg --get-selections

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:

# 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

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

1 Response

  1. Custom essay December 28, 2016 / 1:35

    fantastic piece of writing and a notable link you provide. it's miles very useful. . It makes me so happy your significant information and wisdom have a new channel for trying into the arena. Students getting different type of writing ideas in this custom essay writing service so they can easily get exactly what they need. It’s providing only guaranteed writing papers for the students.

Leave a Reply

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