How to refer to a file on an smb share from terminal prompt

Sorry if this is a bit of a basic question but I have searched and can’t seem to find an answer anywhere.

Can anyone tell me how to refer to a file on a Samba client share in a command prompt.
\Machine\Share\Filename doesn’t seem to work.

Thanks,
Nick

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

For what purpose, exactly? You need to somehow tell the system you’re
using SMB, and a couple of backslashes is not going to do it since those
are just characters. I would look into smbmount (mount the share
somewhere and then access it normally) or smbclient to make a
connection. Once connected (either by mounting the share or with the
smbclient connection, which works a lot like sftp or ftp from the
command line) you can interact normally as if you are on the share directly.

smbclient example


smbclient -U Administrator//nts25.lab.novell.com/c\$
Password:

smb: \> ls
$Recycle.Bin                DHS    0  Thu Apr 19 14:05:08 2012
Config.Msi                  DHS    0  Thu Apr 19 13:46:37 2012
Documents and Settings      DHS    0  Mon Jul 13 23:06:44 2009
pagefile.sys                AHS 8128  Fri Apr 20 03:16:01 2012
PerfLogs                      D    0  Mon Jul 13 21:20:08 2009
Program Files                DR    0  Thu Apr 19 15:58:14 2012
Program Files (x86)          DR    0  Thu Apr 19 15:58:25 2012
ProgramData                  DH    0  Fri Apr 20 03:17:39 2012
Recovery                    DHS    0  Thu Apr 19 14:04:35 2012
System Volume Information   DHS    0  Thu Apr 19 15:58:53 2012
Users                        DR    0  Thu Apr 19 14:04:53 2012
Windows                       D    0  Thu Apr 19 16:04:47 2012

44706 blocks of size 16777216. 43298 blocks available
smb: \> exit

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPkW7oAAoJEF+XTK08PnB5oS0P/iX3UFo5mzHC7skk2hk71wL+
wUKVwOpkFRWhLM840fsxyEW5CkHLUFMt5iQzje0iHC/k/Cm6l2Zjm+W0ZtbtEVO6
X1kxvKhpvoVRKFrr9Grfn4NO1lSRGL42S5+/sqLdvcClFV+/Keu74wqHzqOl1Wor
6O0eEhdvRd5FTLoIB1e4kSbTmrUyZkvIN1ZfNkkQw7O9bLPzAJ3dl5dFIzDODhJm
CNTWAljmm69lBl4TNmlK1LMWKhYHxMJRPzCdEr/WvkXekRgI3zk7uuEKB8thTxOs
RCLkIAgw12/XkAFOnxdhD39xNTVbg88TkpNPvnMqcLkj5hBlY+Cs1npdrKvBER2b
nFt1+tI8WT5nznw62JmeGiHUYcyvx3p35Ilezg6SgFNKlhdaZW7IiTy8jRi2zmag
O02VV+ljaYUMd/bJtaEpbN95J9jn9XMQr0wdUZrbNV8OUkddJat5AWspGsTc5uQT
zNEwHoGXBpCTNImJrmB2aa8LhsHHuUHDRoeRmww6jGDBJSItb9y0aKIdSvyRSObB
yiQ1mCOJztLFjDNDnGTq01kF4dKsK2rCZ6YrJY7y0qRz4/yFB6dframC0lhBRvWw
NEjRdnTSMgSTMhn8GmptmHIxIvdBvO3ef7fvTBSP5yimRrxDVPVpJCFi8VJo4rV2
iesOWBubYWEGFKkUerWV
=1108
-----END PGP SIGNATURE-----

Well the actual purpose I had in mind was as part of a qemu-img convert line, I just wanted to read the source .vhd file directly over the smb network from the other server.

For an example lets simplify by using a copy command as an example:
cp \Machine\Share\myFile.txt myfile.txt
doesn’t work

Should I be doing something like:
cp smb:\Machine\Share\myFile.txt myfile.txt

Nick

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mount it (the share) first, then use the command from the mountpoint.
That will be easiest, use the least amount of space locally (assuming
you do not want to copy it locally before doing something with it).

Something like:

mount -t cifs //serverhere/share /mnt

  • From there you can go directly to /mnt/whatever/goes/here/from/share and
    access everything seamlessly.

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPkYgfAAoJEF+XTK08PnB5AyAP+waD2J176QpfJvvPtbvd42ki
e782uh0FW1nfl7XqTCX9YBOIMZ8c2jVje3Q/7yw/6S8GTnSI/D7ZDCnZ4llopDn6
D5vKSiUu+NiuxALNDM1kiOT2sunWu9Kj2gmu85WZZHSRjyL00pscrK529ZR4q3NL
YBmWVQcbbkVVQ3Z77R2RTqVhBGi5ju18PU4eXJaiwO9lEX5Ue1+eJov57nmaQvyA
961773St2rIqNM+dJNq9um9eTTqllXF/hS2X0trDi8O0d3ImgpcWENmn7DFkCgMq
Mi+Q/4mF82hCQjM6Yb7h/RUGkBoOprZQaJvVxQYUoztVwFh+xT1iZPnCZKif+pPO
+X48b60cjFigoB+7KeH4bztyZvsqNdT53lxPGJ3VEm7V5rSRN7aLzk3Ms05IuZXu
np3E4FtMB5irvuhQb45RWaoy77CdEwXXvV5SBHfIuiO+AaryZ5cSfErnvzJSxtIl
MrWQHybx3mX0iktuqCmh6lPxBbd1PCiBzITmwGsPG96MXJukq9/ZrKTNAcWdxvQW
fy3yTtY0+Wt+ypoos13/Gg3pBr+m3w3yGLhrV0MvMVyY6/ey+yhfhfMHlxrcVfSK
A61YExOfWcMJrz203Cmkw4cVI+GXEViRC3+ecJOAwzgvlABlQ+8fsGtQqeN6J91z
gbKk9SmeBOCL5ae2jK3s
=WkZG
-----END PGP SIGNATURE-----

On 2012-04-20 16:12, ab wrote:
> For what purpose, exactly? You need to somehow tell the system you’re
> using SMB, and a couple of backslashes is not going to do it since those
> are just characters. I would look into smbmount (mount the share
> somewhere and then access it normally)

I don’t see “smbmount” anywhere :-?


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On 04/20/2012 03:13 PM, Carlos E. R. wrote:
> On 2012-04-20 16:12, ab wrote:
>> For what purpose, exactly? You need to somehow tell the system you’re
>> using SMB, and a couple of backslashes is not going to do it since those
>> are just characters. I would look into smbmount (mount the share
>> somewhere and then access it normally)
>
> I don’t see “smbmount” anywhere :-?

When smbfs got renamed to cifs, it went away. Now you use “mount -t cifs”, or
“mount.cifs”.

Tried that but get:
mount error: could not resolve address for servername: unknown error

smbtree lists the server share correctly.

You need to replace servername with the name or ip address of your server :slight_smile:
Probably You want to replace share with the name of your share as well.

Best regards,
Greg

Yes I have, actual command used is:
mount -t cifs //Host1/Data /mnt

Please try with the ip address or edit your /etc/nsswitch.conf so that your system will use WINS name resolution.

Add wins to this line :

hosts:          files mdns4_minimal [NOTFOUND=return] dns

Best regards,
Greg