mount.cifs: Mount SMB/CIFS Shares


mount.cifs overview

mount.cifs lets you mount a Windows SMB or CIFS share on your Linux filesystem. If you prefer, you can achieve the same result by using mount -t cifs.

Quick tip: you’ll often be prompted for a password unless you pass credentials explicitly or use a guest session.

Quick start

  • Connect with a specific username (you’ll be prompted for a password by default):
mount.cifs -o user={{username}} //{{server}}/{{share_name}} {{mountpoint}}
  • Connect as guest (no password):
mount.cifs -o guest //{{server}}/{{share_name}} {{mountpoint}}
  • Set ownership for the mounted directory (uid, gid can be numeric IDs or names):
mount.cifs -o uid={{user_id|username}},gid={{group_id|groupname}} //{{server}}/{{share_name}} {{mountpoint}}

How it fits into the system

  • The -t cifs option is equivalent to using mount.cifs; you can use it with the generic mount command:
mount -t cifs //{{server}}/{{share_name}} {{mountpoint}} -o user={{username}}
  • Typical mountpoint location is under /mnt or /media, e.g. /mnt/share.

Common options and nuances

  • user vs guest: specify credentials in -o user=… or -o guest to skip password prompts. If your environment requires a domain, you may need domain e.g., -o username=DOMAIN\user.
  • Permissions: uid and gid set what owner/group the mounted files appear as, but not the actual Windows ACLs. Be mindful of file permissions and umask on the host.
  • Password handling: avoid placing passwords directly on the command line in shared scripts. Consider a credentials file (mount.cifs …,credentials=/path/to/credfile).

A practical example

  1. Create a mount point:
mkdir -p /mnt/smb_share
  1. Mount with a username and password stored securely in a credentials file:
mount.cifs //server/share /mnt/smb_share -o credentials=/home/user/.smbcredentials,iocharset=utf8,uid=1000,gid=1000
  1. Unmount when done:
umount /mnt/smb_share

## Common pitfalls

- Firewall or Windows share permissions: the server must allow SMB traffic and the share must be accessible with the provided credentials.
- Correct path: `//server/share` is SMB syntax; ensure DNS or IP and share name are accurate.
- Mounting as root: some environments require root privileges to mount network filesystems.
- SELinux/AppArmor: if access is blocked, check security policies and adjust as needed.

## Troubleshooting tips

- If the mount fails with authentication errors, double-check credentials and domain. Try `guest` as a test if the share allows guest access.
- Check dmesg and system logs for CIFS-related messages:

dmesg | tail -n 50

- Verify that the SMB version is compatible with the server. You can pass options like `vers=3.0` or `vers=1.0` depending on the server:

mount.cifs //server/share /mnt/smb_share -o vers=3.0,credentials=/path/to/creds


## See also

- man mount.cifs
- man mount

## See Also
- [How to Use the ln Command for Effective File Management in Linux](/blog/ln-guide-linux)
- [How to Use the lscpu Command for CPU Insights in Linux](/blog/lscpu-guide-linux)
- [zramctl: Quick Start and Practical Guide](/blog/zramctl-guide-linux)
- [How to Master the playerctl Command for Seamless Media Control](/blog/playerctl-guide-linux)
- [mate-about: Quick Insights for the MATE Desktop](/blog/mate-about-guide-linux)
- [torsocks: Route App Traffic Through Tor](/blog/torsocks-guide-linux)