Sunday, 13 April 2014

Empty Trash quickly from Command Line in Linux



I find it useful to be able to quickly delete the Trash on any Linux box I am working on. To do this is straight forward on Ubuntu, Linux Mint or Arch Linux.

Where Trash Resides

  • List your Trash files under :
$ ls -la ~/.local/share/Trash/
  • The 'files' sub-directory is the actual files 
  • The 'info' sub-directory is the metadata for each file
  • The 'expunged' sub-directory can have have content when a folder that belongs to you but contains files that don't is deleted

Manual Method 

  • You can manually remove :
 $ rm -rf ~/.local/share/Trash/files/*
 $ rm -rf ~/.local/share/Trash/info/*
 $ rm -rf ~/.local/share/Trash/expunged/*

trash-cli package

  • Recommended method
  • Install
$ sudo apt-get install -y trash-cli
  • Foe arch install from the AUR 
  • List trash contents
$ trash-list
2013-07-20 15:06:23 /home/lclark/tmp/experimental

  • Empty trash
 $ trash-empty
  • List contents and its empty
 $ trash-list
  • Enjoy !

No comments:

Post a Comment