Stack's Lessons in Linux: File Transfers!

General questions regarding Linux.

Moderators: Terry, FWLUG Administrator

Stack's Lessons in Linux: File Transfers!

Postby stack » Tue Jan 20, 2009 5:11 pm

Hello everyone!
Today's lesson in Linux is about File Transfers! It is brought to you by the letter W and the number 2.

Before we begin today, let me recap a story. A story that is told over and over and over again by thousands of people world wide.

A goes to visit B. A brought along pictures and movies that A took on A's recent vacation. B wants copies. So they decide to network A's laptop to B's network. Sadly, A can't seem to share the data in a format B can understand and visa-versa. After several minutes they give up and decide to just transfer over a physical medium. A has no CD/DVD burner, but B has a 1GB flash drive. A can transfer the small pictures, but the movies are all too big! A & B get frustrated and give up.

Can anyone in the class guess which Operating System was in use?
If you guessed Windows, you are correct!

I have heard people in the group having this problem. I know I have run into this on a regular basis. The 'straw that broke the camels back' for me, so to speak, was when I was recounting a very similar story to an acquaintance and the reply was "well you have these difficulties with all OS's, including Linux"

DAAAAAGGHGHHHH!!!

No. You. DON'T! Linux is no where close to being as difficult. Hence, today's lesson.

But first, what are your options in Windows?
Well let us take a look at the OS in question. Windows. In my latest historical repeat of this story, I was dealing with a guest laptop of Vista and a local desktop install of XP. ('wait? Stack has a copy of XP?' Long story. Built last week. Doubt it will survive to see week 3 of life).

Windows Share.
The Vista system could see the Linux Samba share setup, but was unable to write to it. The Vista system refused to see the share setup on XP. The Linux system could see the Vista share, but was denied access (even with the share set to guest with no password). The XP system couldn't see the Vista share.

FTP.
We configured both Linux and XP with an FTP server. Vista was unable to write to either FTP servers. Whenever we entered in ftp://user@ip.add.re.ss into Windows explore or Internet explorer, IE would open and allow us to browse/download but not upload.

Telnet.
We connected, but I have long forgotten the telnet commands to transfer files. Seriously. Who uses telnet anymore? Why does Microsoft still package it? I mean, I guess it is still around in Linux too, but come on. Seriously? Hey Microsoft! Try updating your code from the 90's!


These limited and poorly supported protocols are about it for Windows. Yes you can install others, but that is for a more advanced user. Not something for an average home user to use. Sure I could have set up putty or Cygwin and SSH, and that would have been a waste as the Vista user probably won't ever use it again. I could have set up an FTP server, but again a needless install. Besides, the last thing I need to be doing is farking around with Windows Firewall and services! Redmond already wasted a lot of my life that I will never get back, why give it more? Especially when the alternative is so easy and Just Works!

So then, what are your options in Linux?
Or more to the topic, why was my acquaintance so wrong? How about I give 7 reasons of varying technical degree. Two examples from so_easy_a_dead_brain_chimp_has_already_done_it. Three from at_least_enough_technical_competence_to_do_a_Google_search. Lastly, two from it_helps_to_have_group_around_who_knows_what_they_are_doing_say_someone_like_the_FWLUG_forums_?_?_. Notice how NONE of these techniques are in the way_out_of_your_league category? That is because, They. Are. Easy! (within the varying degrees mentioned)! These are all programs that can be mastered by the newest of newbies with any kind of motivation to learn simple tricks/tips/commands. Even if they don't want to learn, almost all of these are easily scripted. I have not met anyone in the group who couldn't master these in a day (well maybe not netcat. Not because it is hard, but because it does Sooooooooooo many things. AKA, I will sit at the feet of anyone willing to teach netcat because even I KNOW I will learn something).

Lets start with ZERO-Configuration techniques.
Netcat.
100 internet points to anyone who can name a modern non-specialty Linux distro that DOESN'T have netcat. I would have put up 100$ but I have a feeling Dave would scour the net till he found one. So if anyone can name one, I will print you out 100 internet points instead. :-)

