Reinstall the same apt packages after reinstall or on a new system
- October 29th, 2023
- Posted in Uncategorized
- Write comment
To save a list of installed apt packages on your Ubuntu system so you can reinstall them on another Ubuntu system, you can use the dpkg
and apt
commands to generate a package list and then transfer that list to the new system. Here are the steps:
- On the source Ubuntu system (the one with the packages you want to save), open a terminal.
- Run the following command to generate a list of installed packages and save it to a text file (e.g.,
package_list.txt
):
bashCopy code
dpkg --get-selections > package_list.txt
This command will create a text file called package_list.txt
in the current directory containing a list of all installed packages.
- Transfer the
package_list.txt
file to the target Ubuntu system. You can use methods like SCP, USB drive, or any other means to move the file to the new system. - On the target Ubuntu system, open a terminal.
- Place the
package_list.txt
file in a directory of your choice. - Run the following command to install the packages listed in the file:
sudo dpkg --set-selections < package_list.txt
sudo apt-get -y update
sudo apt-get dselect-upgrade
These commands will set the selections of packages based on the contents of the package_list.txt
file and then update and upgrade your system to install those packages.
Please note that while this method will install the same packages on the new system, it won’t configure them in the same way as your original system. Configuration files for packages are typically not included in this process, so you may need to manually configure any software that requires it after the installation.
Additionally, if the two systems have different versions of Ubuntu or different package sources enabled, there may be some compatibility issues or differences in available packages. Always exercise caution and review the package list before proceeding to ensure that the packages are appropriate for the target system.
Follow Me!