Quick Answer: How to Delete File Linux?
Contents

To remove (or delete) a file or directory in Linux from the command line, use the rm (remove) command.

Be extra careful when removing files or directories with the rm command, because once the file is deleted it cannot be recovered.

If the file is write protected you will be prompted for confirmation as shown below.

How do I delete a file?

Permanently delete a file

  • Select the item you want to delete.
  • Press and hold the Shift key, then press the Delete key on your keyboard.
  • Because you cannot undo this, you will be asked to confirm that you want to delete the file or folder.

How do I delete multiple files in Linux?

In order to remove one single file using the rm command, run the following command:

  1. rm filename. Using the above command, it will prompt you to make a choice of going ahead or back out.
  2. rm -rf directory.
  3. rm file1.jpg file2.jpg file3.jpg file4.jpg.
  4. rm *
  5. rm *.jpg.
  6. rm *specificword*
Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest