How to delete files?

QuestionsQuestions4 SkillsProBasic Files OperationsSep, 01 2025
0145

To delete files in a Unix-like operating system, you can use the rm command. Here’s how to do it:

Basic Command:

rm filename.txt

Breakdown:

  • rm: Stands for "remove," and it is the command used to delete files.
  • filename.txt: The name of the file you want to delete.

Important Options:

  1. -i: Prompts for confirmation before deleting each file.

    rm -i filename.txt
    
  2. -f: Forces deletion without prompting for confirmation.

    rm -f filename.txt
    
  3. -r: Deletes directories and their contents recursively.

    rm -r directory_name
    

Example:

To delete a file named example.txt:

rm example.txt

Warning:

Be cautious when using rm, especially with the -f and -r options, as deleted files cannot be easily recovered.

If you have any more questions or need further assistance, feel free to ask!

0 Comments

no data
Be the first to share your comment!