Delete Files & Folders in LinuxsteemCreated with Sketch.

in #linux7 years ago

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>

1.gif


Remove an empty folder

rm --dir <foldername>

2.gif


Remove a folder containing files

rm --dir -r <foldername>

3.gif


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


Upvote, ReSteem & bluebutton


Sort:  

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.

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.031
BTC 60794.44
ETH 2623.30
USDT 1.00
SBD 2.62