Skip to content

Linux CIFS Mount — Permission Error Fix

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Linux CIFS Mount. We cover key concepts, practical examples, and best practices.

CIFS mounts fail with "mount error(13): Permission denied", "mount error(95): Operation not supported", or mounted files appear owned by nobody and inaccessible. These happen when credentials are wrong, the SMB protocol version mismatches, or the uid/gid mapping is incorrect.

The Problem

sudo mount -t cifs //server/share /mnt -o username=user

Error:

mount error(13): Permission denied

Or the mount succeeds but:

ls -la /mnt

Shows:

drwxr-xr-x 2 nobody nogroup 0 Jun 24 10:30 .

Wrong Approach

# WRONG — no domain, no version, no uid mapping
sudo mount -t cifs //server/share /mnt -o username=user%password

Right Approach

sudo mount -t cifs //server/share /mnt \
  -o username=user,password=pass,domain=WORKGROUP,vers=3.0,uid=$(id -u),gid=$(id -g),dir_mode=0755,file_mode=0644

Expected output:

$ ls -la /mnt
drwxr-xr-x 2 user user 4096 Jun 24 10:30 .
-rw-r--r-- 1 user user  123 Jun 24 10:30 file.txt

Step-by-Step Fix

Step 1: Use a credentials file instead of inline password

echo -e "username=user\npassword=mypass\ndomain=WORKGROUP" > ~/.smbcredentials
chmod 600 ~/.smbcredentials

Step 2: Mount with the correct protocol version

# SMB 3.0 for modern Windows (Server 2012+)
sudo mount -t cifs //server/share /mnt -o credentials=~/.smbcredentials,vers=3.0

# SMB 2.1 for older systems
sudo mount -t cifs //server/share /mnt -o credentials=~/.smbcredentials,vers=2.1

Step 3: Map UID and GID correctly

sudo mount -t cifs //server/share /mnt \
  -o credentials=~/.smbcredentials,uid=1000,gid=1000

Step 4: Set file and directory permissions

sudo mount -t cifs //server/share /mnt \
  -o credentials=~/.smbcredentials,uid=1000,gid=1000,dir_mode=0755,file_mode=0644,noperm

Step 5: Fix the fstab entry

//server/share /mnt cifs credentials=/home/user/.smbcredentials,vers=3.0,uid=1000,gid=1000,noperm,noexec 0 0

Step 6: Test the mount

mount -a
ls -la /mnt
touch /mnt/test && echo "Write works"

Prevention Tips

  • Store credentials in a secure file (chmod 600) instead of inline
  • Always specify vers=3.0 or higher for modern servers
  • Map uid/gid explicitly to your local user
  • Use noperm when the server handles permissions
  • Test with mount -v for verbose output during debugging

Common Mistakes with cifs mount

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world LINUX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why do CIFS-mounted files appear owned by nobody?

The mounted files show the SMB server's numeric UID/GID, which do not exist on the local system. Map them with uid=$(id -u),gid=$(id -g) to set the owner to your local user. Add forceuid and forcegid to always override the server's values.

Which SMB protocol version should I use?

Use vers=3.0 for Windows 2012+, Samba 4.x, and most modern NAS devices. Use vers=2.1 for Windows 7/2008 R2. Use vers=1.0 only for legacy systems (insecure, disabled by default in modern kernels).

How do I make CIFS mount permanent across reboots?

Add an entry to /etc/fstab. Use a credentials file (not inline passwords), specify the correct vers and uid/gid options, and include _netdev to delay mounting until the network is available. Run mount -a to test before rebooting.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro