{"id":11578,"date":"2019-03-14T13:42:47","date_gmt":"2019-03-14T13:42:47","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11578"},"modified":"2019-03-14T13:42:47","modified_gmt":"2019-03-14T13:42:47","slug":"how-to-automatically-empty-the-trash-in-ubuntu","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/how-to-automatically-empty-the-trash-in-ubuntu\/","title":{"rendered":"How to Automatically Empty the Trash in Ubuntu"},"content":{"rendered":"<p>If you want to set your Ubuntu system to automatically take care of your system Trash over a particular period of time, you can make use of the command line utility called autotrash. Autotrash is a utility that looks in a FreeDesktop.org Trash folder for information on its contents and then purges a part of the trash depending on your specified options.<\/p>\n<p>In this article, we will explain how to install, seek help on, and use the autotrash utility. We will elaborate on the procedure by presenting some examples that will help you with the widely used functions of this utility.<\/p>\n<p>We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.<\/p>\n<h2><strong>Install Autotrash through the Command line<\/strong><\/h2>\n<p>We will install the autotrash command line utility through the Terminal application. You can launch the Terminal either through the system application launcher search or the Ctrl+Alt+T shortcut. Please note that only an authorized user can add\/update, remove and configure software in Ubuntu.<\/p>\n<h3><strong>Step1: Update your system\u2019s Repository Index<\/strong><\/h3>\n<p>In order to install the latest version of a software available in Ubuntu\u2019s Internet repositories, your system\u2019s repository index needs to be up-to-date.<\/p>\n<p>Run the following command as sudo in order to update your system\u2019s local repository index with that of the Internet.<\/p>\n<pre>$ sudo apt-get update<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4144 lazy-loaded\" src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-46.png\" sizes=\"auto, (max-width: 643px) 100vw, 643px\" srcset=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-46.png 643w, https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-46-300x154.png 300w\" alt=\"Update Ubuntu Repository\" width=\"643\" height=\"331\" data-lazy-type=\"image\" data-src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-46.png\" data-srcset=\"\" \/><\/p>\n<p>The system might ask you for the password of sudo. Enter the password and your command will take action.<\/p>\n<h3><strong>Step 2: Install autotrash<\/strong><\/h3>\n<p>Now, you can install the autotrash utility by running the following command as sudo in your Terminal application:<\/p>\n<pre>$ sudo apt-get install autotrash<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4145 lazy-loaded\" src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-47.png\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" srcset=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-47.png 599w, https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-47-300x114.png 300w\" alt=\"Install Autotrash\" width=\"599\" height=\"228\" data-lazy-type=\"image\" data-src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-47.png\" data-srcset=\"\" \/><\/p>\n<p>The system might prompt you with a Y\/n option before starting the installation procedure. Please enter Y to continue.<\/p>\n<h3><strong>Step 3: Verify autotrash installation (optional)<\/strong><\/h3>\n<p>You can check the version number of your installed autotrash software and also verify if it is indeed installed on your system. Run the following command to do so:<\/p>\n<pre>$ autotrash --version<\/pre>\n<p>Or,<\/p>\n<pre>$ autotrash -V<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4146 lazy-loaded\" src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-48.png\" sizes=\"auto, (max-width: 491px) 100vw, 491px\" srcset=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-48.png 491w, https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-48-300x86.png 300w\" alt=\"Verify autotrash installation\" width=\"491\" height=\"140\" data-lazy-type=\"image\" data-src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-48.png\" data-srcset=\"\" \/><\/p>\n<p>You are now ready to use autotrash on your Ubuntu.<\/p>\n<h2><strong>How to use autotrash? (with examples)<\/strong><\/h2>\n<p>The autotrash help will tell you all you can do with this application. You can view the help as follows:<\/p>\n<pre>$ autotrash --help<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-4147 aligncenter lazy-loaded\" src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-49.png\" sizes=\"auto, (max-width: 682px) 100vw, 682px\" srcset=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-49.png 682w, https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-49-300x197.png 300w\" alt=\"Get help\" width=\"682\" height=\"447\" data-lazy-type=\"image\" data-src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-49.png\" data-srcset=\"\" \/><\/p>\n<p>For even more detailed information, you can view the manpage of autotrash by using the following command:<\/p>\n<pre>$ man autotrash<\/pre>\n<p>Now we will present some examples that will elaborate on how you can make the best use of this utility:<\/p>\n<h3>Example 1: Delete Files older than x number of days<\/h3>\n<p>This is the most widely used feature of autotrash. You can use the following command syntax to automatically remove the files residing in your system trash for x number of days:<\/p>\n<p><em>$ autotrash -d [days]<\/em><\/p>\n<p>For example, the following command will remove the files that have completed their 30 days in the trash can.<\/p>\n<pre>$ autotrash -d 30<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4148 lazy-loaded\" src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-50.png\" sizes=\"auto, (max-width: 425px) 100vw, 425px\" srcset=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-50.png 425w, https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-50-300x23.png 300w\" alt=\"Autotrash 30 days\" width=\"425\" height=\"33\" data-lazy-type=\"image\" data-src=\"https:\/\/vitux.com\/wp-content\/uploads\/2019\/03\/word-image-50.png\" data-srcset=\"\" \/><\/p>\n<p>This gives you enough time to restore any files that you might wish to, during 30 days.<\/p>\n<p>The following usage of the command lets you apply this feature for not only your trashed files but also deleted files of all the users using the system:<\/p>\n<p><em>$ autotrash -td [days]<\/em><\/p>\n<p>Example:<\/p>\n<pre>$ autotrash -td 30<\/pre>\n<h3>Example 2: Delete files based on free-space left<\/h3>\n<p><strong>Max-free<\/strong><\/p>\n<p>You can only use autotrash to purge files if there is less than M megabytes of free space left at the trash location. As an example, if you set this to 1024, then autotrash will only start to work if there is less than 1GB of free space in the trash. Till that time, autotrash will just exit normally without scanning the Trash directory.<\/p>\n<p>Example:<\/p>\n<pre>$ autotrash --max-free 1024 -d 30<\/pre>\n<p><strong>Min-free<\/strong><\/p>\n<p>Similarly, you can use autotrash to make sure there is a minimum of M megabytes of free space.<\/p>\n<p>Example:<\/p>\n<pre>$ autotrash --min-free 1024<\/pre>\n<p>You can even combine the two command to make sure that autotrash starts reading the trash if there is less than 2 GB of free space, and then keep a check on. The command will then remove files older than 30 days and also remove extra files to ensure that 1 GB of space is always available in the trash.<\/p>\n<pre>$ autotrash --max-free 2048 --min-free 1024 -d 30<\/pre>\n<h3>Example 3: Delete M number of megabytes<\/h3>\n<p>You can use the utility to purge at least M number off megabytes, deleting oldest trash addition first. This feature uses trash entries rather than the individual files.This means that if your oldest trashed item is a 1GB directory, and you request at least 10MB to be removed (M=10), autotrash will remove 1GB.<\/p>\n<p><em>$ autotrash \u2013delete M<\/em><\/p>\n<p>Example<\/p>\n<pre>$ autotrash --delete 1024<\/pre>\n<p>Now you do not need to worry about space wastage on your system because of the system trash The autotrash utility will automatically take care of clearing your unwanted files based on your defined criteria.<\/p>\n<p><a href=\"https:\/\/vitux.com\/how-to-automatically-empty-the-trash-in-ubuntu\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to set your Ubuntu system to automatically take care of your system Trash over a particular period of time, you can make use of the command line utility called autotrash. Autotrash is a utility that looks in a FreeDesktop.org Trash folder for information on its contents and then purges a part of &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/how-to-automatically-empty-the-trash-in-ubuntu\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Automatically Empty the Trash in Ubuntu&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11578","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11578","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11578"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11578\/revisions"}],"predecessor-version":[{"id":11579,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11578\/revisions\/11579"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}