9

I am wondering, is there any way to easily share a folder between Linux and Windows?

3 Answers3

11

Samba

If you want to share files stored on Linux Linux, install a Samba server on the Linux machine. Follow the documentation (Red Hat 6, CentOS 5, Ubuntu).

If you want to share files from Windows, your file manager on Linux can probably connect to a Windows share with no extra effort on your part. Try browsing smb:///. If you want access from the command line, run

mkdir /media/somedir
sudo mount -t cifs //servername/sharename /media/somedir

(If you need help on the Windows side, ask on a Windows site.)

  • 2
    Or use an NFS client on the MSWindows box – symcbean Nov 28 '11 at 09:26
  • this command works perfect but when I restarted the computer I had to do it again. Is there a way to do it permanently? – Tak Mar 15 '18 at 11:58
  • @Tak You can add an entry in /etc/fstab, but this is usually a bad idea with Samba, because it means your computer will get stuck while booting if the server is down. You can also set up an automounter, so that the mount is done when you try to access the directory. I don't have any pointers, search on the web or on this site and ask a new question if you can't find enough information to set it up. – Gilles 'SO- stop being evil' Mar 15 '18 at 13:01
  • @Gilles thanks, I've posted a question here lets hope someone has a solution https://unix.stackexchange.com/questions/430414/automount-windows-shared-folder-on-linux – Tak Mar 15 '18 at 15:10
7

The answer is going to depend very much on which of two questions you are actually asking.

If you want to share files and directories over a network between a PC running windows and a computer running linux that are on at the same time, Gilles' answer regarding Samba is definitely the way to go.

If you're asking how to create a partition/drive on a single dual-booting system that both your windows and linux setups can read, the easiest way is to format a partition as NTFS and use ntfs-3g to mount it in read/write mode in linux.

  • 2
    Or use an ext2/3/4 driver for WIndows. When I explored the question of the existence of drivers for modern Linux filesystems under Windows, I discovered that there was no drivers for XFS or btrfs. But there was for one for ext. – imz -- Ivan Zakharyaschev Nov 28 '11 at 15:05
  • 3
    The ntfs-3g driver for linux seems to be significantly more mature and reliable than the ext2/3/4 drivers for windows. – Shadur-don't-feed-the-AI Nov 28 '11 at 16:08
  • Ok, as for me personally, I had no experience with the ext2/3/4 driver for Windows. @Shadur - thanks for your impression (that it's not mature)! – imz -- Ivan Zakharyaschev Nov 28 '11 at 18:15
  • See also: http://unix.stackexchange.com/questions/5238/which-filesystem-to-use-for-a-partition-shared-with-a-parallel-windows-instalati , http://unix.stackexchange.com/questions/5244/how-to-setup-a-data-partition-shared-by-multiple-linux-oses . – imz -- Ivan Zakharyaschev Jan 30 '12 at 08:14
4

For the Linux -> Windows part, the following is my favorite:

  • python2 -m SimpleHTTPServer
  • python3 -m http.server

This opens a HTTP-Server on Port 8000 for the current directory. You can access it from Windows by typing your IP-Adress in a browser - eg. http://192.0.2.91:8000/

If you want to share a directory, you have to zip it.

schmijos
  • 437