Under Linux, all actions that you can carry out with the mouse and window system via the graphical user interface can also be performed using program calls in the terminal – provided you know the appropriate command and how to use it according to the correct syntax. To make working in the terminal easier, we provide you with an overview of basic Linux commands with detailed descriptions and...All important Linux commands
In Linux, you can easily delete single files, groups of files, or entire folders. However, this works differently in Linux than in Windows. Keep reading to find out about different methods for removing files in Linux.
Free VPS trial from IONOS
Test your vServer for free now - Try a virtual server for 30 days!
Deleting files in Linux with a file manager
Depending on the distribution and desktop environment you’re using, you’ll have Nautilus, Dolphin or another Linux file manager on your computer. Using these standard file managers, you can remove Linux files in just a few simple steps.
- Navigate in the file manager to the files that you want to delete.
- Hold down the left mouse button and select the files that you want to delete.
3. Right-click on one of the files to open the context menu. Depending on the distribution you’re using, you’ll find a menu item such as “Move to Trash” or “Delete File”.
Instead of right-clicking, you can simply press [Del] to remove the selected files.
Deleting files in Linux with the terminal
Considering the large array of commands available in the terminal, it’s no surprise that you can use the command line to delete files in Linux. To do so, complete the following steps:
- Open the file manager and navigate to the files that you want to delete. Alternatively, you can use the command “cd/path/to/the/file” to go directly to the files in the terminal.
- Right-click on the window to open the context menu, and then click on “Open in Terminal”.
3. Use the command “rm” (short for “remove”) to delete a single file or multiple files.
A closer look at the “rm” command
Depending on whether you want to delete a single file, multiple files, or all of the files of a certain file type, the “rm” command will look slightly different.
Deleting a single file
You can quickly and easily delete a single file with the command “rm” followed by the file name.
Deleting multiple files
To delete multiple files at once, simply list all of the file names after the “rm” command. File names should be separated by a space.
rm DeleteMe.odt DeleteMe2.odt
Deleting files with a specific file name
You can also remove all Linux files with a certain file name in the terminal.
Deleting files of a certain file type
If you have a folder that contains different file types and want to delete all the files of a certain type - for example, .pdf or .odt - simply enter the command “rm” followed by an asterisk and the file type.
In this case, you’ll delete all files with the ending .odt.
Deleting all the files in a folder
If you want to delete all of the files and subfolders of a certain folder, enter the following command into the terminal:
rm -r Files/*
In this case, all of the files in the folder “Files” will be deleted. The folder itself will remain. Of course it’s also possible to delete a Linux directory, including all the files it contains.
Your files are taking up too much space, but you still don’t want to delete them? It’s very easy to archive and compress files in Linux!