Mounting Samba (CIFS) shares
Common Internet File System (CIFS) is a network filesystem that's used by Windows file shares and also implemented by Samba. The CIFS protocol is typically used to share access to files and printers.
This page goes over how to mount Samba / CIFS shares on Linux and FreeBSD.
Linux[edit | edit source]
To mount CIFS shares on Linux, you need to have the samba utilities installed. For RHEL based systems, ensure you have
To mount a samba share, use
mount -t cifs. Some common mount options are listed below.
|Your account domain (if applicable)||domain=|
|A credential file containing your username/password/domain||credentials=filename|
|Force a specific protocol version||vers=|
|Use this uid for all files in the mounted filesystem||uid=#|
|Use this gid for all files in the mounted filesystem||gid=#|
SMB protocol versions[edit | edit source]
If the version is left undefined, the default option would be to negotiate t he highest SMB2+ version that is supported by both the client and server. To force a specific version, refer to the table below.
|1.0||The classic CIFS/SMBv1 protocol|
|2.0||The SMBv2.002 protocol. This was initially introduced in Windows Vista Service Pack 1, and Windows Server 2008. Note that the initial release version of Windows Vista spoke a slightly different dialect (2.000) that is not supported.|
|2.1||The SMBv2.1 protocol that was introduced in Microsoft Windows 7 and Windows Server 2008R2.|
|3.0||The SMBv3.0 protocol that was introduced in Microsoft Windows 8 and Windows Server 2012.|
|3.02/3.0.2||The SMBv3.0.2 protocol that was introduced in Microsoft Windows 8.1 and Windows Server 2012R2.|
|3.1.1/3.11||The SMBv3.1.1 protocol that was introduced in Microsoft Windows 10 and Windows Server 2016.|
|3||The SMBv3.0 protocol version and above.|
Examples[edit | edit source]
To mount a CIFS share and have it prompt for a password:
# mount -t cifs -o username=leo,domain=uc,vers=2.1 //10.1.1.123/share /mnt/share
You can also have the credentials placed in a separate file rather than passing it directly as mount options. Create a file with the username, password, and optionally domain defined and then mount using the
credentials=filename option. For example:
## Create a file. Ensure it's not world readable. # cat /etc/cifs_passwd username=leo password=53cr3T$ domain=uc # mount -t cifs -o credentials=/etc/cifs_passwd,vers=2.1 //10.1.1.123/share /mnt/share
To set the default user/group ID, define the
gid value as part of the mount options. All files in this mount will have the specified uid/gid.
# mount -t cifs -o uid=1024,gid=512,credentials=/etc/cifs_passwd //10.1.1.123/share /mnt/share
FreeBSD[edit | edit source]
Mounting[edit | edit source]
# mount_smbfs -I 10.1.1.4 //leo@remote_host/share /mnt/share
-I takes the remote host's IP address. Your username @ the NetBIOS name / path to your share comes next. The mount path follows after that.