Helper scripts to transfer KDE system settings, installed apps, user's home directory to a new computer using Fedora.
rsync -aP --exclude-from=ignorelist.txt /home/$USER [username]@[ip-or-domain]:/mnt/WD16TB/shared/home-backup/$USER/rsync -aP ---exclude-from=ignorelist.txt /home/$USER/ /media/$USER/linuxbackup/home/$USER/rsync -aAXv --delete /media/$USER/linuxbackup/home/$USER/ /home/$USER/-
Save it as transfer-kde-settings.sh.
-
Make it executable:
chmod +x transfer-kde-settings.sh -
Edit Variables:
-
Update SOURCE_HOST, SOURCE_USER, TARGET_DIR, SSH_KEY to match your setup.
-
Adjust CONFIG_DIRS, LOCAL_DIRS, or EXCLUDE_FILES if you need specific files or want to include cache.
-
Execute: ./transfer-kde-settings.sh
Ensure SSH is configured (e.g., ~/.ssh/id_rsa exists and is authorized on the source).
- Follow the script’s final instructions to log out/in or restart Plasma.
-
Dependencies: Install rsync and tar on both systems (
sudo dnf install rsync tar). -
Version Compatibility: Check KDE Plasma versions with plasmashell --version. Mismatches may cause issues.
Manual Transfer: If SSH isn’t available, copy files to a USB drive with:
tar -czf kde-settings.tar.gz ~/.config ~/.local/sharetar -xzf kde-settings.tar.gz -C ~- Specific Settings: If you only want specific settings (e.g., only Konsole), modify CONFIG_DIRS and LOCAL_DIRS to include only those files (e.g., .config/konsolerc, .local/share/konsole).
Troubleshooting: If settings don’t apply correctly, clear the cache (rm -rf ~/.cache/*) and restart Plasma.
This script should cover most KDE settings, but let me know if you need adjustments for specific applications or a different transfer method!
Below, I’ll guide you through the process of listing installed programs on Fedora 42 Linux, exporting them to a file, and creating a robust script to reinstall those programs on a new system. The script will include error handling and detailed explanations to ensure clarity and reliability.
Fedora uses the dnf package manager, which tracks installed packages. To list explicitly installed packages (those you manually installed, excluding dependencies), you can use the dnf history userinstalled command. This is ideal for capturing your intentionally installed applications. Command to List Explicitly Installed Packages
dnf history userinstalled > packages.txtExplanation
- dnf history userinstalled: Lists packages that were explicitly installed by the user, omitting automatically installed dependencies.
> packages.txt: Redirects the output to a file named packages.txt in your current directory.
The resulting packages.txt file will contain package names, one per line, such as firefox, vlc, or gnome-tweaks.
The output may include some system packages or dependencies. You should review and edit packages.txt to include only the applications you want to reinstall on the new system.
cat packages.txtEdit the file with a text editor (e.g., nano packages.txt) to remove unwanted packages or add comments for clarity.
If you want a complete list of all installed packages (including dependencies), use:
rpm -qa --qf "%{NAME}\n" | sort > all_packages.txtHowever, this list will be much longer and include system libraries and dependencies, which may not be necessary for reinstallation. The dnf history userinstalled method is generally preferred for user-installed applications.
Once you have packages.txt, transfer it to the new system (e.g., via USB drive, network share, or cloud storage like Google Drive).
Above is a Bash script that uses packages.txt to install the listed packages on a new Fedora 42 system. The script includes error handling, logging, and detailed comments to explain each step.
Script: install_packages.sh
Save the Script:
Copy the script above into a file named install_packages.sh on the new Fedora 42 system.
Example:
nano install_packages.sh-
Paste the script, save, and exit.
-
Make the Script Executable:
chmod +x install_packages.sh- Place the Package List:
Ensure packages.txt (from Step 1) is in the same directory as the script.
- Run the Script:
Execute the script with root privileges:
sudo ./install_packages.shShebang (#!/bin/bash): Specifies that the script runs in Bash.
-
Variables:
- PACKAGE_LIST: Name of the input file (packages.txt).
- LOG_FILE: Log file to record installation progress and errors.
- ERROR_COUNT and SUCCESS_COUNT: Track the number of failed and successful installations.
-
Logging Function (log_message):
- Appends timestamped messages to both the terminal and install_packages.log.
- Ensures all actions are recorded for troubleshooting.
-
Root Check (check_root):
Verifies the script is run with sudo, as dnf requires root privileges.
- Package List Check (check_package_list):
Ensures packages.txt exists and is not empty.
-
System Update (update_system):
- Runs
dnf update -yto refresh package metadata and apply system updates. - Continues even if the update fails (non-critical).
- Runs
-
Package Installation (install_packages):
- Reads packages.txt line by line, skipping empty lines and comments (lines starting with #).
- Installs each package using dnf install -y.
- Logs success or failure and updates counters.
-
Error Handling:
- Checks for missing files, root privileges, and installation failures.
- Logs all errors to install_packages.log for review.
- Exits with a non-zero status if any installations fail.
-
Summary and Suggestions:
- Reports the number of successful and failed installations.
- Suggests enabling RPM Fusion repositories for third-party software (e.g., multimedia codecs, Steam) if packages are unavailable.
-
Example packages.txt
firefox
vlc
gnome-tweaks
# libreoffice # Commented out, will be skipped
gimp
- Log File Example (install_packages.log)
Package Installation Log
[2025-04-23 12:54:01] Script initialized.
[2025-04-23 12:54:02] Updating system packages...
[2025-04-23 12:54:10] System update completed successfully.
[2025-04-23 12:54:10] Starting package installation from 'packages.txt'...
[2025-04-23 12:54:11] Installing package: firefox
[2025-04-23 12:54:15] Successfully installed firefox
[2025-04-23 12:54:15] Installing package: vlc
[2025-04-23 12:54:20] Successfully installed vlc
[2025-04-23 12:54:20] Installing package: gnome-tweaks
[2025-04-23 12:54:25] Successfully installed gnome-tweaks
[2025-04-23 12:54:25] Installing package: gimp
[2025-04-23 12:54:30] ERROR: Failed to install gimp
[2025-04-23 12:54:30] Installation complete. Successful: 3, Failed: 1
[2025-04-23 12:54:30] WARNING: 1 package(s) failed to install. Check 'install_packages.log' for details.
[2025-04-23 12:54:30] To retry failed installations, review 'install_packages.log' and reinstall manually.
[2025-04-23 12:54:30] Note: If some packages are missing, consider enabling third-party repositories (e.g., RPM Fusion).
[2025-04-23 12:54:30] Run: sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
[2025-04-23 12:54:30] sudo dnf install https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm- Enabling Third-Party Repositories
Some applications (e.g., VLC, Steam, or multimedia codecs) may require third-party repositories like RPM Fusion. The script suggests enabling these at the end. To do so manually:
sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpmRun these commands before executing the script if you know your packages depend on RPM Fusion.
- Handling Flatpaks or Snaps
If you use Flatpak or Snap packages (e.g., from Flathub or Snap Store), these are not managed by dnf. To list installed Flatpaks: bash
flatpak list --app > flatpaks.txtxargs -a flatpaks.txt flatpak install -yflatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepoThe script above focuses on dnf packages, but you can extend it to handle Flatpaks by adding a similar loop for flatpak install.
- Package Not Found: If a package fails to install, check if it’s available in the default repositories or requires RPM Fusion. Search for it:
dnf search package_name-
Version Mismatches: Fedora 42 may have newer package versions. The script uses package names (not versions), so it should install the latest available version.
-
Log Review: Check install_packages.log for detailed error messages if any installations fail.
-
Network Issues: Ensure the new system has an internet connection, as dnf downloads packages from online repositories.
Before running the script on the new system, test it on a virtual machine or a non-critical system to ensure it works as expected. You can create a Fedora 42 virtual machine using tools like VirtualBox or GNOME Boxes.
-
List Installed Packages: Use dnf history userinstalled > packages.txt to capture explicitly installed packages. Edit packages.txt to include only desired applications.
-
Installation Script: The provided install_packages.sh script automates package installation with error handling, logging, and user-friendly output. It checks for root privileges, validates the package list, updates the system, and installs packages while tracking successes and failures.
-
Additional Steps: Enable RPM Fusion for third-party packages and handle Flatpaks separately if needed.
-
Troubleshooting: Review install_packages.log for errors and ensure repositories are correctly configured.
-
This approach ensures you can efficiently replicate your Fedora 42 setup on a new system while minimizing manual effort and handling potential errors gracefully.
-
Fedora package management documentation
-
Community discussions on automating package installation
-
RPM Fusion setup guide