I know that this is a very dangerous command, but what does it actually do. In other words, to what extend does it delete the hard drive. Does it delete only the user data? Or does it delete root OS files as well. If someone were to activate this command, would it break the OS? Running as sudo on Yosemite
The command itself is "rm", which is a program used to remove a file.
The "-rf" is the first argument to the program. Arguments can be thought of as "settings" or other information that you want the program to use while performing its task.
"-rf" is really a short hand for two seperate arguments, "-r" and "-f":
-r means that you want the program to not only remove files, but also directories, and that you want the program to remove not only the files/folders that you request, but also any subfolders and their contents.
-f means that you do not want to be prompted for confirmation on each delete, and that attempts should be made to delete every file/folder listed, no matter if you have permissions to do so orr not.
The last part of the command "/" is actually the list of what you want the program to delete. In this case "/" means the "root" (the top) of the file hierarchy. In practice this means to do delete everything on your system - including files on external drives that may be mounted.
The command does not discriminate between user data or operating system files. As long as you have permissions to delete a file/folder, it will be deleted.
When run as sudo (i.e. with root permissions) under Yosemite, it will break the system so that it doesn't function afterwards.
For newer versions of macOS, destruction will be limited by the SIP system that protects the operating system core. However, still do not run the command with sudo, as you risk ruining the system and deleting your own data.