How to delete a folder in Linux

delete linux folder

For delete a folder in linux, it can be done in multiple ways, both from the graphical interface and from the command line, and you could even use different commands to delete one of these directories that you no longer want, whether it is full or empty. In this simple tutorial you will learn how to do it quickly. A tutorial for those new to GNU/Linux, and also for some users who have been a little longer and perhaps didn't know all the existing methods...

Of course, the most comfortable and easiest method of all is from your desktop environment, simply selecting the folder you want to delete, then right-clicking and in the drop-down menu you press Move to Trash or Delete, depending on the environment. This will make the directory and its contents go to the recycle bin if they aren't too big, so you can go to the bin and recover the contents if you want. If it is a directory of too many gigabytes, then it will ask you if you want to delete it permanently, since it cannot be contained in the trash, and it can no longer be recovered.

On the other hand, you also have some directories that you may need privileges to delete and you won't be able to do it from your file manager. Therefore, you should use terminal for it. From the command console you can do it in several ways, choosing one of these commands, the first to delete an empty folder and the second to delete a folder that is not empty:

rmdir nombre_carpeta

rmdir -r nombre_carpeta

Now, if what you want is simply delete all contents of the folder but leave the folder intact, in that case you can use these commands, the first to delete all the files inside the folder and the second to also delete the sub-folders that may exist:

rm /ruta/de/carpeta/*

rm -r /ruta/de/carpeta/*


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.