Save a copy of all debian packages in the form in which they are installed and configured on your system

for a in $(sudo dpkg --get-selections|cut -f1); do dpkg-repack $a|awk '{if (system("sleep .5 && exit 2") != 2) exit; print}';done
A copy of all installed debian packages on your system will be put back together, with all changes in configuration files you made and placed in the current directory. Make sure you have enough disk space (say 2-3 GB). Break any time with Ctrl+C.
Sample Output
$ ls -1
accountsservice_0.6.45-1ubuntu1.3_amd64.deb
acl_2.2.52-3build1_amd64.deb
acpid_2.0.28-1ubuntu1_amd64.deb
acpi-support_0.142_amd64.deb
...
^C
(Ctrl+C)

6
By: knoppix5
2021-01-17 17:07:02

What Others Think

I think you didn't test the command cuz it's fatally broken (my machine's an Ubuntu 20.04 LTS): ------- for a in $(sudo dpkg --get-selections|cut -f1); do dpkg-deb $a;done [sudo] password for : dpkg-deb: error: need an action option Type dpkg-deb --help for help about manipulating *.deb files; Type dpkg --help for help about installing and deinstalling packages. dpkg-deb: error: need an action option ------- The last 3 lines are repeated for every item.
rautamiekka · 261 weeks and 2 days ago
^ (Oh yeah, I forgot commanlinefu.com doesn't support lines in comments ... Sorry about that)
rautamiekka · 261 weeks and 2 days ago
This relies on every package having a DEBIAN folder associated with it. i.e if you were building every package yourself first. It is fatally broken. even with the required -b switch it won't work
Myso · 261 weeks and 2 days ago
Sorry people, my fault: I wrote "dpkg-deb" instead "dpkg-repack" in the command. Corrected!
knoppix5 · 261 weeks and 2 days ago
Can I tell what packages are already installed on a Debian system? ... Note that this operation does not necessarily leave the package in a usable state;
Elizabeth76 · 255 weeks and 4 days ago
Very nice, Thanks for sharing the most important information I am so glad to visit this blog. We provide Graphic Design Courses. If you need any issues regarding the Graphic Courses visit our website...
graphicdesign11 · 254 weeks and 5 days ago
www.instagram.com/enri1que
Falk1993 · 251 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: