Fedora Silverblue doesn’t come with
dnf because it’s an immutable operating system and uses a special tool called
rpm-ostree to layer packages on top instead.
Most terminal work is designed to be done in containers with
toolbox, but I still do a bunch of work outside of a container. Searching for packages to install with
rpm-ostree still requires
dnf inside a container, as it does not have that function.
I add these two aliases to my
~/.bashrc file so that using
dnf to search or install into the default container is possible from a regular terminal. This just makes Silverblue a little bit more like what I’m used to with regular Fedora.
cat >> ~/.bashrc << EOF alias sudo="sudo " alias dnf="bash -c '#skip_sudo'; toolbox -y create 2>/dev/null; toolbox run sudo dnf" EOF
If the default container doesn’t exist,
toolbox creates it. Note that the alias for
sudo has a space at the end. This tells
bash to also check the next command word for alias expansion, which is what makes sudo work with aliases. Thus, we can make sure that both
sudo dnf will work. The first part of the dnf alias is used to skip the
sudo command so the rest is run as the regular user, which makes them both work the same.
We need to source that file or run a new bash session to pick up the aliases.Continue reading Making dnf on Fedora Silverblue a little easier with bash aliases