How to transfer files from one Linux system to another

From ITSwiki
Jump to: navigation, search

This is a short tutorial for copying from any Linux/Unix system to another.

Using tar

Example:you have some files you want to copy/transfer from your own Linux system onto a server.

Create a new directory:

mkdir project2010

copy the files you want to transfer into that directory/folder:

cp file1.c file2.c project2010
tar cf project2010.tar project2010

When this has finished, do:

scp project2010.tar xyz@thinlinc.imm.dtu.dk:/home/xyz/project2010.tar

Now logon to thinlinc.imm.dtu.dk and do:

tar xpf project201.tar

When this has finished then do:

rm project2010.tar

Using tar over ssh

You can pipe the output of the tar command directly to ssh, and thus avoid the storing of the temporary .tar file. Place your files in the directory as above, then run the following:

tar -cf - project2010  | ssh USERID@thinlinc.imm.dtu.dk tar -xf -

This will tar the local directory "project2010" and untar it on thinlinc into a directory project2010 in your home.

Using rsync

The following command will copy the local directory "project2010" to your home directory on thinlinc.

 rsync -av project2010 --rsync-path=/opt/csw/bin/rsync USERID@thinlinc.imm.dtu.dk:

If you want to place it in a different directory on thinlinc then just add that directory name after the : in the above command.

As with any file copy please ensure that you do not accidently overwrite any files on thinlinc.