What does "rm -rf linux" do?
Solution 1:
-
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.
Solution 2:
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
).
Solution 3:
rm -rf linux
The above command deletes "linux" recursively if it is a folder else if it is a file , it just deletes the file. This command searches for the folder / file named "linux" in the current directory. You should be very careful while handling rm command because if you are working as a privileged user a misstyping like rm -rf / this could wipe your entire root partion. Man pages of rm command details about the arguments and short info is as follows :
rm -rf
rm Remove files (delete/unlink)
-f --force
ignore nonexistent files, never prompt
-r -R, --recursive
Remove directories and their contents recursively