Tuesday
Jan122010

Copy files between Linux and Windows

So the introduction of Linux boxes on the network had me stumped as to how to copy files back and forth.  (Trust me:  it comes up.)

There's a lot of ways to do it.  You can sftp the files back and forth, get fancy with Cygwin, or download a nifty GUI utility here.

I choose to leverage SAMBA (in Windows-speak, "smb" or server message block). 

This can expose a "share" on the Linux box to Windows or allow you to copy from Windows to Linux.  Let's try the latter first.

Log into the Linux machine (as root, preferably).

  1. Find the smb.conf file (i.e. nano /etc/samba/smb.conf).  If you're not sure where smb.conf is you can search for files in Linux like this:  find / -name smb.conf where "find" is the command, "/" is the directory you want to start the search in, and "smb.conf" the file you want to search for.
  2. Edit smb.conf via nano smb.conf or vi smb.conf.  If you're new to Linux I would suggest nano.  It's in most distributions.  If you're trying to impress someone use vi.  There's others, of course.
  3. You'll want to add the following sections in smb.conf to create a folder called "SHAREDFOLDER" accessible by users tallarico and root .
  4. Note that to create a "tallarico" user you'd use the command useradd tallarico then a passwd tallarico both executed by root to create the user and set the password. To create the folder do a mkdir /home/tallarico/SHAREDFOLDER .
  5. Restart samba with service smb restart .

    You should now be able to browse to the Linux box (e.g. LINUX1) from your Windows machine via Start > Run \\LINUX1\ and logging in with the credentials to user LINUX1\root (or user LINUX1\tallarico - depending on how you set up security on your smb.conf.