How to delete files in Ubuntu

Ubuntu is a Linux operating system in which we can store different types of files. To free up space on the system, we need to delete some unnecessary or corrupted files. In Ubuntu, we can remove unnecessary files from the system using the “rm” command, or remove the link using the command line interface.

There are two types of files; Program files and data files. Program files contain program instructions that can be executable. Data files contain simple information. Files can be distinguished by their extensions, for example PDF files will have the extension “.pdf” and text files will have “.txt”. We can save, move, update or delete files on the system.

In this article, we will discuss how to remove unnecessary files or files from the system to free up storage using Ubuntu Linux commands. Follow the instructions to successfully remove the file from the system.

Deleting files in Ubuntu using rm command

The rm command is used to remove files from the system at the same time.

Syntax:

$ rm [options] filename/filenames

Removing a file using the rm command: Run the following command to remove the “linux.txt” file from the current directory:

$ rm linux.txt

The ls command is used to list all files in the current directory to check if the file to be deleted exists:

Now run the below command to check if the file has been deleted by displaying all files in the current directory:

$ ls

Now, from the above image, we can see that “linux.txt” no longer exists in the current directory.

Removing multiple files at once: Run the command below to remove “linux1.txt” and “linux2.txt” from the current directory:

$ rm linux1.txt linux2.txt

Change the file names “linux1.txt, linux2.txt” according to your requirements. The ls command is used to list all files in the current directory to check if the files to be deleted exist.

Now run the below command to check if a file is deleted or not by displaying all files in the current directory:

$ ls

We see that “linux1.txt, linux2.txt” no longer exists in the current directory.

Delete all files of the same type: To delete all files of the same type, use the wildcard

$ rm *.txt

and standard extensions. Run the command below to remove all .txt files from the current directory:

The ls command is used to list all files in the current directory to check if the files to be deleted exist.

$ ls

Now run the below command to check if the file has been deleted by displaying all files in the current directory:

There are no more .txt files left in the directory as shown above.

$ rm –i /home/alishba/Desktop/andreyex.txt

Deleting files with confirmation: Before deleting a file, use the rm command with the -i parameter, to confirm it, run the command below to delete “grayex.txt” from the desktop directory after confirming the deletion:

Specify a file path to delete a file that is not in the current directory. The ls command is used to list all files in the desktop directory to check if the files to be deleted exist. You must enter “yes” to confirm the deletion of the file.

$ ls

Now run the below command to check if the file has been deleted by displaying all files in the current directory:

Deleting files in Ubuntu using the unlink command

The unlink command is also used to delete one file at a time.

$ unlink linux.txt

Removing a file from the current directory: Run the command below to remove the “linux.txt” file from the current directory:

The ls command is used to list all files in the desktop directory to check if the files to be deleted exist.

$ ls

Now run the below command to check if the file has been deleted by displaying all files in the current directory:

Deleting files in Ubuntu through a GUI

If you are a beginner and don’t know how to use the command line correctly, you can also delete files using the GUI method as shown below:

Step 1. Open the location of the file.

.ud73bd7c54aab07714192b46521d9e421, .ud73bd7c54aab07714192b46521d9e421 .postImageUrl, .ud73bd7c54aab07714192b46521d9e421 .centered-text-area {min-height: 80px; position: relative; } .ud73bd7c54aab07714192b46521d9e421, .ud73bd7c54aab07714192b46521d9e421: hover, .ud73bd7c54aab07714192b46521d9e421: visited, .ud73bd7c54aab077d192b } .ud73bd7c54aab07714192b46521d9e421 .clearfix: after {content: “”; display: table; clear: both; } .ud73bd7c54aab07714192b46521d9e421 {display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: # E67E22; box-shadow: 0 1px 2px rgba (0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba (0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba (0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba (0, 0, 0, 0.17); } .ud73bd7c54aab07714192b46521d9e421: active, .ud73bd7c54aab07714192b46521d9e421: hover {opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: # D35400; } .ud73bd7c54aab07714192b46521d9e421 .centered-text-area {width: 100%; position: relative; } .ud73bd7c54aab07714192b46521d9e421 .ctaText {border-bottom: 0 solid #fff; color: # ECF0F1; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .ud73bd7c54aab07714192b46521d9e421 .postTitle {color: # 2C3E50; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .ud73bd7c54aab07714192b46521d9e421 .ctaButton {background-color: # D35400! important; color: # ECF0F1; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url (https://andreyex.ru/static/plugins/intelly-related-posts/assets/images/simple-arrow.png) no-repeat; position: absolute; right: 0; top: 0; } .ud73bd7c54aab07714192b46521d9e421: hover .ctaButton {background-color: # E67E22! important; } .ud73bd7c54aab07714192b46521d9e421 .centered-text {display: table; height: 80px; padding-left: 18px; top: 0; } .ud73bd7c54aab07714192b46521d9e421 .ud73bd7c54aab07714192b46521d9e421-content {display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .ud73bd7c54aab07714192b46521d9e421: after {content: “”; display: block; clear: both; }

Step 2: Delete the file.

Now, to delete a specific file, right-click on it, a dropdown will appear, select the “Move to Trash” option from the list, and your file will be deleted.

And the file will no longer be in the folder.

Conclusion

Computer files are digital storage media in systems, just like paper files and folders. There are several types of files with different extensions, for example .txt, .pdf, .doc and many others. You can save, delete, modify, copy and move files using Linux commands. In this article, we have explained how to remove files from Ubuntu (Linux OS) using rm and unlink command. To get additional storage space on your system, please read the article carefully to successfully delete unneeded files using any of the commands above.

Related Posts