6 ms·
A thorough Linux clean-up script
- deleted 2y ago[deleted]
- LinuxBender 2y agoFWIW BleachBit in many repos is more complete than this. One can go further and mount some of the directories mentioned in the script as tmpfs. It may also be worth noting that recursively removing everything in /tmp while a desktop is running can cause some glitches in some desktop window managers and/or Xorg depending on many conditions.
- throwaway29303 2y agoReminder that shred(1) doesn't work on journaled filesystems.[0][1][2] CAUTION: shred assumes the file system and hardware overwrite data in place. Although this is common, many platforms operate otherwise. Also, backups and mirrors may contain unremovable copies that will let a shredded file be recovered later. See the GNU coreutils manual for details. [0] - https://man7.org/linux/man-pages/man1/shred.1.html https://man7.org/linux/man-pages/man1/shred.1.html [1] - https://stackoverflow.com/questions/913282/shred-doesnt-work-on-journaled-fs https://stackoverflow.com/questions/913282/shred-doesnt-work... [2] - https://en.wikipedia.org/wiki/Journaling_file_system https://en.wikipedia.org/wiki/Journaling_file_system
- uws 2y agoThank you for your detailed assessment. I have updated the script to fill the directories with random data (to match original size) at the end to help prevent recovery further.
- not_your_vase 2y agoLiterally 8-9 lines of rm/shred commands (depending on how you count), asking you to run it as root (so it will clean the home of root instead of the user, without even checking what's going on -.-) or with sudo. Come on, this is not even low effort. I'm sure you can do better than this.
- uws 2y agoThank you for your review. I have updated the script to mention running as the user with sudo. Some people use the root user for administration.
- not_your_vase 2y agoshred_and_fill "$HOME/.local/share/Trash" shred_and_fill "/root/.local/share/Trash" If I, as a sysadmin give root rights to my user, and that user deletes my (real root) files, even from the Trash or anywhere else, then the next step includes such a level of violence that's not compatible with any kind of Code of Conduct.
- uws 2y agoIf you give a user wheel/sudo/root privileges, then they will be able to delete the root user's files regardless of using this script. I will consider removing this line and thus the required superuser privileges in the next release.