Netcat is sometimes shortened to just nc. It is a powerful tool that lets you talk with people on different systems (IM like), it lets you port scan a computer, it can gather/monitor network traffic, and it can share a file!
To have netcat listen (-l) on a port (-p) and receive a file, on the computer /Receiving/ the file run:
Code: Select all
nc -lp 1234 > your_file

and on the computer /Sending/ the file run:
Code: Select all
nc rec.ipa.ddr.ess 1234 < your_file


That is it! No configuration. No mess. Just a file transfer!

What about folders? Or multiple files?

To have netcat listen (-l) on a port (-p) and receive the files/folders, on the computer /Receiving/ the files run:
Code: Select all
nc -lp 1234 | tar -xv

and on the computer /Sending/ the file run:
Code: Select all
tar -cv your_file your_second_file your_directory/ whatever_else.blah | nc ip.add.re.ss 1234


TaDa! Tis the magic and simplicity that brings a tear to the eyes of everyone who claims Linux is difficult!

Woof!
So you want to share a file/folder from Linux to someone on OSX or Windows. Well as the story goes, good luck. Right? Not so. You are on Linux! So use Woof.
This site does a better job explaining it then I do: http://www.linux.com/feature/60098
In short, it serves up a one time http server with the files. To serve the file just once (-c1) on a specified port (-p1234), use the command:
Code: Select all
woof -p1234 -c1 file_or_folder

The other computer (Linux,Mac,Windows) just needs to have a working web browser capable of accessing a http server. So simple even IE can do it! (You still probably should use Firefox though...)
[side note] Woof _can_ store a configuration file, but it doesn't have to have one so it goes here.

Now for possible/minimal configuration techniques.
SSH
I have not been on a non-specialty Linux system that didn't have ssh in a very long time. Just about every distro out there has at least a client installed. The server side isn't hard to install either. Most distros use openssh, so it is a matter of 'apt-get install openssh-server' (Debian based), or 'yum install openssh' (CentOS, your rpm based distro may vary).
The first scp copies transfer_this_file to the other server and places it in /dest/dir/transfer_this_file.
The second scp copies transfer_this_file and this_file_too to the other server and places it in /dest/dir/transfer_this_file and /dest/dir/this_file_too
The third copies transfer_this_file to the other server and places it in /home/stack/new_name. When you do not specify a location after the : the files are copied to the home directory. Likewise, to keep the same name and place in the home directory one could just use stack@ip.add.re.ss:. where the ':.' is important.
The fourth copies a directory to the other server, places it in home, and keeps the name.
Code: Select all
scp transfer_this_file stack@ip.add.re.ss:/dest/dir/.
scp transfer_this_file this_file_too stack@ip.add.re.ss:/dest/dir/.
scp transfer_this_file stack@ip.add.re.ss:new_name
scp -r transfer_this_dir stack@ip.add.re.ss:.


What if we want to copy FROM the other server? Just reverse them!
Code: Select all
scp stack@ip.add.re.ss:/dest/dir/transfer_this_file .
scp stack@ip.add.re.ss:transfer_this_file new_name
scp -r stack@ip.add.re.ss:transfer_this_dir .


FTP
Again, I can't think of a non-specialty distro that /doesn't/ have a decent ftp client. Granted a lot are command line based, but there are also a lot of good ftp GUI clients. As for the server, I have seen a lot of distros preinstalling vsftpd recently. If it isn't installed, vsftpd is the package name for yum and apt-get. Edit /etc/vsftpd.conf to setup a directory location, then '/etc/init.d/vsftpd start'. That's it!

Giver
Personally, I don't care for a program that gives you AIDS...umm..wait..hold on...no maybe that isn't right...ah! Mono! Umm...this might be a bit of a personal bias but...[in my best Ace Ventura voice] Ewwwwwww....AIDS or Microsoft's Mono? Anywhoo...Giver. Hosted by Google. Drag and drop GUI. How could anyone claim this is _not_ easy? I don't think anyone can with any respect and seriousness. Learn more here: http://code.google.com/p/giver/

Lastly, the 'you will have to configure something' techniques. These vary too much for me to post in detail here. What works for me in Debian may work in Ubuntu, but may not work the same way in Red Hat.

