Are you new for Linux and even don’t know “how to delete in Linux Ubuntu 20.04″? Or Do you want to learn more options to delete files? Don’t worry.
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 in Linux
- How to delete multiple files in Linux
- How to delete with wildcards
- It is Recommended before delete file in Linux
- How delete file in Linux using GUI
How to delete in Linux
Be extra careful, When you delete a in Linux using the rm command because you can’t recover file once deleted by rm command.
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 directory use command followed by file names by space.
$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.
– expansion is used to prompting to ask confirmation before deleting each file. Syntax Use:
$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 firstname.lastname@example.org