Moving files between Unix and Windows systems

Choosing the right tool -- Secure Copy, Samba, or Rsync -- for the right job

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.

Secure Copy

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.

Samba

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.

1 2 Page
Mobile Security Insider: iOS vs. Android vs. BlackBerry vs. Windows Phone
Recommended
Join the discussion
Be the first to comment on this article. Our Commenting Policies