Casually removing root files
ervinb.github.io
ervinb.github.io
> The $HOME directory naturally fulfills both of these requirements from the user’s perspective.
Note that there's nothing special about the user's home directory here, it just happens to normally have u+wx. It's entirely possible to have the user's home not owned by themselves; you might want to do this for example if you have a restricted user who you don't want messing around with their dotfiles.
My mental model is that a directory is just a special file that links to other files.
Adding or deleting a file to a directory is just a case of writing to the "special file" to add or remove links to other files.
Any other hardlinks in any other directories are completely unaffected.
"I assume that SQL tables are basically just fancy CSV files. Therefore strong invariants are obviously confusing."
But some people don't know, and benefit from learning it. So chill.
The point of chmod 000 was to say that clearly nobody has any any permissions to do anything directly on the file; that the permissions on the file must have nothing to do with it.
https://linux.die.net/man/1/mountpoint
E.g.
mountpoint -q /mnt/backup || exit 1I agree setting the flag is the superior option.
Mounting something just creates a new filsystem namespace over a path. It doesn't touch the existing directory.
So you can safely leave the directory in question immutable, you never remove the flag, and it will only prevent writes to the directory when it is not overlaid by a mount.
As a tiny issue, in the 3rd snippet, '/home/user/shoe/little-rock' should be left-shoe, no?
Yes, that part probably doubled the time it took me to read the first part of the post, because I had to double-check everything.
Listing is controlled by r--. Access to content items is controlled by --x.
--x in the context of directories is typically called "search" permission rather than execute.
To put that another way: when you delete a file in POSIX, you're not writing to the file, you're just writing to the directory. (Think of a directory as just a file containing a stream of dirent data—if you have write permission on it, you can modify the dirents.) After you remove a dirent, the kernel then goes and cleans up the file if its link count has become zero—and, obviously, the kernel has permission to do that.
I believe it was because I had done something funny with the home directory and the user didn't fully own it (I believe it was a home media server).
I guess apparently some SSH versions expect `chattr -i` or I guess the parent directory to be owned completely by the user (I have been meaning to look into this some day). Maybe it wasn't -i .. maybe it was +i?
It was this problem with SELinux: https://stackoverflow.com/a/21636460/318174
restorecon -R -v /root/.ssh
I was confused because I have used chattr with ssh files before just for added security. My memory was also hazy because I don't know much about SELinux. Hopefully I didn't misguide anyone.https://man.openbsd.org/chflags.1
> # chattr +i /home/user/left-shoe/little-rock
Or more traditionally, chmod +t /home/user/left-shoe
though that would affect other files.
Making local edits in any part of /usr/ is extremely frowned upon.
http://man7.org/linux/man-pages/man5/ext4.5.html#FILE_ATTRIB...
Warning: GRUB strongly discourages installation to a partition boot sector or a partitionless disk as GRUB Legacy or Syslinux does. This setup is prone to breakage, especially during updates, and is not supported by the Arch developers.
# chattr -i /boot/grub/i386-pc/core.img
# grub-install --target=i386-pc --debug --force /dev/sdaX
# chattr +i /boot/grub/i386-pc/core.img
in case of partition or a partitionless disk is that GRUB relies on embedded blocklists in the partition bootsector to locate the /boot/grub/i386-pc/core.img file and the prefix directory /boot/grub. The sector locations of core.img may change whenever the file system in the partition is being altered (files copied, deleted etc.).
The workaround for this is to set the immutable flag on /boot/grub/i386-pc/core.img (using chattr command as mentioned above) so that the sector locations of the core.img file in the disk is not altered. The immutable flag on /boot/grub/i386-pc/core.img needs to be set only if GRUB is installed to a partition boot sector or a partitionless disk, not in case of installation to MBR or simple generation of core.img without embedding any bootsector (mentioned above).