10

I am trying to mount a windows share using this command:

sudo mount -t cifs -o username=USERNAME,password=PASSWORD \\192.168.2.12\TestShare mnt/

But it is giving me this error:

mount.cifs: bad UNC (\192.168.2.12TestShare)

I have also tried these commands:

sudo mount -t cifs -o username=USERNAME,password=PASSWORD \\192.168.2.12\\TestShare mnt/
sudo mount -t cifs -o username=USERNAME,password=PASSWORD \\192.168.2.12:\TestShare mnt/

But they all give me the same error. The file is shared and the name and password are correct. I have also installed cifsutils.

Does anyone know what I am doing wrong? Does it have something to do with the WORKGROUP?

3
  • 1
    try //192.168.2.12/TestShare /mnt/ and if your password or username contains special characters try simplifying them.
    – rob
    Commented Oct 24, 2014 at 12:22
  • Yes! You are my hero today, I can't beleive it was that simple! Thanks! Commented Oct 24, 2014 at 12:28
  • When Linux devs speak about UNC paths they of course don't mean a real UNC path but what THEY call an UNC path. Commented Dec 1, 2019 at 22:25

2 Answers 2

19

try reversing the slashes and pointing to the root mnt folder

sudo mount -t cifs -o username=USERNAME,password=PASSWORD //192.168.2.12/TestShare /mnt/ 

if your password or username contains special characters try simplifying them.

1
  • Upvote. Yes, in the Windows world it should be forward slashes. Plus I see in your answer that you also corrected the double slashes after the IP address. The only double slash should be at the beginning, as you show here.
    – SDsolar
    Commented Jan 9, 2017 at 21:29
2

It works following way ,too

    sudo mount -t cifs -o username=USERNAME,password=PASSWORD '\\192.168.2.12\TestShare' /mnt/ 

By wrapping in single quotes, you can copy-paste the url directly without slash (/,) modifications.

2
  • 4
    To be fair, this Answerer is pointing out that quoting the '\'s prevents their recognition by the shell as special characters so that the CIFS mount handler can actually get that argument in one piece from the command line and that handler CAN understand the slash swapping that is needed to understand path and file names on products from that Redmond, USA based outfit that uses '/' as a command line argument introducer.
    – SlySven
    Commented Feb 11, 2016 at 20:05
  • 4
    I'd like to suggest that the answer be elaborated upon to indicate what is being illustrated by it.
    – Kolban
    Commented Feb 11, 2016 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.