We outline how to remove a directory in Linux, and how to remove write-protected folders with steps for the terminal or file manager.
- Linux is an operating system like Windows. However, most Linux operating systems are free and can be configured much more freely.
- Linux is based on the Unix operating system, which is often used in data centers or universities.
- Linux was first made publicly available in 1991.
- To date, Linux is free and a so-called free operating system. This means that the source code is freely accessible and everyone can work on the further development.
- There are now numerous Linux variants such as the free Ubuntu or Mint . You can get both as a 32-bit and a 64-bit version. In addition, both have a stylish surface and are very reminiscent of Windows. So they are very well suited for entry-level users who are switching to Windows.
- The mascot and unmistakable distinguishing mark of Linux is Tux, a little penguin. You can often find this in programs that are compatible with Linux.
- The risk of getting viruses or malware is much lower with Linux. One of the reasons for this is that Linux is used by significantly fewer people. There are also far more security measures than under Windows.
Tip: You can also get free office packages such as OpenOffice or LibreOffice or the graphics program Gimp for Linux. In addition to a free operating system, you also have many free tools at your disposal. Internet browsers such as Firefox and email clients such as Thunderbird are also available for Linux . If you don’t want to directly delete your Windows partition, you can also install Ubuntu on a USB stick. How to leave a Discord server, create or delete one, change Discord nickname
How to remove a directory in Linux: The file manager
Deleting directories is no more difficult on Linux than it is on Windows – well, almost. In our instructions, we will show you how to remove directory in Linux and how you can also remove write-protected folders via the terminal or the file manager and remove non-empty directory Linux style.
How to compress a file using Windows, Zip or NTFS: step-by-step
If you want to delete all the files in a folder, it is more convenient to remove the entire directory. You don’t have to select each file individually and you save a lot of time. You also delete all the subdirectories it contains, using this method. On Linux, there are several approaches to deleting a Linux directory quickly and easily.
There are numerous Linux distributions that have different graphical interfaces, but often a similar structure. The method presented should work under Ubuntu, Fedora or Debian. The easiest way to remove Linxux directory is to use the file manager:
- In the file manager, navigate to the directory that you want to delete.
- Right-click on the directory and then click on the menu item “Move to the trash” in the context menu.
- With the menu item “Move to the trash” you can delete a directory under Linux.
- It can happen that certain directories can only be deleted with admin rights. Depending on which file manager you are using, it asks — similar to Windows — whether you should delete the directory with admin rights.
- If the file manager does not ask you, you have to start it via the terminal with “sudo” or “su”. This automatically gives you admin rights in the graphical file manager.
TIP: If you are not sure what the name of your file manager is, you can find the name in the file manager menu under Help, About, or ‘?’.
Delete Linux directory: using the terminal
There are various Linux commands for the terminal that have different functions. In addition to files, Linux directories can also be deleted using command commands.
- Open the file manager and navigate to the directory you want to delete. Alternatively, you can open the terminal directly and use the command “cd / path / to / the / directory” to go to the folder that contains the directory.
- Right-click on the window and the context menu will open. Select “Open in Terminal” here.
- After right-clicking in the file manager, the context menu appears with the option to open the terminal
- In the file manager, you can right-click to open the terminal with the preselected path to the directory.
- Use the command “rm -r” (abbreviation for remove) and then enter the directory name to delete the entire folder with all its contents.
rm -r [folder name]
Why do I have to use rm-r to delete?
When you delete a Linux directory, you also delete all files and subdirectories in it. So that you do not receive an error message, the command command must be extended by the addition “-r”. In this way, the directory and all the files it contains can be deleted recursively.
Put simply, deleting directories always requires the ” -r ” parameter as an option, which stands for recursion. So the correct command would be ” rm -r myfolder / “.
For this, it helps to understand the Linux logic: Even if a folder is a file, it is a special case of a file because it can contain other files. In this respect, the entire content of a folder must inevitably be deleted, which works via recursive deletion. And it doesn’t matter whether there are actually files in the folder or not.
An example: We want to delete the folder “Example folder” including all files and sub-folders in the directory ~ / Downloads . Assuming you are already in the ~ / Downloads directory , the following command must now be entered:
rm -r Example folder/
After deleting the directory, the ls command will no longer display the folder. So the folder was deleted.
This works in the same way as with files, especially since folders are also files under Linux — and yet there are two small restrictions : With a simple ” rm myfolder / ” the error message appears that it is a folder. Problems with missing rights can also arise. The general syntax is:
rm [OPTION] file/folder
The other possible error message refers to a lack of rights – in this case you must run the rm command with root rights . To do this, you can either switch completely to the “root” user – simply enter ” su ” and then your root password . Or you just execute the individual command with the appropriate rights: ” sudo rm -r myfolder / ” of course only works if your current user is in the sudo group. With Ubuntu , Mint and many other popular distributions, the sudo variant would be the standard, with Debian the permanent user change with su.
After you have issued the command, the program asks whether the folder should be “descended” (if it is a deeper subfolder) and whether the (write-protected) folder should really be deleted – confirm both with “Yes” (j) or “Yes” (y) . How to reduce PDF file size Mac or PC without extra software
Terminal command to delete a complete folder in Linux
With the command “rm” followed by “-r” and the folder name, you delete a complete folder including the files and subfolders it contains. As with the file manager, you can only delete certain directories in the terminal with admin rights . In this case, switch to the “root” user in the command line by entering “su” and your root password. Instead of changing users, you can alternatively type in the following command command to delete a Linux directory with admin rights:
sudo rm -r [folder name]
If you are not sure what the name of the manager is, just open it as normal and look at the top of the file menu under ” Help “, the ” ? ” Or ” About ” – under one of the points there is guaranteed to be the name of the program. That depends on the respective desktop environment, with the LXDE desktop the typical command would be ” sudo pcmanfm “. So started you should be able to delete pretty much anything. How to clone a Git repository: step-by-step guides for 3 ways
Ubuntu: delete directory in the terminal – here’s how
You can easily manage your files and directories under Ubuntu via the terminal.
- To delete a directory under Ubuntu , first start the terminal with the key combination [Ctrl] + [Alt] + [T] and navigate to the location where the desired folder is located.
- Then enter the command “rm -r directory”, replacing “directory” with the name of the directory to be deleted. If you confirm your entry, the directory will be deleted.
- The “-r” in the command means that all files in the selected directory will also be deleted.
- If you are not that familiar with the most important terminal commands in Ubuntu , you can always call up the terminal’s help with “man” and the corresponding command. In the case of deletion, this would be the command “man rm”, for example.
Delete Linux directory in Explorer
Files and directories can be deleted in Explorer just as easily as in the terminal.
- First, navigate in the Ubuntu Explorer to the location of the directory that you want to delete.
- Then click the folder, right -click on to open the context menu.
- Simply select “Delete” in the context menu – and the directory will be deleted.