After 2 years of using Fedora as my main daily driver, I absolutely love the package update speed of this distro. However, Fedora is also known for being strictly consistent. Have you ever wanted to switch from MariaDB to MySQL, or move to the full version of FFmpeg on RPM Fusion? It’s frustrating when dnf reports conflicts or, worse, threatens to wipe out your entire desktop environment.
In those dead-end situations, standard install or remove commands are almost useless. The secret lies in two often-overlooked tools: dnf swap and dnf shell. These are techniques for replacing system components at the root without bringing down the whole house you’re living in.
Quick start: Rapid replacement in 3 simple steps
If you need to get the job done right now, here are two scenarios that will save you at least 15 minutes of digging through dependency errors.
1. Swapping software packages with dnf swap
Don’t run a remove command followed by an install; it’s very easy to break dependency chains. Bundle them instead. For example, to switch from MariaDB to MySQL while keeping all related packages intact:
sudo dnf swap mariadb-server community-mysql-server
DNF will calculate how to exchange these two packages within the same transaction. Shared libraries will be preserved instead of being accidentally deleted.
2. Multitasking with dnf shell
When you need to perform a complex sequence of operations—such as removing A, installing B, and upgrading C—and want the system to execute them in a single transaction:
sudo dnf shell
# You will enter an interactive environment:
> remove firefox
> install google-chrome-stable
> run
> quit
Everything only begins when you type run. DNF will aggregate all requests to find the most optimal solution.
Why does traditional dnf install often fail?
Typically, DNF operates on a safety-first mechanism: if package-B conflicts with package-A, it stops immediately. If you remove package-A first, dozens of other critical software pieces might be dragged into the removal “black hole.”
I once encountered a tricky case while changing audio drivers. If I removed the old set, Fedora insisted on deleting the GNOME Desktop due to overlapping dependencies. dnf swap solves this problem with an “Atomic Transaction” mechanism. The system understands: “I’m taking component A out and putting component B in immediately.” There is no gap that leaves the system vulnerable.
More flexible swap syntax
You can explicitly specify actions to avoid confusion when package names differ significantly:
sudo dnf swap --install new-package --remove old-package
Mastering dnf shell for “major surgeries”
Think of dnf shell as a transactional programming environment. Every command you enter is placed in a queue. This is extremely useful when installing B requires A to be gone, but removing A requires C to be installed as a replacement first. If you run these as separate commands, you’ll fall into an endless loop of errors.
Essential commands in the shell:
config: Change DNF settings (like disabling GPG checks) during the session.repo enable [reponame]: Temporarily enable a repository just for this transaction.transaction list: Inventory the list of tasks about to be performed.
Typical example: Switching from ffmpeg-free (Fedora’s stripped-down version) to the full version from RPM Fusion for smoother video processing:
sudo dnf shell
> --setopt=strict=0
> remove ffmpeg-free
> install ffmpeg
> run
Note: --setopt=strict=0 makes DNF more flexible when handling conflicting libraries like libavcodec-free.
Real-world experience from my personal machine
Here are a few tips to help you avoid having to reinstall your system after “tinkering” deep under the hood:
1. Always have a backup plan with dnf history
If apps act up after a swap, don’t panic. DNF has excellent “time travel” capabilities:
sudo dnf history
sudo dnf history undo [ID]
This command will return your machine to the exact state it was in before the swap was performed.
2. Avoid touching core libraries
While dnf swap is powerful, never foolhardily swap packages like glibc or the kernel. These components are the backbone of the system; a single mistake can cause an immediate system hang.
3. Cleaning up leftovers
After swapping, old dependencies sometimes remain on the machine as “orphans.” Run the following command to keep your system lean:
sudo dnf autoremove
Hopefully, this article gives you more confidence when you need to intervene deeply in Fedora. Instead of fearing bright red “Conflict” errors, use swap and shell to handle them like a true pro!

