From owner-freebsd-questions@freebsd.org Sun Feb 23 17:49:23 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BD3E32437B7 for ; Sun, 23 Feb 2020 17:49:23 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48QXkp437mz4BCB for ; Sun, 23 Feb 2020 17:49:21 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([188.102.104.44]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPA (Nemesis) id 1MplTn-1jmu2S0jXB-00q7nr; Sun, 23 Feb 2020 18:49:09 +0100 Date: Sun, 23 Feb 2020 18:49:08 +0100 From: Polytropon To: Jos Chrispijn Cc: freebsd-questions@freebsd.org Subject: Re: rm | Cleaning up recycle bin Message-Id: <20200223184908.b35d656a.freebsd@edvax.de> In-Reply-To: References: Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:EcOh1GkTXQ1xa0gYEZ1GL+Q/1fjP+J0qyF4nYJtTY6I2Q/2G3eA s60FF5N/O/cMBXw74jvHgJo5oQYlB6gyG5z6NvIu/Aq+PRPW8t2SJfP/REzOK/Idxc7pZon UvJsfP6Hbs2R0fYObWzplEEU248IPnt/F4LjdMXYJozFbb5aOrQ6t3/bkQOFEpMtJ1AquVo mClhSQl8hzQ6IP8JYNgAA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:+XmzxuV4eok=:1nmF1ZsIo+Btvqr6DtSdPB Mo89YAIciqL2etDvZOIMNAuVFXuOPUMzjf8i+tV2tkJ72ScobtrkieLmASqGp7emVgqR9E5mk KFibH85KiVs9/jScJa5m+Di+DVXEsC2ohGPYuzRaDHkhMfbjwhAN/4j5IuaKU12TGkyA0Zwum fZUXvXRtE32rJ8heNVCvnz/VgFMHZUwr4cRKgytuqaG5sg0/KdwroMn2X7/T/wDViek8ef/qx Ua5ESKKY8S5V5MPjsz0PlK2hAqL1N3qmMQ+zNxvtaPBTcAY0zATf5LjOsonmgjlR/mfCznGJq VH2gE/fDND9e1RHimPZRoiiihLGP2PKGPH6OsnorwCzH2JWPIg2oM6aEPgF9Dci1wQeB7FMng f9xMC6NUCB0pJySDT7qo6Nel3Fveb1/jHhvNHlswoVIBXmhorQaHP+TifRSdjxFUKYWgbr0YX DqGWkDuRzIdkkmIgybKiJS1DLKuEdME9ZFsbpPDKY+33Eq8pnezRz8Fw+7NSifjZHw89+QlOQ GUrDWeuiXH4ydWvn0b+3JVo6NQkBxKJPoLqzsOqo6OF+Crt2DXK9nGwX30xazupwdWwC9QoUy 21AHpzMZTcvK5TVJDLkyExNnxA00Sngfg6QG1QQC6YgnaBUJb2JuzoD//YJ7jUBxeVigmv/bG qQmqSCYswi2vqakaIkh4T4u25egFTLZFh+SMcxkN/kZ2+ROvd5Kkeyu8VCO27FcHlUkoZoyoH 1Azc/nQl9xNAvYgLGaL1k5kZSV8b6+Xv9xIFjkejAABwx5AEhDcoLZrZuLFYBZUCz8TW1Mdgi Yr3XtZAcsovJHD8j0FXHCxkeCfz/5xlzbxMaIN4s4UR0VHtdalU3/xI4Ztw3dsKRHATSn4J X-Rspamd-Queue-Id: 48QXkp437mz4BCB X-Spamd-Bar: ++++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 212.227.17.10) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [4.34 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RECEIVED_SPAMHAUS_PBL(0.00)[44.104.102.188.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.95)[0.947,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.90)[0.898,0]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[10.17.227.212.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[10.17.227.212.rep.mailspike.net : 127.0.0.17]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(0.09)[ip: (-0.59), ipnet: 212.227.0.0/16(-1.12), asn: 8560(2.19), country: DE(-0.02)] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Feb 2020 17:49:23 -0000 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, ...