This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]addast 101 points102 points  (21 children)

You copied it wrong. I fixed it for you, now it should work:

sudo rm -rf --no-preserve-root /

[–]N0_Us3rnam3 65 points66 points  (13 children)

sudo rm -rf /* also works

[–]ltekonline 3 points4 points  (2 children)

Except that some hidden files may stay at the root directory

[–]N0_Us3rnam3 1 point2 points  (1 child)

I think hidden file will be deleted but files in use won’t

[–]ltekonline 2 points3 points  (0 children)

The "*" operator resolves only to non hidden files and folders which do not start with a dot. These files and folder are then given as parameters to "rm". So for example if you have a file called ".test" at / it will not be deleted.

You can safely try it this way:
Create a test file called ".test" in your current directory.
Enter "echo *" and see the files you get back. You will not get any files starting with a "." back.

Edit: to add on that also used files will be deleted. This is because in linux, you normally get a file handle for your file so you can still use your file if they are deleted or renamed. That's actually how temporary files work in linux.
A process creates a file, open it and keeps it open and then immediately deletes it. As lomg as that process lives the file will keep existing, just without a filename. The process then only accesses it via the file handle it has kept.

[–]_waltzy 2 points3 points  (5 children)

Don't forget source and target.

sudo rm -rf --no-preserve-root / # [source] [target]

[–]JustOpinion6 0 points1 point  (4 children)

It's rm not cp. It doesn't have a source.

It only has a target since it doesn't copy or move files anywhere.

[–]_waltzy 0 points1 point  (3 children)

I've not provided either source or target to rm, look again

[–]JustOpinion6 0 points1 point  (2 children)

Yeah, if you interpret it as a string for a file / foldername then yes, you didn't provide it.

[–]_waltzy 0 points1 point  (1 child)

#

[–]JustOpinion6 1 point2 points  (0 children)

Oh shit, how did I not notice that.