Linux Mint中文件与文件夹权限无法继承问题求助
Hey there, let's work through this permission issue you're hitting on your Linux Mint system. You've tried setfacl and adjusting umask, but new files still default to 644 instead of inheriting the 775 group permissions you need. Let's break this down step by step to get it working right.
1. First: Verify ACL is Properly Enabled on Your Filesystem
Before diving into permission rules, make sure your ext4 partition actually has ACL support turned on—this is a prerequisite for any ACL settings to take effect:
Run this command to check current mount options:
mount | grep ext4Look for the
aclkeyword in the output (e.g.,rw,relatime,acl). If it's missing, you need to update your/etc/fstabfile:- Open
/etc/fstabin a text editor, find your ext4 partition line, and addaclto the mount options list (separated by commas). - Remount the partition to apply changes:
sudo mount -o remount /(replace/with your actual mount point if it's a different partition).
- Open
To confirm it's set permanently for future boots, run:
tune2fs -l /dev/your-partition-device | grep "Default mount options"You should see
acllisted here.
2. Correct the Default ACL Configuration
Your initial setfacl -R -d -m ugo:rwx command is syntactically valid, but it misses a critical component: setting the mask permission, which acts as a filter for group and other user permissions. Here's the correct workflow:
Step 1: Set the Parent Folder's Base Permissions
First, ensure the target folder itself has the 775 permissions we want to inherit from:
sudo chmod 775 /path/to/your/target/folder
Step 2: Apply the Default ACL Rules
Default ACLs dictate what permissions new files/folders inherit. We'll explicitly set permissions for the owner, group, others, and the mask to ensure group permissions aren't restricted:
# Set default permissions: owner rwx, group rwx, others rx sudo setfacl -d -m u::rwx,g::rwx,o::rx /path/to/your/target/folder # Set the mask to rwx to ensure group permissions are fully applied sudo setfacl -d -m m::rwx /path/to/your/target/folder
The -d flag marks these as default rules, meaning they'll apply to all new items created inside the folder.
Step 3: Verify the ACL Setup
Run this command to check that your default rules are correctly applied:
getfacl /path/to/your/target/folder
You should see output that includes these default rules:
default:user::rwx default:group::rwx default:other::r-x default:mask::rwx
3. Ensure Your umask Setting is Active
Changing umask to 0002 is the right move for group-friendly permissions, but make sure it's permanently set:
- For your user account, add
umask 0002to the end of your~/.bashrcfile. - For all users system-wide, add it to
/etc/profileor/etc/bash.bashrc. - Apply the change immediately with
source ~/.bashrc(or the system-wide file you edited), and log out/in to ensure it's active for all sessions.
Note: When default ACLs are in place, they take priority over umask, but setting umask 0002 ensures consistency across your system even outside this specific folder.
4. Test the Results
Now create a test folder and file to verify permissions:
cd /path/to/your/target/folder mkdir test_dir touch test_file
- The folder
test_dirshould show permissionsdrwxrwxr-x(775) - The file
test_filewill show-rw-rw-r--(664) — this is normal! New files don't get execute permissions by default (a security safeguard). If you truly need executable files to inherit 775, you can adjust the default ACL, but this isn't recommended for most use cases.
内容的提问来源于stack exchange,提问作者user313162

