What does "rm -rf linux" do?

  • rm is command to remove/delete stuff.
  • -rf is two options joined together
  • -r for recursive removal ( typically used with directories) - -f to force the action
  • linux in this command is either a file or directory.

Therefore, this command reads delete folder called linux. If the command really comes from a tutorial on uninstalling an application, likely that application has files that are specific to Linux and other files specific to other OS. Some applications don't have a .deb package and don't have installation scripts; essential files are compressed in a zip or tar archive, and deleting the files extracted from those archives is sufficient. Hence why this command is suggested.

However, you may see another command, which looks similar and somewhat dangerous: rm -rf /. This is intended to recursively delete everything (!) from hard drive partition where root filesystem is installed (in Windows terminology it would be "delete everything from C:\ drive). This command might be intentionally ( maybe maliciously ) suggested to newbies or clueless users as a way to uninstall Linux, but it doesn't uninstall an operating system, technically speaking not without loss of data. Uninstalling an operating system differs from uninstalling an application.


rm -rf linux deletes (unlink(2)) the file named linux from the current directory (the directory from which the command is run).

If the file happens to be a directory, it removes the directory recursively (-r) i.e. removes everything inside that directory too.

Also it does the removal forefully (-f) i.e. no user confirmation is required and if the file happens to be not present, no error is shown, the exit status will be 0 always (without -f, an error will be shown for the non-existent file and the exit status will be 1).

Tags:

Command Line