Ubuntu_User

Search, generate or restore from list of installed packages

In cmd-fu on July 15, 2009 at 12:49 pm

Listing packages

To get the list of packages that start with pkg_name_begin:


dpkg --get-selections pkg_name_begin*

For a more generalized search, e.g where pkg_name_partial is text within the package name:


dpkg --get-selections | grep "[[:space:]]install$" | grep -i pkg_name_partial

To get a list of all installed packages on your debian system:


dpkg --get-selections | grep "[[:space:]]install$" | \awk '{print $1}'

It makes terrific sense to periodically generate and store this list for any eventually where you need to reinstall the system. You should even consider turning this into a script, and place into a weekly or monthly cron job that mails you the list.


dpkg --get-selections | grep "[[:space:]]install$" | awk '{print $1}' | tee installed_pkgs | mailx -s "List of installed packages" you@mailhost.com

Reinstalling packages

To install the packages from the list created earlier on top of a fresh Ubuntu install, follow these steps:

sudo apt-get upgrade

sudo apt-get dist-upgrade
dpkg –set-selections < installed_pkgs sudo apt-get -u dselect-upgrade [/sourcecode] Formatting woes: The third statement should read dpkg –set-selections < installed_pkgs, but wordpress won’t let it be.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: