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
To mount CIFS shares on Linux, you need to have the samba utilities installed. For RHEL based systems, ensure you have samba-utils
installed.
To mount a samba share, use mount.cifs
or mount -t cifs
. Some common mount options are listed below.
Description | Mount option |
---|---|
Your username | username=user |
Your password | password= |
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
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.
Version | Description |
---|---|
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
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 uid
and 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
Mounting
# mount_smbfs -I 10.1.1.4 //leo@remote_host/share /mnt/share
where -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.