{"id":16045,"date":"2022-03-18T23:59:27","date_gmt":"2022-03-18T23:59:27","guid":{"rendered":"https:\/\/linuxways.net\/?p=16045"},"modified":"2022-03-18T23:59:27","modified_gmt":"2022-03-18T23:59:27","slug":"how-to-delete-a-file-in-ubuntu","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-delete-a-file-in-ubuntu\/","title":{"rendered":"How to Delete a File in Ubuntu"},"content":{"rendered":"<p>From time to time, our system accumulates plenty of unnecessary files that we do not need. These files consume a lot of space in your system. To free up the storage space, you must find and delete those unnecessary files from your system.<\/p>\n<p>In today\u2019s post, we will explain how to delete a file in Ubuntu. The method explained here can be followed in any Linux distribution.<\/p>\n<h2>Delete File in Ubuntu<\/h2>\n<p>In Ubuntu, you can delete a file either through the command line using the rm command or through the File Manager. However, note that the rm command does not move the deleted files to Trash. Instead, it permanently deletes the files. If you have mistakenly deleted the file, you can only recover it from the backup. On the other hand, if you delete a file through File Manager, it will first go to Trash. From the Trash, you can decide to either restore the file or remove it permanently.<\/p>\n<h3>Delete a Single File<\/h3>\n<p>To delete a file in Ubuntu, use the below syntax:<\/p>\n<pre>$ rm &lt;filename&gt;<\/pre>\n<p>If a file is not present in the current Terminal directory, provide the location of the file. For instance, to delete a file <strong>test.txt<\/strong> located in the Documents directory, we can use the below command:<\/p>\n<pre>$ rm ~\/Documents\/test.txt<\/pre>\n<h3>Delete Multiple Files<\/h3>\n<p>To delete multiple files, use the below syntax:<\/p>\n<pre>$ rm &lt;filename1&gt; &lt;filename2&gt; &lt;filename3&gt;<\/pre>\n<p>For instance, to delete three text files <strong>file1.txt file2.txt, <\/strong>and<strong> file3.txt<\/strong> placed in our current Terminal directory, the command would be:<\/p>\n<pre>$ rm file1.txt file2.txt file3.txt<\/pre>\n<p>You can also delete multiple files using the wildcard character (*). For instance, to delete all the files ending with the <strong>.tar<\/strong> extension, the command would be:<\/p>\n<pre>$ rm *.tar<\/pre>\n<p>This command will remove all the archive files ending with the<strong> .tar<\/strong> extension.<\/p>\n<h3>Prompt before deleting a file<\/h3>\n<p>The rm command with the <strong>-i<\/strong> option prompts for approval before deleting a file.<\/p>\n<pre>$ rm -i &lt;filename&gt;<\/pre>\n<p>When it prompts for approval, hit <strong>y<\/strong> to delete the file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"466\" height=\"84\" class=\"wp-image-16046\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-86.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-86.png 466w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-86-300x54.png 300w\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" \/><\/p>\n<h3>Delete write-protected file<\/h3>\n<p>The rm command by default prompts for confirmation before deleting a write-protected file.<\/p>\n<pre>$ rm &lt;filename&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"575\" height=\"46\" class=\"wp-image-16047\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-87.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-87.png 575w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-87-300x24.png 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/p>\n<p>If you want to forcefully delete the file without prompting, use the rm command with the <strong>-f<\/strong> option.<\/p>\n<pre>$ rm -f &lt;filename&gt;<\/pre>\n<p>This command will not ask for your approval before deleting the write-protected file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"384\" height=\"43\" class=\"wp-image-16048\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-88.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-88.png 384w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-88-300x34.png 300w\" sizes=\"auto, (max-width: 384px) 100vw, 384px\" \/><\/p>\n<h2>Delete file graphically<\/h2>\n<p>Those who do not like the command line can use a graphical method for deleting a file. To delete a file graphically, launch the file manager. Right-click the file and select <strong>Move to Trash<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"418\" class=\"wp-image-16049\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-89.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-89.png 890w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-89-300x141.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-89-768x361.png 768w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/p>\n<p>Another way to delete a file is to first select it and then hit the <strong>Delete<\/strong> key.<\/p>\n<p>To delete multiple files simultaneously, select all of them and follow the above procedure.<\/p>\n<p>By doing so, the file will be deleted from your system. As explained earlier, this method does not permanently delete the file. If you later want your file back, you can get it back from Trash. To delete the file from your system permanently, remove it from the Trash too.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"889\" height=\"461\" class=\"wp-image-16050\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-90.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-90.png 889w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-90-300x156.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/03\/word-image-90-768x398.png 768w\" sizes=\"auto, (max-width: 889px) 100vw, 889px\" \/><\/p>\n<p>In this post, we covered how to delete a file in Ubuntu using the command line and graphical methods. Using either of the methods described here, you can easily delete unwanted files from your system and free up storage space.<\/p>","protected":false},"excerpt":{"rendered":"<p>From time to time, our system accumulates plenty of unnecessary files that we do not need. These files consume a lot of space in your system. To free&hellip;<\/p>","protected":false},"author":1,"featured_media":16061,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[934,31],"class_list":["post-16045","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-file","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16045","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=16045"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16045\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/16061"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=16045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=16045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=16045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}