3 Software Mount
Drew edited this page 2026-05-01 21:02:06 -04:00

How to Mount SMB Shares

This guide shows how to mount SMB/CIFS network shares on Linux with proper permissions.


Method 1: basic mount

Create a mount point

sudo mkdir /mnt/myshare

Mount the share

sudo mount -t cifs //server-ip/share /mnt/myshare -o username=youruser,password=yourpass,uid=1000,gid=1000,file_mode=0664,dir_mode=0775

Test it works

touch /mnt/myshare/test.txt
mkdir /mnt/myshare/testfolder

Method 2: permanent mount (fstab)

Add to fstab for automatic mounting

sudo nano /etc/fstab

Add this line

/etc/fstab

//server-ip/share /mnt/myshare cifs username=youruser,password=yourpass,uid=1000,gid=1000,file_mode=0664,dir_mode=0775,_netdev,x-systemd.device-timeout=30,noauto,x-systemd.automount 0 0

Mount all fstab entries

sudo mount -a

Method 3: secure credentials

Create credentials file

sudo nano /etc/cifs-credentials

Add your login info

/etc/cifs-credentials

username=youruser
password=yourpass

Secure the file

sudo chmod 600 /etc/cifs-credentials

Use it in fstab

//server-ip/share /mnt/myshare cifs credentials=/etc/cifs-credentials,uid=1000,gid=1000,file_mode=0664,dir_mode=0775 0 0

Common options

  • file_mode=0664 - Files are readable/writable
  • dir_mode=0775 - Folders are accessible
  • uid=1000 - Your user ID (check with id -u)
  • gid=1000 - Your group ID (check with id -g)
  • vers=3.0 - SMB version (try 2.0 if 3.0 fails)

Important for file managers

When using file managers, navigate to your mount point (like /home/user/mount) instead of using smb:// URLs. This ensures applications can properly open files from the network share.

  • Use: /home/user/mount/file.txt
  • Avoid: smb://server/share/file.txt

Unmount

sudo umount /mnt/myshare