I have been playing around with chmod, chown, setfacl and special bits trying to get multiple system/full users in same group correct access permissions to my media collection.
But I’ve messed it up somehow and now I’m having weird problems that are hard to track.
I would like to set my whole collection back to the defaults.
What is the best way to do this?
One problem I’ve had when making changes to so many files is the process seems to go forever without completing. Eventually it gets killed so my filesystem has variable attributes throughout. how can this be worked around?
I want everything to be owned by myuser, group media, everything else default I will sort it from there once I have a fresh slate.
And is there a way to backup these attributes only? I don’t have enough storage to backup the files themselves.
It is Debian with ext4 filesystem.
Edit to add: Media collection is on its own separate drive/filesystem; this has no impact on anything else on the computer.
Restore from backup. No point in trying to figure out what changed, how and where.
that sounds to ge good advice, but I’m pretty sure they would yave done that themselves, if they had a backup.
and, if you read the whole post, you’ll know that they are physically unable to keep a backup.
deleted by creator
deleted by creator
I’m not familiar with
chacl(“change the access control list of a file or directory”). Is is similar tosetfacl(“set file access control lists”)? A matter of preference/habit?It seems like
-Bdoes “Remove all ACLs”. Which I guess is what I am asking for? Files on linux are OK to have no ACLs?About the
find ... {} +, I see{} +runs the specified command on the selected files, but the command line is built by appending each selected file name at the end; the total number of invocations of the command will be much less than the number of matched files.
So does it wait until it has found all the matches to run the command as a giant batch instead of running it as it finds matches?
So does it wait until it has found all the matches to run the command as a giant batch instead of running it as it finds matches?
almost. it runs the command in batches, if you have few enough files it may only run it once. this shouldn’t make it slower, but actually faster.
and yes, linux does not use ACLs by default.
on ext4 usage of ACLs is not even enabled by default, but only if you set it up with the right mount optionon ext4 usage of ACLs is not even enabled by default
Is that the case? One reason I included the information is because I found conflicting info and I am unsure. I specifically recall reading it is default on ext4 but not ext3.
aclis specified as a default mount option when creating an ext2/3/4 filesystemThis SE thread has a coment dated 2015:
Recent distro have ACL mount option included by default (since kernel 2.6). So it’s not mandatory to redefine it in /etc/fstab (or similar). Non exhaustive list of filesystems concerned: ext3, ext4, tmpfs, xfs and zfs .
I don’t think I have read anywhere it is not default for ext4, only for earlier exts.
oh, that’s right, sorry. it must have changed in recent years.
so I haven’t either found a definitive answer to whether it is a default mount option, but the closest I found is almost it:
man mountsays to look inman ext4, and there itsays the defaults are determined by the filesystem superblock.the superblock’s settings can be viewed with
tune2fs -l /dev/your_blockdev, and according to the “default mount options” line I indeed have acl enabled by default on all my ext4 filesystems.so in the end, the default is determined by the tool that makes the filesystem.
mkfs.ext4reads them from/etc/mke2fs.confif not overridden with an argument. on my system tue acl option is right there in this file.and that also means that this depends not on your current system, but on the system where the filesystem was created.
deleted by creator
Is there a reason to run
find -exec chmod 644 -- {} +rather than
find -type f -exec chmod 644 -- {} +?
deleted by creator
To back them up, perhaps cp -r --preserve=xattrs --attributes-only (or --preserve=all if you don’t want only xattrs)
Wouldn’t that back up the media files themselves also, not just the attributes?
Not with --attributes-only.
I mean, too late for you now. But I have a script that backs up just the permissions and owners for a given folder hierarchy.
I use it because I backup to a cloud backup platform that doesn’t save them. So these files are backed up with the data so the files and permissions/owners can be restored in an emergency.
But you could of course also use the file to restore permissions after a user generated mistake too.
can you share the script?
Yeah. Only on my phone right now but will get it and post here later/tomorrow.
OK so it’s fairly simple. You need to install the acl package (or whatever equivalent package contains getfacl/setfacl. Then you can use that to dump the data from an entire structure into a file (I also then bzip that). Then I backup all installed packages to help with a restore too.
So the script looks like:
#!/bin/bash cd /etc /usr/bin/getfacl -R . | /usr/bin/bzip2 -9 >PERMISSION_BACKUP.bz2 chmod 600 PERMISSION_BACKUP.bz2 cd /home /usr/bin/getfacl -R . | /usr/bin/bzip2 -9 >PERMISSION_BACKUP.bz2 chmod 600 PERMISSION_BACKUP.bz2 cd /root /usr/bin/getfacl -R . | /usr/bin/bzip2 -9 >PERMISSION_BACKUP.bz2 chmod 600 PERMISSION_BACKUP.bz2 cd /var /usr/bin/getfacl -R . | /usr/bin/bzip2 -9 >PERMISSION_BACKUP.bz2 chmod 600 PERMISSION_BACKUP.bz2 /usr/bin/apt list --installed | /usr/bin/bzip2 -9 >/root/INSTALLED-PACKAGES.bz2 chmod 600 /root/INSTALLED-PACKAGES.bz2To restore you change to the folder the backup was taken from, unbzip the file (or uncompress live via pipe) and use setfacl --restore=<file>
thanks for getting back to me. :)
I am curious what kind of situation would screw up your /etc/ directory?
It’s for backup purposes mainly. A lot of cloud backup providers don’t store permissions.
So if I restore the data I can then restore the permissions after. So these are the folders I am backing up (with some exceptions in /var)
Ah I see. Thanks! The data and the attributes are stored separately.





