O'Reilly logo

Practical Linux by Bill Ball, John Ray, Michael Turner, M. Drew Streib

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deleting Files and Directories

Removing files and directories is another common task when using Linux and should be performed with care. Deleted files and directories are irrevocably lost. This is a great reason to always maintain backups of important files or directories.

Deleting Files with the rm Command

The rm (remove) command is used to delete files and directories. You delete files by including a single filename or several filenames on the command line, like so:

$ rm sentmailJune1998 sentmailJuly1998 sentmailAugust1998

Use wildcards to delete multiple files:

$ rm *1998

The rm command with the -r (recursive) can also be used to delete files within a specified directory. If you attempt to delete a directory without this option, the rm

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required