How to Mount SMB SharesΒΆ
This guide shows you how to mount SMB/CIFS network shares on Linux with proper permissions. π
π Method 1: Basic MountΒΆ
π Create a mount pointΒΆ
π 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ΒΆ
β‘ Method 2: Permanent Mount (fstab)ΒΆ
π Add to fstab for automatic mountingΒΆ
β Add this lineΒΆ
//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ΒΆ
π Method 3: Secure CredentialsΒΆ
π Create credentials fileΒΆ
π Add your login infoΒΆ
π‘οΈ Secure the fileΒΆ
π― 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 withid -u) π€gid=1000- Your group ID (check withid -g) π₯vers=3.0- SMB version (try 2.0 if 3.0 fails) π’
π― Important for File ManagersΒΆ
When using Thunar or other 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