How do I copy files to a Windows Share?

10

1

How do I use bash to copy files to a Windows share?

Jake

Posted 2012-01-16T10:44:09.723

Reputation: 639

your question belongs to [su], voting to close – CharlesB – 2012-01-16T10:53:52.013

Answers

6

Unless you're looking for a permanent setup (where smbmount might be better) you want to use the smbclient solution, which acts similar to a FTP client. You connect, then cd around and put/get files.

Connect as follows:

$ smbclient //computer.domain/sharename -U domain/username
Enter domain/username's password: 
Domain=[DN] OS=[Windows Server (R) 2008 Enterprise 6002 Service Pack 2] Server=[Windows Server (R) 2008 Enterprise 6.0]
smb: \>

Check the manual page here: http://linux.die.net/man/1/smbclient

Mattias Ahnberg

Posted 2012-01-16T10:44:09.723

Reputation: 938

Thanks for this, I am now able to connect to the remote windows computer. I can list the files and folders in that share. Now whats the command to copy a file located in my home folder to the windows share? – Jake – 2012-01-18T07:38:53.663

Just put filename.txt for example. – Mattias Ahnberg – 2012-01-18T15:54:47.630

Thanks for the help. Here is what worked for me. mkdir /mnt/smbshare and then sudo mount -t cifs //serverfs/c$ -o username=Jasonbe,password=password /mnt/smbshare – Jake – 2012-01-19T09:02:33.000

2

I assume that you use *NIX.

So, basically, you have to mount the share with smbmount, then just use the cp command.

Refer to this and CIFS utils

onur güngör

Posted 2012-01-16T10:44:09.723

Reputation: 151

2

To expand a little on @onur's point - as long as you have a filesystem mounted, (almost) all normal file utilities should be usable, as at that point it just appears to *nix as a filesystem.

Samba allows you to mount windows shares using smbmount, which comes as standard with many distro's and as an option with most others.

Commands such as cp, mv etc should work just fine.

Rory Alsop

Posted 2012-01-16T10:44:09.723

Reputation: 3 168