Linux Tutorial

How to Delete File in Linux by using command and GUI


Are you new for Linux and even don’t know “how to delete file in Linux Ubuntu 19.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.

Article Contents:

How to delete file in Linux

Be extra careful, When you delete file 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.

$rm /path/to/file

If you are removing the file from current directory use rm command followed by filename only:

$rm filename

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 current directory use rm command followed by file names seperated 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

$rm java*

If you want to delete all .pdf files then syntax will be:

$rm *.pdf

It is recommended to list all files using ls command before using a wildcard, and use -i option with the rm command.

i 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 graphical interface as well.

Right click on file > Move to Trash


Delete file by GUI can be recovered, because deleted file is saved in Trash. After deleting from trash it goes out of system.



By Now, You know lots of about deleting file, you can use cautions to delete a file in linux by command line interface. if you are using GUI no problem you can get back after deleting file.

How do you like this article tell me in comment box? If you have any question, you can put in comment box.

If you want to contact me mail at [email protected]

If Appreciate My Work, You should consider:

Skip to toolbar