How do I mount a CIFS share?

488,871

Solution 1

There is pyNeighborhood which is a gui for mounting samba shares and available in the software centre for download.

There is a good article located here on how to set it up and use it.

First install cifs utils

sudo apt-get install cifs-utils

Alternatively, the basic terminal command is :

mount -t cifs -o username=USERNAME,password=PASSWD //192.168.1.88/shares /mnt/share

If you'd like to see your mount in Nautilus it would be good to create a subfolder first in /media/USERNAME/ for example:

mkdir /media/paul/cifsShare

also, password could ommited in the mount command for example (will also demonstrate file/folder modes):

sudo mount -t cifs //nas-server/cifsShare /media/paul/cifsShare -o username=paulOnNAS,iocharset=utf8,file_mode=0777,dir_mode=0777,soft,user,noperm

in this case you'll be asked for the password (actually for 2 passwords) on the mounting moment.

Have a read through the Samba documentation here on how to do it and set it up correctly to mount on start up etc.

Solution 2

It's as map7 said, but if you don't want to use root permissions every time you change a file on the drive, then you'll have to mount to a user folder, and make sure the gid and uid are set to your username.

The command setting them:

mount -t cifs -o username=USERNAME,password=PASSWD,uid=$USER,gid=$USER //192.168.1.88/shares ~/mnt/share

Note that mnt folder was created in ~/mnt/share instead of /mnt/share.

Also you can leave out password=PASSWD if you want it to prompt you instead of you having it in the command, which is potentially stored in your shell's history:

mount -t cifs -o username=USERNAME,uid=$USER,gid=$USER //192.168.1.88/shares ~/mnt/share

Solution 3

1) My samba share shows in Caja (the ubuntu 16.04 „explorer“) as

smb://thinkpad/ddrive/

This is a good lithmus test, there are no connection/path issues.

(caveat: If you get asked by caja about password credentials from your windows machine, you might want to switch Domain from WORKGROUP to the name of the machine, i.e. ‘thinkpad’. Then the truly local login credentials of your drive should do.)

2) If that works, here comes the command:

sudo mount -t cifs -o username=frank //thinkpad/ddrive /mnt/ddrive
  • Make sure beforehand, /mnt/ddrive exists as an empty directory.
  • You cold also add a ,password=supersecret directly (no space) after username=, but you can also wait for being prompted, when you enter the command.

Solution 4

I disagree with the claim that root is always necessary to make cifs connections go. It is true, it is always needed for CLI smbmount, but a file manager such as nautilus has ability to mount a cifs share and it is not necessary to be root.

I don't use Gnome, but I still have Nautilus installed. Run this in a terminal to prevent having it try to take over the desktop

$ nautilus --no-desktop &

In Ubuntu 16.04, left side tree menu has "Connect to Server" on the bottom. Click that, the suggestion is type "smb://foo.example.com". smb is old word for "cifs", and if you put in your server and share with smb:// at beginning, connection does work! I promise. If your share is a named thing, it is required after a slash, "smb://foo.example.com/myshare".

I've used other file managers in same way. Protocol has to be "smb://".

Solution 5

  1. You can put all those details in /etc/fstab so you can have directories mounted on system startup. If windows or SMB server is on IP address 192.168.1.1

    /etc/fstab
    //192.168.1.1/SharedFolder/    /mnt/linux_smb   cifs    username=winuser,password=TopSecret   0    0
    
  2. Create directory as linux mount point

    mkdir /mnt/linux_smb
    chmod 755  /mnt/linux_smb
    
  3. For the first time mount this manually

    mount -a
    
  4. Eventual errors can be found by

    dmesg | tail 
    
Share:
488,871

Related videos on Youtube

KYLE
Author by

KYLE

Updated on September 18, 2022

Comments

  • KYLE
    KYLE over 1 year

    I'm using Ubuntu 11.10, and am trying to mount a freenas server. I have the server set to share in cifs and nfs with no luck.

    I have tried smbmount //192.168.1.### /mnt/

    I am not new to Ubuntu but am nowhere near a power user, so I'd prefer a GUI option if available.

    How do I mount a cifs share in 11.10?

    • will
      will almost 4 years
      Has anyone explained what error 95 might be? The message si "operation not supported", but it doesn't say what "operation".
  • mcExchange
    mcExchange over 8 years
    is there a way to mount the samba share without 1) hard coding the password and 2) having to be root?
  • codaamok
    codaamok about 8 years
    @mcExchange root is needed and you can use smb credentials file to protect you credentials
  • Marco Pashkov
    Marco Pashkov about 8 years
    also make sure you have cifs-utils installed: sudo apt-get install cifs-utils. For more info this ubuntu help doc is great.
  • Pavel Niedoba
    Pavel Niedoba about 8 years
    pyNeighborhood gives me segmentation fault when started over ssh in ubuntu 14.04
  • rubynorails
    rubynorails almost 8 years
    @MarcoPashkov cifs-utils is what got me up and going. None of this would work otherwise. This should be directly included in the answer.
  • Peter T.
    Peter T. over 6 years
    It took me a bit to figure out, where I can type in the smb://.... path in Nemo / Linux Mint 18, but actually it's quite simple: if the path input box is not visible, enable it in the View menu.
  • David Refoua
    David Refoua over 5 years
    Also also, make sure that you're using SMBv2 to connect to newer machines, i.e.: mount -t cifs ... -o vers=2.0,username=... otherwise you might get a host is down.
  • Babak
    Babak almost 4 years
    I was getting Permission denied error only because I haven't included the domain name with my USERNAME. Not a bad thing to mention too. DOMAIN\USERNAME just in case.