Working with files is a fundamental skill that you should learn when working with Linux. In this tutorial, we will focus on how to create empty files and then delete them again. Whether through the graphical user interface or the terminal – you have various ways to do this effectively and easily.
Main takeaways
- You can create empty files using both the graphical user interface and the terminal.
- The command touch is a powerful method to create files in the terminal.
- Files can be deleted with the command rm, and wildcards can also be used.
- Using the -f option with rm ensures that no confirmation prompts appear.
Step-by-step guide
1. Creating empty files via the graphical user interface
If you are using the graphical user interface, simply navigate to the desired folder. Right-click in the empty space of the folder, and select the "New Document" option. Then you can choose "Empty Document". This creates an empty file that has no content and thus has a size of 0 bytes.

2. Creating empty files in the terminal
Creating an empty file in the terminal can be significantly simpler and faster. You use the command touch for this. To create a file, simply type touch followed by the desired filename. For example:
This creates an empty document named "Terminal_Document".

3. Checking if the file was created successfully
To ensure that the file was actually created, you can use the command ls. This shows you all files in the current directory. If everything went correctly, you should see your newly created empty document in the list.

4. Deleting files with rm
Deleting a file in the terminal is done using the command rm. To remove a file, type rm followed by the name of the file. For example, if you want to delete the document named "Terminal_Document", you would use:
After executing this command, the file will be permanently deleted.

5. Using wildcards to delete multiple files
If you want to delete multiple files at once, you can use wildcards. Let's say you have several files that share a common pattern in their names, like "Terminal_Document_1", "Terminal_Document_2", etc. You can delete all of these files with a simple command:
The asterisk (*) stands for any number of characters, so all files that start with "Terminal_Document" will be deleted.

6. Deleting specific files with placeholders
If you only want to delete certain files, for example, those with a specific number, you can use placeholders. For example, you can delete all files with "Terminal_Document" and the endings "60" and "70" in their names with the following command:
The question marks (?) stand for exactly one character, so this would only delete the files with two additional digits.

7. Confirmation option with rm
To ensure that you can delete files without prompts, you can use the -f (force) option. This means that the system will not request confirmation for the deletion. Thus, you can use the command like this:
This is useful in situations where you are sure that you do not want confirmation before a file is deleted.

Summary – Effective Guide to Creating and Deleting Files in Linux
In this tutorial, you learned how to create empty files using both the graphical user interface and the terminal and how to efficiently delete these files, utilizing wildcards and additional options like -f.
Frequently Asked Questions
How do I create a file with touch?You use the command touch followed by the filename, e.g., touch MyFile.
How do I delete a file in the terminal?With the command rm filename, you can delete a file.
What are wildcards?Wildcards allow you to use placeholders for characters to address multiple files at once.
How do I use the -f option when deleting?With rm -f filename, you delete a file without prompt.
How can I ensure that the file has been deleted?Use the command ls to check the directory after deletion.