Difference between revisions of "How to transfer files from one Linux system to another"

From ITSwiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
(Created page with "This is a short tutorial for copying from any Linux/Unix system to another. <span class="script">page.toc</span> ====Using tar==== Example:you have some files you want to c...")
 
Line 1: Line 1:
 
This is a short tutorial for copying from any Linux/Unix system to another.
 
This is a short tutorial for copying from any Linux/Unix system to another.
  
<span class="script">page.toc</span>
+
==Using tar==
 
+
====Using tar====
+
  
 
Example:you have some files you want to copy/transfer from your own Linux system onto a server.
 
Example:you have some files you want to copy/transfer from your own Linux system onto a server.
Line 14: Line 12:
  
 
  cp file1.c file2.c project2010
 
  cp file1.c file2.c project2010
cd project2010
+
  tar cf project2010.tar project2010
  tar cf ../project2010.tar . &amp;
+
  
 
When this has finished, do:
 
When this has finished, do:
  
cd ..
 
 
  scp project2010.tar xyz@thinlinc.imm.dtu.dk:/home/xyz/project2010.tar
 
  scp project2010.tar xyz@thinlinc.imm.dtu.dk:/home/xyz/project2010.tar
  
 
Now logon to thinlinc.imm.dtu.dk and do:
 
Now logon to thinlinc.imm.dtu.dk and do:
  
mkdir project2010
+
  tar xpf project201.tar
cd project2010
+
  tar xpf ../project201.tar &amp;
+
  
 
When this has finished then do:
 
When this has finished then do:
  
cd
 
 
  rm project2010.tar
 
  rm project2010.tar
  
'''NOTE''':
+
==Using tar over ssh==
 
+
1) the '&amp;' means:execute in background<br /> 2) the command 'jobs' will show you which jobs that are still runnning<br /> 3) the . (dot)is very important - it means "here" in Unix "language"
+
 
+
====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:
 
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:
Line 45: Line 34:
 
This will tar the local directory "project2010" and untar it on thinlinc into a directory project2010 in your home.
 
This will tar the local directory "project2010" and untar it on thinlinc into a directory project2010 in your home.
  
====Using rsync====
+
==Using rsync==
  
 
The following command will copy the local directory "project2010" to your home directory on thinlinc.
 
The following command will copy the local directory "project2010" to your home directory on thinlinc.
Line 53: Line 42:
 
If you want to place it in a different directory on thinlinc then just add that directory name after the : in the above command.
 
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.'''''
+
As with any file copy please ensure that you do not accidently overwrite any files on thinlinc.
[[Category:2010]]
+
 
 
[[Category:Linux-Unix]]
 
[[Category:Linux-Unix]]
 
[[Category:Tips and Tricks]]
 
[[Category:Tips and Tricks]]

Revision as of 18:16, 11 June 2012

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.