Linux mount CIFS Windows Share

last updated in Categories , , , , , , , ,

Q. How do I mount CIFS Windows Server / XP / Vista Shared folder under Linux operating systems?

A. Common Internet File System is an application-level network protocol mainly used to provide shared access to files, printers, serial ports, and miscellaneous communications between nodes on a network. You can easily access CIFS share from Linux and mount them as a regular filesystem.

Mount Linux CIFS share

Mount CIFS with the default local filesystem permissions:
# mkdir /mnt/cifs
# mount -t cifs //server-name/share-name /mnt/cifs -o username=shareuser,password=sharepassword,domain=nixcraft
# mount -t cifs //192.168.101.100/sales /mnt/cifs -o username=shareuser,password=sharepassword,domain=nixcraft

OR
# mount.cifs //192.168.101.100/sales /mnt/cifs -o username=shareuser,password=sharepassword,domain=nixcraft
Where,

  • username=shareuser : specifies the CIFS user name.
  • password=sharepassword : specifies the CIFS password. If this option is not given then the environment variable PASSWD is used. If the password is not specified directly or indirectly via an argument to mount, mount will prompt for a password, unless the guest option is specified.
  • domain=nixcraft : sets the domain (workgroup) of the user

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

23 comment

  1. Hi,
    i can mount windows share when using gnome mount.
    but if i use CLI then how to mount without password since there is no password required for my windows share..

    -EKram

  2. @Drew: You can add a line similar to below to /etc/fstab

    //WindowsHost/Sharename /LocalMountPoint cifs username=,credentials=/etc/cifsauth{any file},domain=[workgroup/WindowsHostName/Most of the time can be left blank] 0 0

    Two zeros at end of line are important as it will prevent boot failure when windows share is unavailable.

    Format of credentials file (/etc/cifsauth)
    username=
    password=

  3. mount -t cifs //[netbiosname]/techsupport /mnt/techupport -o username=[username],doamin=[name],rw,file_mode=0777,dir_mode=0777

    mount with write permisssion

  4. Mount in cifs in AIX
    mount -v cifs -n 172.16.69.20/gbuilder/builder\!12 -o wrkgrp=commvault-nj /recutstotest /mnt

    use ‘\’ if your password contains escape sequence

  5. …and what if the folder you’re mounting on the windows share has a space in it? //storageserver/old%20work?

  6. Try:
    //storageserver/old\ work

    Just in case a formatting problem crops up, that’s backslash space between old and work.

  7. Hi,

    what about if the WIN share has spaces in its name? How do you mount it then?

    thanks,
    Mark

  8. i connect to domain and i can able to login using window domain user.i used to mount (mount -t cifs //server-name/share-name /mnt/cifs -o username=shareuser,password=sharepassword,domain=nixcraft) as root worked fine.
    But i need to mount particular user window domain share folder whenever i login as domain user. how to make fstab entry that can automatically retrieve username and password from login information and mount automatically

  9. //192.168.1.60/RMAN-Backup/BO_Rman /RMAN/Bck-files cifs user=rman@tt.local,password=2TC@Rman,rw,users,auto,file_mode=0777,dir_mode=0777,uid=oracle,gid=oinstall 0 0
    I write this parameter on fstab and when i start RMAN on oracle user, shown this error “RMAN-03009: failure of backup command on c4 channel at 09/22/2015 03:09:20
    ORA-19504: failed to create file “/RMAN/Bck-files/BCK_LVL1_SVBO_1016_1_891054558″
    ORA-27041: unable to open file
    Linux-x86_64 Error: 13: Permission denied
    Additional information: 3”

    please help me
    I change mount point owner to oracle:oinstall and chmod 777 on it .

  10. Seems some shares requires to use “user” instead of “username” in

    “username=shareuser,password=sharepassword,domain=nixcraft”

    replace username with user like this:

    “user=shareuser,password=sharepassword,domain=nixcraft”

  11. I have followed the below steps to mount share on debian linux. But i am getting an error as
    “mount error: cifs filesystem not supported by the system
    mount error(19): No such device
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

    1. Shard one folder/drive in hyper-v.
    2. Installed cifs-utils on debian linux VM
    3. mount -t cifs //hostname/sharedname localmountpoint -o username=”username”,password=”password”,domain=”domain ”

    The above credentials are hyper-v credentials. Is anything i am missing here?

    Have a question? Post it on our forum!