Skip to content

Instantly share code, notes, and snippets.

@mike-pisman
Last active October 20, 2022 10:41
Show Gist options
  • Save mike-pisman/aadeabc515d4f7925f99b8cda04f1b57 to your computer and use it in GitHub Desktop.
Save mike-pisman/aadeabc515d4f7925f99b8cda04f1b57 to your computer and use it in GitHub Desktop.
A few command to help migrate from old Ubuntu/Debian machine to a new one and reinstall all of the aptitude packages.
# On the old machine, create a list of all installed packages
apt list --installed 2>/dev/null | sed 's/\/.*//g > pkglist'
# On the new machine, Filter packages for those available
while read package; do apt show "$package" 2>/dev/null | grep -qvz 'State:.*(virtual)' && echo "$package" >>packages-valid && echo -ne "\r\033[K$package"; done <packages
# Install the available packages all at once
sudo apt install $(tr '\n' ' ' <packages-valid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment