Re: Of mice and men
- From: mwojcik@xxxxxxxxxxx (Michael Wojcik)
- Date: 23 May 2005 19:29:15 GMT
In article <19lr811kttloalebp3k156r3990jqd4rq6@xxxxxxx>, James Johnson <saildot.maryland@xxxxxxxxxxx> writes:
>
> Actually, to wipe all of the drives (because Unix doesn't differentiate
> different drives, they're each mounted to a directory name and called file
> systems or slices depending on flavor of Unix)
That's not really correct. Unix provides a single hierarchical file-
system representation. Files are maintained on filesystems, which
are data structures for representing collections of files and direct-
ories (or implementations for maintaining those structures - thus
"ext2 filesystem", "BSD Fast Filesystem", etc). The kernel maintains
a list of currently-available filesystems, which are called "mounted"
filesystems. One is the root filesystem, and its hierarchy of files
begins at the root of the kernel's filesystem representation - that
is, at "/". There may be zero or more additional mounted filesystems,
each of which is mounted at some directory ("mount point") of a
previously-mounted filesystem.
Drives are not filesystems. Drives are physical devices which may
hold all or part of the data of one or more filesystems. Unix does
expose physical drive devices, but not for the purpose of ordinary
filesystem access.
"Slice" is a term for an extent of the storage capacity of a drive,
like "partition" in the MS world. It's used by some Unixes. Other
Unix flavors allow filesystems to span disks (AIX has for more than
fifteen years, for example) and have no association between drive
"slices" and filesystems. Even on Unixes which do partition drives
into slices and restrict a filesystem to a slice, the terms shouldn't
be confused.
> you should log in as root and execute:
>
> rm -rf /*
>
> rm - remove
> -rf command switches telling it to be recursive (remove all
> subdirectories) and to force it (just do it without asking permission)
More precisely, the -r flag tells rm to:
- descend directories recursively, if permitted by filesystem access
controls (requires read and "execute"[1] permission on the subdirectory,
and read permission [to get the directory's contents] on the parent
directory); note that rm will not follow symbolic links that point to
directories
- remove empty directories (normally rm will not remove a directory),
if permitted (requires write for the parent directory)
- remove all files from any directories specified on the command line
or encountered during traversal of subdirectories, if permitted
(requires write permission for the parent directory)
This is crucially different from "remove all subdirectories" in its
various failure modes, as well as some of the more subtle semantic
differences.
And the -f flag tells rm to:
- remove read-only files (and other filesystem objects), if permitted
(requires write for the parent directory)
- suppress all prompting for confirmation
> / the root directory, everything in Unix mounts off of here
If it's mounted at all. "rm -rf /" won't touch unmounted filesystems,
for reasons that should be obvious.
> * the wildcard to remove all matches of any character number combination
No, it's a shell metacharacter (for pretty much every Unix shell),
which is expanded *on the command line* to every filename which
matches the rest of the path specification, except those beginning
with a "." character. That's a crucial distinction for many reasons.
In this particular case, for example, it means that the command "rm
-rf /*" will NOT remove any files beginning with "." in the root
directory.
The "correct" version of this command is simply "rm -rf /". No wild-
card is required; "/" is a directory, and "rm -rf" will recursively
remove whatever it can from each of the directories specified on its
command line, then try to remove those directories themselves.
Of course, this entire exercise is impractical anyway. Some direct-
ories may not be accessible even to the superuser without manually
changing their permissions. Some filesystems may be unmounted, or
mounted read-only. Removing directory entries doesn't remove file
data, so there's no "wiping" happening here.
And there's no reason to do it anyway. If you need to "wipe" a disk
for your own reuse, just partition it and use it; there's no need to
do any more. If you need to "wipe" it to keep some data confidential,
crush it or burn it - there's no point in doing any less.
Of course, "rm -rf /*" will still get you into trouble. Unix is
happy to let you shoot yourself in the foot. It gives you the loaded
gun and points it in the right general direction, in fact. That's
why it's important to know how things work in Unix, and not to just
memorize command lines and their intended consequences.
Or use one of those GUI things. I understand some people actually
like Konqueror and all that sort. My stepdaughter was horrified when
I fixed a problem on her iBook recently by opening a terminal window
and working from the command line (and even more so when I booted it
into single-user mode) - she thought "only PCs did that" - so clearly
some folks will use Unix for years without ever typing a single
command.[2]
1. On Unix, "execute" permission for a directory means the process
can set its current directory to that directory.
2. The downside, of course, is that when things go wrong (in this
case, Apple's half-assed printer subsystem), they're screwed. I see
this *all the time* with Macs. "Oh, my printer doesn't work anymore.
I have to get a new one." "Oh, that scanner never did work." "Oh,
Office doesn't run anymore - I need to reinstall OS X."
--
Michael Wojcik michael.wojcik@xxxxxxxxxxxxxx
Art is our chief means of breaking bread with the dead ... but the social
and political history of Europe would be exactly the same if Dante and
Shakespeare and Mozart had never lived. -- W. H. Auden
.
- Follow-Ups:
- Re: Of mice and men
- From: Richard
- Re: Of mice and men
- References:
- Re: Of mice and men
- From: Pete Dashwood
- Re: Of mice and men
- From: LX-i
- Re: Of mice and men
- From: Pete Dashwood
- Re: Of mice and men
- From: Donald Tees
- Re: Of mice and men
- From: Pete Dashwood
- Re: Of mice and men
- From: jce
- Re: Of mice and men
- From: Pete Dashwood
- Re: Of mice and men
- From: Michael Mattias
- Re: Of mice and men
- From: Pete Dashwood
- Re: Of mice and men
- From: Arnold Trembley
- Re: Of mice and men
- From: Pete Dashwood
- Re: Of mice and men
- From: James Johnson
- Re: Of mice and men
- Prev by Date: Re: Occurs Depending Memory Use
- Next by Date: Re: Of mice and men
- Previous by thread: Re: Of mice and men
- Next by thread: Re: Of mice and men
- Index(es):
Relevant Pages
|