Hacker News new | ask | show | jobs
by zellux 5934 days ago

  # cd 
  # rm -rf *
I'm wondering why they can delete files under /bin and /dev?
2 comments

Because they are root and those are just files.

Perhaps they need to alias rm to 'rm -I' (-I : prompt once before removal)? I remember one of the MandrakeLinux versions had that enabled by default many years ago. It saved me a couple of times when I was still a Unix noobie.

"Because they are root and those are just files."

Just because you are root doesn't mean you should be able to do whatever you like to the filesystem at any time. Most modern unix variants (including linux) support file attributes such as immutability, see the man page for chattr(1) if you want more. In BSD land there is additionally the concept of Secure Levels which limit the ability of root to change file attributes under different circumstances; generally you have to reboot into single user mode to overwrite files or directories marked as immutable or delete ones marked as append_only.

According to the FreeBSD chflags(1) manpage:

  The chflags command first appeared in 4.4BSD.
Which puts it about seven years after this story.
"4.4BSD" isn't the same as FreeBSD 4.4, but actually version 4.4 of the original BSD which was released in June 1994.
OK, eight years, then. The timeline I found gave 1993 for 4.4BSD.
AFAIK a single cd command will set current working directory to /root, and rm -rf will only remove everything under /root. Or does cd command had different behavior in Unix at that time, comparing to shells today?
That sort of thing is why /root is now root's home directory.
The homedir of root was probably / on that system.
Did that version of BSD have secure levels? Updating systems where the system binaries are marked immutable can sometimes be a pain; but the comfort level it provides is remarkable.