Date: Sun, 23 Feb 2020 18:49:08 +0100 From: Polytropon <freebsd@edvax.de> To: Jos Chrispijn <bsduser@cloudzeeland.nl> Cc: freebsd-questions@freebsd.org Subject: Re: rm | Cleaning up recycle bin Message-ID: <20200223184908.b35d656a.freebsd@edvax.de> In-Reply-To: <a589bf69-a53b-a732-08ff-74e09b723bbd@cloudzeeland.nl> References: <a589bf69-a53b-a732-08ff-74e09b723bbd@cloudzeeland.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 23 Feb 2020 14:05:35 +0100, Jos Chrispijn wrote: > I read somewhere that using the rm command does not phsyically remove > the 'deleted' files when using the command in a terminal session. Can > you tell me how/where I can really remove these files (as per user > account or in general)? Thanks! The rm command _does_ remove the files entirely, i. e., the disk blocks allocated to a file will be marked "free", so any further write operation might claim them for a different file. The concept of a "recycle bin" is not present in FreeBSD's UFS filesystem. Deleted files are deleted, period. Recovery is possible as long as no further writes happen, but it's not a trivial task - yes, I've been able to experience that trouble first-hand). ;-) So if you use rm, and no process holds the file open, the disk space occupied by the file will be freed immediately; if some process still uses the file, its name will be removed (so you cannot address it by that name anymore), but the disk space will be freed when the process closes the file. So instead of going by the metaphor of the "recycle bin", just imagine a shredder, as in OS/2 GUI. :-) Note that tools like the Midnight Commander usually do the same as rm: If you PF8 (delete) a file, it's gone, and the same goes for whole directory subtrees. However, several desktop environments use a temporary directory to move "deleted" (quotes deserved!) files and directories there, and you need to find that directory and clean it manually, except there is a GUI element that says "empty recycle bin" (or the like), which you'll usually find in the context menu of the corresponding icon. _That_ step uses rm (or the underlying system call) to actually remove the files. See "man 1 rm" and "man 2 unlink" for details. If you want to know a little bit more about how this works on UFS, I suggest reading "A Fast File System for UNIX" by McKusick et al.: https://people.eecs.berkeley.edu/~brewer/cs262/FFS.pdf It once helped me solving my data recovery problem... ;-) I think this is what you mean with "physically remove". If you also want to remove the _data_ (read: the former file content), you need to overwrite the file's content with a random pattern or with zeros first. This can be done with the dd tool. There is also a port called "secure rm" (srm) that achieves the same "by overwriting, renaming, and truncating it before unlinking". You can find its manpage with further suggestions here: https://www.freebsd.org/cgi/man.cgi?query=srm However, this does not change things related to disk space becoming free. So when intending to simply remove files without any "recycle bin" nonsense, rm is the way to go. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200223184908.b35d656a.freebsd>