Delete Files & Folders in Linux
![4.png](https://steemitimages.com/DQmWoVgKL7rVTweZWuneKVH8VLZJVEXn9mANwwa9aptyGww/4.png)
Hey this is just a quick tutorial how to delete files or folders in a Linux based OS. Of course it's just right-click and "Move to Trash", but I am going to show you the nerdy way in the console.
Remove 1 single file
To remove a single file the command rm
is used and after it write the filename with it's extension. Then hit Enter.
rm <filename.extension>
Remove an empty folder
rm --dir <foldername>
Remove a folder containing files
rm --dir -r <foldername>
That's it! It's this easy to remove files and folders in Linux, especially if you don't use a mouse and are stuck with a touchpad, it's probably quicker to type this in.
Sources:
https://pixabay.com
So interesting for me to read it. Amazing for your posting. I like it. Thank for your information @profitgeneration
For removing a folder containing files, rm -rf will also work i.e. removing recursively.
Thanks I didn't know that.
Welcome. Actually my profession is Weblogic Admin,so my day starts and ends with linux,haha
Yeah, sometimes permissions get weird and the only way to delete something is from the command line. I've had to clean up Windows installations by pulling the drive and docking it on a Linux PC.
Those recursive delete commands can get you in a lot of trouble, though. Got to make sure you know what you're asking for. (With great power comes great responsibility.)
If the folder has elevated privilege then it can be deleted with sudo. Sometimes folders copied over from foreign USB sticks or installed folders as backups have root locks on them, so if these need to be deleted then
sudo
access is needed.The recursive delete only works inside that folder, and it deletes everything inside it, so if you dont want all deleted, then just delete them manually 1 by one.