Follow ZDNET: Add america arsenic a preferred source connected Google.
Linux makes interacting with your PC and your apps rather straightforward. Anything you tin bash connected proprietary operating systems similar Windows and MacOS, you tin bash with the open-source OS, from the elemental to the complicated.
Often, however, the simplest tasks tin beryllium a spot confusing, particularly erstwhile you're caller to something. For instance, however bash you delete a directory (aka "folder") connected Linux?
Also: The archetypal 8 Linux commands each caller idiosyncratic should learn
Sounds simple, right? It is! Just similar connected MacOS oregon Windows, deleting a directory connected Linux tin beryllium handled by anyone, careless of accomplishment level.
I'll amusement you 2 casual ways to bash this, and I'll besides see a bonus method that provides a much unafraid mode to delete a directory.
Method 1: From the record manager
What you'll need: The lone things you'll request for this are a desktop Linux organisation and a directory to delete. I'll show this connected Pop!_OS with the COSMIC desktop, but the process volition beryllium similar, careless of Linux distro oregon desktop environment.
I urge creating a trial directory to debar accidentally removing the incorrect one. To make a caller directory wrong the record manager, right-click connected immoderate blank spot successful a directory and click New Folder. If you're utilizing KDE Plasma, you'd right-click a blank spot successful the record manager and past click Create New > Folder.
Let's delete the trial directory you conscionable created. Open your record manager and find that directory.
Right-click the directory to beryllium deleted and past click Move To Trash. If you don't spot an introduction for Move To Trash, you should spot a Delete entry.
Deleting a record from wrong the Pop!_OS COSMIC record manager.
This process works for some bare directories and directories that location files/folders.
Also: My apical 5 password managers for Linux - and my favourite works connected Windows and MacOS too
You tin past bare your trash truthful the record is permanently deleted.
Method 2: From the bid line
Deleting a directory from the command line is simply a spot trickier, but not overly difficult. This is done with the rm command.
Open your terminal app
The archetypal measurement is to unfastened your terminal app.
Change into the close directory
Next, alteration into the determination that houses the directory to beryllium deleted. For instance, accidental the directory to beryllium deleted is located successful /home/jack/Documents. To alteration into that directory, contented the command:
cd ~/Documents
The ~/ is shorthand for your location directory.
Note: You don't have to alteration into the determination lodging the directory to beryllium removed. If you don't, you'll conscionable request to usage the afloat way to the directory to beryllium deleted.
Delete the directory
Let's accidental the directory to beryllium deleted is named TESTING. To delete that directory, careless of whether it's bare oregon contains files/folders, you would delete it with the command:
rm -rf TESTING
If you were to usage lone the bid rm TESTING, it would neglect due to the fact that you're deleting a directory. The -rf options are:
- r - recursive - deletes each files/folders wrong the directory and past deletes the directory itself.
- f - forces the deletion.
You don't person to usage the f option. For immoderate reason, I conscionable automatically usage it.
You could besides usage the interactive mode, which would be:
rm -ri TESTING
When deleting successful interactive mode, you volition beryllium prompted to OK each step.
Bonus method
For some, utilizing 1 of the supra methods isn't enough, particularly if a directory contains files with delicate accusation that request to beryllium deleted.
Also: 5 obscure Linux distros you've astir apt ne'er heard of - but should decidedly try
If that's the case, you'll privation to usage the shred bid to overwrite the interior files/folders with 1s and 0s and past delete the directory with 1 of the methods above.
The shred bid works similar this:
shred -u -z -n 3 FILE
Where FILE is the sanction of the record to beryllium deleted.
The supra options are arsenic follows:
- -u - Deallocate and region the record aft overwriting.
- -z - Add a last overwrite with zeros to obfuscate the shredding.
- -n X - (where X is simply a fig supra 3) indicates however galore iterations are utilized for the overwriting. The default is 3.
After you've shredded each of the containing files, delete the directory with your record manager oregon the rm command.

4 days ago
11






English (US) ·