There are many ways to move files between Unix and Windows. In my mind, they fall into three categories -- secure copy (let's not even think about ftp), shared drives, and file synchronization. Each has its own advantages.
For secure copy, we have scp and sftp commands. Native to Unix systems, both commands are available for Windows as well. I use pscp (PuTTY's scp) which you should find in your PuTTY folder (e.g., C:\Program Files\PuTTY or C:\Program Files (x86)\PuTTY) if you have PuTTY installed. I make sure the folder is in my Windows search path so that I can access it from any directory and then run commands that work just like scp on Unix:
C:\User\shs> pscp myfile.txt shs@unixserver:/home/shs
Works like a charm. The command will ask for your password and move the file or files specified. Wild cards are acceptable. Just remember that text files moved from Windows to Unix systems will retain their carriage returns and those coming in the opposite direction will lack them.
Another option for moving files between Unix and Windows systems it to make a drive or folder available by "sharing" it. Both Unix and Windows have commands for this. To share files between the two types of systems, you can use Samba. Samba is an implementation of the SMB/CIFS networking protocols. So it runs on a Unix system and allows Unix directories to be accessed by Windows systems or Windows shares to be mounted on Unix systems.
To set up shared directory on a Linux system, you have to add a section to your samba configuration file describing what you're sharing and how. You will have different settings depending on what you are sharing and its sensitvity. In general, home directories should be available to their owners and public directories available to everyone. However, this doesn't mean that you shouldn't limit who can access anything on the server. "Everyone" might mean everyone on a particular subnet or in a particular group. Other settings in the smb.conf file allow you to limit who can access Samba shares to specific hosts or IP ranges.
Shares set up in the Samba configuration file (smb.conf) will look like what you see below. Most section labels (e.g., "public") serve as the mapping name. The /shares/public folder shown below, for example, can be mapped on a Windows system with the command "net use P: \unixhost\public" where P: is an available drive label, unixhost is the name of the Unix server, and public is the label we set up in the smb.conf file. The label "homes", however, is a special one in that it tells the Samba service to allow home directories to be shared. Each user can then map his or her own home directory on their Windows systems.
[homes] comment = Home Directories browseable = no read only = no create mode = 0750 [public] path = /shares/public public = yes writable = yes create mask = 0777 browseable = yes
Samba also allows you to mount Windows shares on your Unix server. Sometimes it's easier to mount a shared Windows drive, copy the files it needs, and then unmount the drive than it would be to make this happen from the Windows side.
To mount a Windows share, you would use a command like this:
mkdir /mnt/datafiles mount -t smbfs -o username=remuser,password=abc123NOT //windowshost/datafiles /mnt/datafiles
In this command, /mnt/datafiles is a mount point we're setting up to move the files we need, remuser is the name of a user recognized by the Windows system, abc123NOT is his password (please use better passwords!), and windowshost is the name of the remote system.
From the Windows side, you can view what is being mapped and what is being share with the "net use" and "net share" commands.
Copying files with rsync has the distinct advantage of great performance since rsync smartly copies changes in files rather than complete files whenever that's an option. This means that, if a single byte has been added to the source file, a single byte will be transferred to the destination.
Rsync can be used to copy files from one system to another, but it's meant to keep files synchronized between systems. You may be familiar with using rsync between Unix systems, but versions of rsync are available to synchronize files between Windows and Unix systems too. Check out Grsync for Windows systems at sourceforge -- http://sourceforge.net/projects/grsync-win/?source=recommended&_test=goal.
This article is published as part of the IDG Contributor Network. Want to Join?