netscrew.dev/commands/mount
Command

n mount

Mount a network share (SMB/CIFS) — cross-platform, hides the syntax

Short forms:map · cifs · mnt

Usage — n mount

═══════════════════════════════════════════════════════════════════════════════
  Netscrew ("n") — mount (map, cifs, mnt) — Mount a network share (SMB/CIFS), cross-platform, syntax hidden
═══════════════════════════════════════════════════════════════════════════════

USAGE:
  n map .                              what's mounted on this machine — and will it survive a reboot?
  n map //host/share [user]            mount it (read-write, until reboot)
  n map //host/share [user] --ro       read-only
  n map //host/share [user] --persist  reconnect at boot/login
  n map //host/share --at Z:           choose the drive letter / mount point
  n map //host/share --print           show the command without running it
  n map '\\host\share'                 Windows style works too — quote it on Linux/mac or the shell eats the backslashes
  n map off Z:  |  off /mnt/x          unmount

OPTIONS:
  --rw / --ro                      read-write (default) or read-only
  --persist                        survive reboot (Linux: writes a locked fstab entry)
  --at <point>                     drive letter (Win) or mount dir (Linux/mac)

Target: . = this machine · <host> = remote
Deeper: n map -h = the concept/theory behind this command  ·  n -h linux-cifs  ·  n -h uac-shares

The concept behind it — n mount -h

═══════════════════════════════════════════════════════════════════════════════
  NETSCREW PLAYBOOK: Linux CIFS Mounts & Root Ownership Trap ["linux-cifs"]
═══════════════════════════════════════════════════════════════════════════════

THE SYMPTOM:
  You mount a CIFS/SMB share on Linux with sudo, but regular users get
  "Permission Denied" when trying to write, edit, or delete files!

THE CAUSE (uid=0 Root Hijacking):
  Because mount was run as root, the Linux kernel assigns owner root:root (0755)
  to the mount point. Local desktop users are treated as "Others" (Read-Only),
  even though the remote server granted full access!

REMEDIATION (Mount with User ID Mapping):
  sudo mount -t cifs //server/share /mnt/point -o username=user,uid=$(id -u),gid=$(id -g),file_mode=0775,dir_mode=0775

PERMANENT /etc/fstab ENTRY:
  1. Store credentials in /etc/samba/credentials (chmod 600)
  2. Add to /etc/fstab:
     //server/share /mnt/point cifs credentials=/etc/samba/credentials,uid=1000,gid=1000,file_mode=0775,dir_mode=0775,nofail 0 0