How to empty the trash can through the terminal

Written by kristen waters
  • Share
  • Tweet
  • Share
  • Email

Some Linux and Unix desktop environments include a Trash folder that works like the Windows Recycle Bin. When you delete a file from the desktop environment, it goes into the Trash folder. If you later realise that you deleted the file in error, you can restore it to its original folder. If you cannot delete the contents of the Trash folder through the graphical interface, you can locate the file through the command line and forcefully empty the directory as the root user.

Skill level:


  1. 1

    Open a terminal window. The terminal can be found under the Applications menu or by right-clicking on the desktop. The window should open with a command prompt in your home directory.

  2. 2

    Type the command "find . -name "*Trash" to locate the Trash directory. The Trash directory is usually found at "/home/user/.Trash" or "/home/user/.local/share/Trash", depending on the distribution and desktop environment you are using. Replace "user" with your user name.

  3. 3

    Type the command "cd .Trash/" to navigate into the Trash directory. Replace ".Trash/" with the directory found in the output from the find command in the previous step.

  4. 4

    Type the command "su -" to become the root user. Type the root password when prompted. Ubuntu and Linux Mint users type the command "sudo" before the next command and skip this step.

  5. 5

    Type the command "rm -rf *" to remove all the files and folders within the directory.

  6. 6

    Type the command "exit" to close the root session. Skip this step if you are using a Ubuntu or Linux Mint system.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.