Removing Directories using the Terminal

Just been playing around with an SDDM theme in Plasma that I want to remove. Normally modern SDDM themes have a wastebin icon to remove them but this was an old one from 2015 and the wastebin icon greyed out.

So the first thing in the terminal i did was to su to 'root' (I should point out that this may not work in Zorin as 'root' password is usually hidden, I am basing this on MX-Linux KDE Plasma which allows you to create a separate password for 'root' at point of install).

cd ..

to the directory where you are wanting to remove [NB you can't remove a directory which contains files! You have to remove the files first before you can remove the directory], in this example it was /usr/share/sddm/themes

Once there, open the theme's directory to remove the files inside the directory with:

rm *.*

this removed all the files apart from .user and LICENSE.


rm .user

I then wanted to remove the empty directories but could not. After research I needed to enter the command


[this is dependent upon a package xutils-dev ]


sudo apt install xutils-dev

after installation


removes the empty directories.

I'm using Linux for ages, never played around with themes and also never heard about "cleanlinks" and the ubuntu wiki in my native language doesn't even know about it (and it never failed me for Debian :grin: - but it knows "GitHub - brandt/symlinks: symbolic link maintenance utility").

It says, to delete a folder and everything in it (even folders and files), do this:

rm -r [foldername]

So, yes, a folder with something in it can completely be removed. Otherwise Linux would be worse than DOS.

1 Like

If you want a little speed, without prompting for each file, you can use:

rm -fr [foldername]

If you install Nautilus Admin:
sudo apt search nautilus-admin

nautilus-admin/focal,focal,now 1.1.9-3 all [installed]
  Extension for Nautilus to do administrative operations

... you can delete directories that still have files in them. I found this out as I was purging extraneous fonts from my system... the purge would leave behind the font directories because a .UUID file remained in each directory.

I'm going to check out cleanlinks, to be sure I don't have any dangling symbolic links. Usually, I just find the symbolic link and delete it manually.