We all know that we have to use the -rf option of rm command carefully. What I wonder is does Linux allow executing this command: rm -rf /? If so, why? This command could have disastrous consequences if allowed to run:It would delete everything including files on the hard drive and files on connected removable media devices. How can we remedy the situation, especially without the assistance of all the executable commands which would also be deleted?
Does Linux allow executing the rm -rf /  command?
linux;rm;command
You cannot run rm -rf /: you'll get the error permission denied. Only root can modify the root directory.If you run this command as root (e.g. with sudo rm -rf /), Linux actually refuses to run it. You need to pass a special option --no-preserve-root in order to call rm on /.You can still run dangerous commands, e.g. rm -rf ~ will delete all your files. It's like having a kitchen knife: it's very handy to cut all kinds of food, but if you point it towards your neck and push hard, you will get hurt.Fortunately, recovering from rm -rf ~ is easier than recovering from inserting a knife into your neck. You do have backups, right?