Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have one folder to copy that consists of PHP and similar files for creating a web site.

How do I copy one folder from the server (Linux Ubuntu) to the client PC (Linux Ubuntu) using terminal? Could I use ftp? For the terminal connection I'm using Telnet.

The folder location on the server:

qa@ubuntu:~/www/html/js 

And I want to copy it to the client at:

qa@desktop2:~/home/qa/html
share|improve this question

migrated from stackoverflow.com Jul 1 '10 at 3:05

This question came from our site for professional and enthusiast programmers.

5 Answers 5

up vote 5 down vote accepted

You can use scp if you have an ssh server running on the remote machine (a good thing to have anyway). Telnet is not good, its unencrypted and bothersome.

Since I assume you can ssh onto the remote machine, the basic way to use scp is:

scp -r ~/www/html/js qa@desktop2:~/home/qa/html/js

Assuming that you want to copy from qa@ubuntu:~/www/html/js to qa@desktop2:~/home/qa/html/js scp is pretty powerful, so I suggesting reading the man page for it at

man scp
share|improve this answer
1  
The correct syntax is user@host:path, not user@host/~/path. If I understood it correctly, your example should be scp qa@ubuntu:www/html/js qa@desktop2:home/qa/html (although it's unclear whether @klox wanted ~/home/qa/html or ~/html). –  grawity Jul 1 '10 at 18:03
    
Oops, sorry, my bad. Thanks for the correction. –  Aatch Jul 13 '10 at 22:29

Edit: You'll have trouble copying files via telnet my friend. Why do you insist on using a terminal?

Meaning, you’re running Windows, so presumably have access to a graphical environment. So would using windows file sharing / a web browser / ftp client / ssh client / etc be ruled out because they're graphical? And if so, why?

Do you have root access on the Ubuntu machine? I would suggest you install an ssh server:

sudo apt-get install openssh-server

Then grab a windows SSH/SCP client, eg. WinSCP, and use it to log in to the server and copy your files.

Or if you really really want to do it via the terminal for some reason, grab Cygwin and install opens, then use the 'scp' command mentioned below.

You need to be a little more specific about your situation.

  • what OS is the client running?
  • what OS is the server running?
  • what services is the server running, if you know (FTP, HTTP, NFS, SMB, SSH, etc)

For example, if you have SSH access to the server, something like this would work:

scp user@server.mydomain.com:/remote/path/file.txt /local/path/

If you have HTTP access to the file (http://server.mydomain.com/path/file.txt) then as the poster above suggested, wget:

wget http://server.mydomain.com/path/file.txt

The answer depends heavily on your situation.

share|improve this answer
    
look at my edited question.. –  klox Jul 1 '10 at 3:13
    
the folder location at server: qa@ubuntu:~/www/html/js and i want to copy at client: qa@desktop2:~/home/qa/html –  klox Jul 1 '10 at 3:44

If you're using Windows for this, and you really can't use HTTP in any way to get the file, you can resort to old-school file-transfer over 7-bit ASCII protocols. I'm talking about Z-Modem. It last saw major use over dial-up internet, specifically in the BBS world, with a side-line in unix-to-unix transfers when FTP wasn't available (generally over rsh, but I'm digressing).

Anyway, to get that directory tree from Windows, without using FTP or HTTP, just terminal.

  1. Telnet to server using HyperTerm.
  2. Tar/Zip up the directories you're interested in.
  3. From the command line,
    sz filename.tar.gz  
  4. From Hyperterm, select Transfer -> Receive File.
  5. Specify your save path, and "Zmodem" as the receiving protocol.

It won't transfer as fast as FTP or HTTP would, but it'll get you files.

share|improve this answer
    
how if i want transfer with same OS linux to linux..? –  klox Jul 1 '10 at 4:32

It depends on how the file is served. If the file can be downloaded from a web browser, then the "wget" command will work: http://linux.die.net/man/1/wget

share|improve this answer

If ssh/scp is not available, try netcat.

http://nakkaya.com/2009/04/15/using-netcat-for-file-transfers/

Netcat is basically a simple file dump to a network port. It's useful for transfer to a barebone host when ssh isn't available, or transferring very large files over LAN/internet where SSH encryption overhead becomes a bottleneck.

That said, scp is still the standard way to do transfer files from remote hosts. And if you're trying to transfer a whole directory, it's best to using rsync over ssh:

rsync -avz -e ssh qa@ubuntu:~/www/html/js  ~/home/qa/html

Scp traverses the directory as it's transferred, it can be very slow with large folders. Rsync traverses through the entire directory and applies gzip compression before transfer begins. If a local copy exists, rsync with compare the two and transfer only the delta: the changed portion of the files.

And an added correction for previous scp suggestion: scp a whole directory reqiures the -r option:

scp -r qa@ubuntu:~/www/html/js  ~/home/qa/html
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.