Copy files between Linux and Windows

From LQWiki
(Redirected from Sharing Files with Windows)
Jump to navigation Jump to search

This describes how to copy files over the network between a computer (or virtual machine) running Windows and another computer (or virtual machine) running Linux.

There is also an article how to access a Linux partition when running Windows and how to access a Windows partition when running Linux. You may need this if your computer is running only one operating system and having two hard disk partitions.

You are on a Linux host

You want to access a Windows drive

So you are on a Linux computer and want to access a Windows drive over the network. This explains how. In this example we assume winhost is your Windows computer's hostname (you can check the hostname by right clicking on My Computer and selecting Properties). Go to the Windows computer and open the Explorer. Share a folder by right-clicking onto it and selecting "Sharing and security". Call it "share1". Then, on your Linux computer,

  • Open up your favorite file explorer, perhaps Konqueror or Nautilus
  • In the address bar, type smb://winhost/share1
  • You should now see the files and folders in that share. Double-click on them to open them up and view them.

troubleshooting

If that doesn't work, then you may need to do something more complicated.

smbclient -L winhost
  • If you see the share, mount it like this:
mount //winhost/share1 /mnt/smb
  • after the next reboot, your mount will be lost. To make it persistant, add the following line to your /etc/fstab:
//winhost/share1  /mnt/smb smbfs  defaults  0  0

You want to share a folder

So you are on a Linux computer and want to share a folder so that also Windows machines can access it over the network. To do this, you run the SAMBA service on your computer. To enable sharing to Windows machines, right click on a folder in Nautilus; the menu should have an item called "Sharing Options". Click it and pick the name for your share. If you don't have Windows folder sharing enabled yet, Nautilus will ask you for a password and install the service, after which you will need to log out and back in. The share should now be available on the Windows computer.

See also Setting up a Samba Server.

You are on a Windows host

You want to access a Linux drive

Use WinSCP. Choose the SFTP protocol; the login and password are the same as those you use when logging in locally. If it does not work, look at your Linux computer: Try to shut down your firewall and install the openssh service.

You want to share a folder

You can share files with Linux using normal Windows sharing mechanisms. The Linux host will be able to access these files using samba.

See also