Are you new for Linux and even don’t know “how to delete
As you know the graphical environment is growing day by day, And now you can use a graphical interface to delete the file.
Trust me Command line interface is more interesting then GUI. Once you will be habitual of commands you never like press right/left click on objects through mouse of your computer.
Using the keyboard will give you an amazing experience. This is a royal experience for a Linux user.
This article is not about how to remove directory in Linux.
This article will only cover how to delete files using different methods.
- How to delete
- How to delete multiple files in Linux
- How to delete
- It is Recommended before delete file in Linux
- How delete file in Linux using GUI
How to delete
file in Linux
Be extra careful, When you delete a
To delete a single file use the rm command followed by the file path with the name.
If you are removing the file from current directory use rm command followed by filename only:
How to delete multiple files in Linux
To delete multiple files in single time use rm command followed by the file paths and names separated by space.
$rm /Path_to_file1 /Path_to_file2 /Path_to_file3
If you want to delete multiple files from
$rm filename1 filename2 filename3
How to delete a file with wildcards
If you want to delete all files with a specific prefix name, then you can use a wildcard (*). For example, remove all the files start with java from the current directory, use the following command
If you want to delete all .pdf files then syntax will be:
It is Recommended before delete file in Linux
It is recommended to list all files using ls command before using a wildcard, and use -i option with the rm command.
$rm -i filename
If you are facing any problem or error before deleting the file. use -f option to remove file forcefully.
-f command is so powerful, can remove write the protected file without prompt.
$rm -f filename
Delete File in Linux by using GUI
GUI is very lovely for new users, but not good for Linux experts. You can delete any file from the graphical interface as well.
Right-click on file > Move to Trash
Delete the file by GUI can be recovered because the deleted file is saved in Trash. After deleting from trash it goes out of the system.
By Now, You know lots of about deleting the file, you can use cautions to delete a file in Linux by the command-line interface. if you are using GUI no problem you can get back after deleting the file.
How do you like this article tell me in the comment box? If you have any question, you can put in the comment box.
If you want to contact me a mail at email@example.com