Linux: delete directory - the right Linux command
If you are new to Linux and not that experienced, the basic Linux commands are new territory for you. Deleting a file or directory is easily done through the terminal. To do this, use "rm", which stands for "remove". For a folder, you need to call it recursively.
How to delete a directory in Linux
If you want to delete a directory, you don't need many different commands in Linux. You only need one command and two options.- Open a terminal by pressing Ctrl + T.
- In the terminal, you can now use "cd <folder name>" to change to the folder with the name <folder name>. "cd" stands for "change directory".
- With "cd ..." you change again one directory up, that is, in the folder that contains the folder in which you are.
- To delete a file, navigate to the corresponding parent folder and use the command "rm <filename>". You can also enter only the beginning of the file name and then let it complete with a tap on the Tab key.
- Normally, you must now confirm this operation with a "y" for "yes". You can get around this by appending a "-f" to the command. "f" here stands for "force" and means delete without asking. Der Befehl wird also zu „rm -f <Dateiname>“.
- Wollen Sie nun ein ganzes Verzeichnis löschen, nutzen Sie den Befehl „rm -rf <Ordnername>“. Das „r“ steht für „recursive“ und bedeutet, dass der Befehl „rm“ für diesen Ordner und alle seine Unterordner durchgeführt wird.