File Sharing
File Sharing tests Samba and NFS: exporting directories, mapping identities, controlling access, and mounting from clients. The exam favors working configuration over broad theory.
Core rules
- Samba global settings in
smb.confincludeworkgroup,security = user, andpassdb backend = tdbsam. Shares setpath,browseable,writable,valid users,write list,create mask, anddirectory mask. - Samba passwords are separate:
smbpasswd -a aliceorpdbedit -a -u alice; list withpdbedit -L.testparmchecks syntax; reloadsmbd(andnmbdfor browsing). - NFS exports live in
/etc/exports:/srv/share 192.0.2.0/24(rw,sync,no_subtree_check). Apply withexportfs -ra; inspect withexportfs -vandshowmount -e localhost. NFSv4 uses TCP/2049; NFSv3 also needs rpcbind/111 and mountd. root_squashmaps remote root tonobody;no_root_squashtrusts it and is risky.syncis safer thanasync. Clients mount withmount -t nfs4 server:/srv/share /mntor an/etc/fstabentry.
Worked example
Create a Samba share for group accounting at /srv/accounting. Run chgrp accounting /srv/accounting, chmod 2770 /srv/accounting; in smb.conf add [accounting] path = /srv/accounting, valid users = @accounting, writable = yes, create mask = 0660, directory mask = 2770. Add users with smbpasswd -a, run testparm, reload. Reasoning: the setgid bit keeps new files in the group; the masks prevent world access; valid users enforces group membership at Samba level, not just Unix mode bits.
Traps
NFS export options must have no spaces before the parenthesis; exportfs -ra is needed after edits; a firewall blocking 2049/111 breaks mounts. Samba may be blocked by SELinux (samba_share_t) or fail because the Unix user has no Samba password. root_squash surprises admins who expect root-owned uploads to remain root-owned.