NFS
A perfect example of my last statement. I had a very successful configuration of Debian, CentOS, and Mandrake systems configured in NFS. They all had different configurations but worked together flawlessly!
NFS is Network File System. To the users it just shows up as another mount point folder. Nothing different then a second hard drive, a CD, or a USB thumb drive.

Samba.
Setup a share visible to Linux, Apple, and Window machines.

Both of these _are_ easy to setup. They just require you to have a decent clue what you are doing and to know the commands for your OS. There are countless good tutorials out there, and I am willing to help should someone need it!

That's it for this lesson!
If you have other tips and tricks for transferring files under Linux, please share! I would love to hear them.

For those who insist I am wrong and have never run into problems sharing legal files between Windows XP and Vista [1][2], Happy DIAF'ing!
Note: I am only a little bitter about having so much of my time wasted by Redmond. Just a tiny bit. | | <-This much really. :x
[1] 1,820,000 results from Google. http://www.google.com/search?q=Vista+XP ... k+problems
[2] Only 147,000 from microsoft search. http://search.microsoft.com/Results.asp ... =QBME1&l=1


Have fun kids!
~S~

[EDIT] Someone pointed out to me that there is also a Google search capable of displaying problems with Samba. Way to use the internet Sherlock! The reason why I posted those links was because file sharing between Windows XP and Vista is NOT as straight forward as it once was. It is different enough, that many others are having problems as well. Problems are posted all over microsofts website. Vista screwed up the once simple process of 'right-click folder -> share as'. Vista: Is there anything it can't screw up?

Also, a friend of mine pointed out to me that Firefox has something called FireFTP ( http://fireftp.mozdev.org/ ). I had never heard of it before today, but it apparently fixes the problems we had with FTP and IE. How cool is Open Source? It can even fix Windows problems!
Last edited by stack on Tue Jan 20, 2009 6:11 pm, edited 1 time in total.
User avatar
stack
 
Posts: 268
Joined: Sat Jul 14, 2007 2:11 pm
Location: Fort Worth, Texas

Re: Stack's Lessons in Linux: File Transfers!

Postby maczimus » Tue Jan 20, 2009 5:44 pm

WOW good post Stack. I got so tired of samba that i found something along the lines of Giver

http://p300.eu/

it finds other clients on the network. is platform independent and works great.
User avatar
maczimus
 
Posts: 101
Joined: Fri Jul 06, 2007 8:40 pm
Location: Fort Worth

Re: Stack's Lessons in Linux: File Transfers!

Postby stack » Tue Jan 20, 2009 6:12 pm

Sweet! Thanks maczimus!

Look pretty simple so far. I will have to test it out next time I am with a bunch of friends.
User avatar
stack
 
Posts: 268
Joined: Sat Jul 14, 2007 2:11 pm
Location: Fort Worth, Texas

Re: Stack's Lessons in Linux: File Transfers!

Postby David Miller » Tue Jan 20, 2009 7:22 pm

Woof sounds cool. seems like a good no-fuss way to share files.

One simple way to spray your data about is to cat it over ssh, which might come in handy if you wanted to image a block device over the internet.

do something like
cat /dev/hdx | ssh user@host cat > hdx.image
David Miller
 

Re: Stack's Lessons in Linux: File Transfers!

Postby maczimus » Tue Jan 20, 2009 10:46 pm

Bring it to the next meeting and maybe we can bog down the router even more :D
User avatar
maczimus
 
Posts: 101
Joined: Fri Jul 06, 2007 8:40 pm
Location: Fort Worth

Re: Stack's Lessons in Linux: File Transfers!

Postby guruz » Thu Jan 22, 2009 4:27 am

Hey guys :)

Thanks for mentioning p300. If you need any help you can ask me. If you want to vote on news features, use http://p300.uservoice.com/

Thanks!
Markus (p300 main dev)
guruz
 
Posts: 1
Joined: Tue Jan 20, 2009 6:32 pm


Return to FWLUG General Discussions

Who is online

Users browsing this forum: No registered users and 48 guests

cron