{"id":16282,"date":"2022-03-30T10:33:15","date_gmt":"2022-03-30T10:33:15","guid":{"rendered":"https:\/\/linuxways.net\/?p=16282"},"modified":"2022-03-30T10:33:15","modified_gmt":"2022-03-30T10:33:15","slug":"how-to-empty-trash-in-ubuntu-from-command-line","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-empty-trash-in-ubuntu-from-command-line\/","title":{"rendered":"How to Empty Trash in Ubuntu from Command Line"},"content":{"rendered":"<p>When you delete a file in your system, it goes to Trash. Its purpose is to enable the users to restore the files that were deleted accidentally. However, when you empty the trash, all the files are deleted permanently. Emptying the trash on regular basis can help you to <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-free-up-disk-space-in-ubuntu-20-04-lts\/\">free up some disk space<\/a> on your system. On Linux systems, you can empty trash both using the graphical interface and the command line.<\/p>\n<p>In today&#8217;s post, we will show how to empty trash in Ubuntu from the command line (Terminal). This post is intended for the users who prefer the command line for handling their everyday tasks.<\/p>\n<p><strong>Note<\/strong>: The files or directories deleted by the rm command do not go into Trash. Instead, they are permanently removed from the system. Therefore, you should be careful before <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-delete-a-file-in-ubuntu\/\">deleting a file<\/a> or a <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-delete-a-directory-in-ubuntu-20-04\/\">directory<\/a> through <a href=\"https:\/\/linuxways.net\/de\/centos\/rm-command-in-linux\/\">the rm command<\/a>.<\/p>\n<h2>Method#1<\/h2>\n<p>In this method, we will empty the trash in Ubuntu through the Terminal using the rm command. You can open the Terminal in Ubuntu using the Ctrl+Alt+T shortcut. Let\u2019s get started.<\/p>\n<p>1. Navigate to the directory where trash files are stored. You can do so through the command below:<\/p>\n<pre>$ cd ~\/.local\/share\/Trash\/files\/<\/pre>\n<p>2. To view the deleted files that are stored in Trash, run the command below:<\/p>\n<pre>$ ls<\/pre>\n<p>3. To empty the trash, run the command below:<\/p>\n<pre>$ rm -rf *<\/pre>\n<p>Make sure you are in the <strong>~\/.local\/share\/Trash\/files\/<\/strong> directory before running the above command.<\/p>\n<p>This command will empty the Trash. You can verify this through the command below:<\/p>\n<pre>$ ls<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"627\" height=\"130\" class=\"wp-image-16283\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-225.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-225.png 627w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-225-300x62.png 300w\" sizes=\"auto, (max-width: 627px) 100vw, 627px\" \/><\/p>\n<h2>Method#2<\/h2>\n<p>In this method, we will empty the trash in Ubuntu through the Terminal using the trash-cli utility. You can open the Terminal in Ubuntu using the Ctrl+Alt+T shortcut. Let\u2019s get started.<\/p>\n<p>1. Install trash-cli utility through the command below:<\/p>\n<pre>$ sudo apt install trash-cli<\/pre>\n<p>Enter the sudo password. After you have entered the password, it will ask if you want to carry on the operation. Hit <strong>y<\/strong> and then the<strong> Return<\/strong> key.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1057\" height=\"418\" class=\"wp-image-16284\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-226.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-226.png 1057w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-226-300x119.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-226-1024x405.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-226-768x304.png 768w\" sizes=\"auto, (max-width: 1057px) 100vw, 1057px\" \/><\/p>\n<p>This will install the trash-cli utility on your Ubuntu system.<\/p>\n<p>2. To view the deleted files that are stored in Trash, run the command below:<\/p>\n<pre>$ trash-list<\/pre>\n<p>3. To empty the trash using the trash-cli utility, run the command below:<\/p>\n<pre>$ trash-empty<\/pre>\n<p>This command will empty the trash. You can verify this through the command below:<\/p>\n<pre>$ trash-list<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"714\" height=\"174\" class=\"wp-image-16285\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-227.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-227.png 714w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-227-300x73.png 300w\" sizes=\"auto, (max-width: 714px) 100vw, 714px\" \/><\/p>\n<p>This is how you can empty trash in Ubuntu from the command line. This task should be done regularly in order to free up some space in your system. If you find this task tedious, you can automate the procedure of emptying the trash. Visit this <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-automatically-empty-the-trash-in-ubuntu-20-04\/\">post<\/a> for the complete procedure.<\/p>","protected":false},"excerpt":{"rendered":"<p>When you delete a file in your system, it goes to Trash. Its purpose is to enable the users to restore the files that were deleted accidentally. However,&hellip;<\/p>","protected":false},"author":1,"featured_media":16322,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[159,31],"class_list":["post-16282","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-trash","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=16282"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16282\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/16322"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=16282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=16282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=16282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}