How To Delete Files And Folders Using Linux

Use the 'rm' command or your desktop environment's graphical tools

What to Know

  • Select the object and press Delete on the keyboard. Or, right-click the object and select Delete or Move to Trash.
  • Open the shell prompt. Enter the rm command followed by a space and the name of the file or folder.
  • In the GUI, deleted files and folders move to the Trash folder by default in case you want to recover them.

This article explains how to delete files and folders in Linux using your desktop environment's graphical tools or the rm command from a shell prompt.

Delete Files and Folders Graphically

Delete file in ubuntu

Although each desktop environment uses slightly different metaphors for file access, in general, you're generally free to delete files and folders by either:

  • Clicking the object then pressing Del.
  • Right-clicking the object then selecting the Delete or Move to Trash option, or its equivalent.

In the GUI, by default, deleted files and folders move to the Trash folder, from which they may later be recovered if you deleted them accidentally.

Remove Files From the Shell

rm command in linux

The rm command works from the shell prompt; its usage is the same regardless of your distribution or your desktop environment.

By default, the command looks like this:

rm file-to-delete

Command Options for 'rm'

The rm command accepts several options that influence how it executes:

  • -f: Ignores (force) non-existent files and arguments without prompting for confirmation.
  • -i: Prompt before each object deletes.
  • -r: Remove directories and their contents recursively.
  • -d: Remove empty directories.
  • -v: Display progress with verbose notifications.
  • --help: Displays a summary of the command's syntax and usage.


The rm command's delete capability does allow for file recovery with sufficient time and skill. To remove files permanently, use the shred utility.

From the shell prompt, rm supports wildcard patterns. Thus, to delete all files with a PDF extension, type:

rm *.pdf

In addition, rm unlinks hard and soft links.

Which Method Is Better?

The benefit of the GUI relates to ease-of-use, but each DE's file manager functions slightly differently. The rm command functions similarly across all distributions, but it works from the shell prompt.

Was this page helpful?