Mounting Windows network shares in Linux

The basics

To mount a Windows network share in a Linux system you will usually use the CIFS protocol. On Debian and RHEL/CentOS, the necessary tools are provided in the cifs-utils package.

Suppose the network share you want to mount is identified by the UNC path \\server\public and you want to access its contents via the local directory /mnt/windows on your Linux machine. First prepare the mount point (unless it already exists):

# mkdir /mnt/windows

Then mount the network share (note the change of backslashes to slashes in the UNC path!):

# mount -t cifs //server/public /mnt/windows

To unmount the Windows share just do:

# umount /mnt/windows

Basically, that’s all.

Password authentication

If you have to authenticate to access the Windows server, you can pass your username (e.g. ‘hoppenheit’) and domain (e.g. ‘example.org’) as options to the mount command (you will be prompted for your password):

# mount -t cifs //server/public /mnt/windows \
    -o username=hoppenheit,domain=example.org

To make a local user on the Linux system (e.g. ‘martin’) own the mounted network share and (optionally) set the permissions to your liking you need some additional options:

# mount -t cifs //server/public /mnt/windows \
    -o username=hoppenheit,domain=example.org \
    -o uid=martin,gid=martin,file_mode=0640,dir_mode=0750

There are many more options which are described in the mount.cifs manpage.

Kerberos authentication

If your setup supports Kerberos and you are logged in as a domain user (e.g. ‘hoppenheit@example.org’), you can use your Kerberos ticket instead of a password for authentication:

$ sudo mount -t cifs //server/public /mnt/windows \
    -o sec=krb5,cruid=$USER,multiuser