Enhancing Skills

rm: Remove files or directories

Command: rm

Used to remove files or directories. Be careful with this command! It permanently deletes files without sending them to the trash.


Sample Command and Output:

$ rm file1.txt
$ ls

Description:

  • rm file1.txt: Removes file1.txt from the current directory.
  • ls: Lists the contents of the current directory to confirm that file1.txt has been deleted.

Sample Command and Output:

$ rm -r folder1/
$ ls

Description:

  • rm -r folder1/: Recursively removes the directory folder1 and all its contents. The -r option allows rm to delete directories and their contents.
  • ls: Lists the contents of the current directory to confirm that folder1 has been deleted.

Additional Arguments:

  • -i: Prompts before each removal.
  • -f: Forces the removal without prompting.
  • -v: Verbose mode, displays the files being removed.

Sample Command and Output:

$ rm -rf folder1/

Description:

  • rm -rf folder1/: Forcefully and recursively removes the directory folder1 and all its contents without prompting. The -rf combination is powerful and should be used with caution, as it can delete large amounts of data quickly and irreversibly.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.