无需chattr:设置局域网共享文件夹不可移动且保留rwx权限
Alright, let's break this down. You've got a server with shared folders like Photos and Music, you can't delete the Photos folder but still move it within the Family Share scope, and you want to lock down that move capability while keeping full read-write-execute (rwx) access to the folder's contents. Here's how to do it based on your server's setup:
For Windows Servers (NTFS Volumes)
Since moving a folder within the same volume is essentially a rename operation (which modifies the parent directory's entries), we can tweak NTFS advanced permissions to block this while preserving rwx:
- Right-click the Photos folder → Properties → Security tab → Advanced
- Find the permission entry for your
Family Sharegroup and click Edit - In the Advanced Permissions list:
- Keep these permissions enabled to maintain rwx access:
- Read & Execute, List Folder Contents, Read
- Write, Create files / write data, Create folders / append data
- Uncheck Rename and Delete (these are what allow moving the folder within the share)
- Keep these permissions enabled to maintain rwx access:
- Click OK to save changes. Users can still edit, add, and run content inside Photos, but can't move or rename the folder itself.
For Linux Servers (Samba Shares)
Samba has built-in settings to lock specific folders from being moved, plus we can use ACLs to preserve rwx access:
- Tweak Samba Configuration
- Edit your Samba config file (usually
/etc/samba/smb.conf) - Find your Family Share section and add these lines:
[FamilyShare] path = /path/to/your/shared/folder writable = yes valid users = @FamilyShare veto files = /Photos/ # Blocks moving/deleting the Photos folder delete veto files = no # Ensures the folder isn't deleted accidentally - Restart the Samba service:
sudo systemctl restart smbd
- Edit your Samba config file (usually
- Verify Folder Permissions
- Make sure the Photos folder itself has rwx permissions for the group:
chmod -R g+rwx /path/to/your/shared/folder/Photos setfacl -R -m g:FamilyShare:rwx /path/to/your/shared/folder/Photos
- Make sure the Photos folder itself has rwx permissions for the group:
For macOS Servers (AFP/SMB Shares)
macOS lets you granularly control shared folder permissions via advanced settings:
- Open System Settings → General → Sharing
- Select your
Family Shareentry, then click Info next to it - Navigate to the Photos folder, right-click → Get Info → Sharing & Permissions
- Click the lock icon to unlock, then click the gear icon → Show Advanced Permissions
- For the
Family Sharegroup:- Keep Read, Write, and Execute enabled
- Uncheck Rename and Delete
- Make sure to apply these changes only to the folder itself (not recursively) so contents inside remain fully accessible.
Key Takeaway
Moving a folder within a shared area relies on modifying the parent directory's entries (to rename or reposition the folder). By blocking those specific permissions (rename/delete) at the parent or folder level, you lock the folder's position while keeping full access to what's inside.
内容的提问来源于stack exchange,提问作者swift_dan

