🗑️

Linux 'rm' Command Usage

Jul 19, 2025

Overview

This lecture explains how to use the rm command in Linux to remove files and directories, emphasizing caution to prevent accidental deletion.

Removing Files

  • Use the rm command in Linux to delete files, similar to deleting files in Windows.
  • Example: rm text1 removes the file named "text1" from the current directory.
  • Attempting to remove protected files or directories may result in an error message.

Removing Directories

  • Directories (folders) require recursive removal with the rm -r command.
  • Example: rm -r misc deletes the "misc" directory and its contents.

Caution When Using rm

  • Accidentally deleting important files or folders is possible with rm, so always double-check the target before executing the command.

Key Terms & Definitions

  • rm — Command in Linux used to remove (delete) files and directories.
  • Recursive (-r) option — Allows rm to delete directories and their contents.

Action Items / Next Steps

  • Practice using the rm and rm -r commands in a controlled environment.
  • Always review the files or directories you are about to remove to avoid accidental deletion.