Quick tip: Empty trash from command line (Windows and Linux)

Emptying the trash or recycle bin can be done by right clicking on the icon and hitting the empty option. Almost everybody is familiar with this behavior but not everybody knows this can also be done from the command line.

Windows

All the contents of the recycle bin is stored in one directory. We just have to clear that directory.

Step 1:

Open a command prompt (Start + R to open the run window) and type cmd.

Step 2:

Type the command:

rd /s %systemdrive%$Recycle.bin

rd is short for “Remove Directory”. The /s parameter takes care of removing directory and files in the directory itself. %systemdrive% is an envrionment variable which contains the drive on which Windows is installed.

Linux

In linux the trash is stored on different locations, it might be ~/.local/share/Trash or some .Trash directories. In the repositories there’s a package available which takes care of this task.

Step 1:

Install the package from the repositories:

sudo apt-get install trash-cli

Step 2:

Run the command:

trash-empty

1 thought on “Quick tip: Empty trash from command line (Windows and Linux)”

Comments are closed.