Solved

Copy file (cp) from one command line (BSD) to another.

Posted on 2010-09-12
6
432 Views
Last Modified: 2012-06-27
logged in via ssh, need to copy a file from another machine back to my machine.
What is the command for the extraction of the file.
I know how to cp a file from directory to directory or mv, can't remember the command.
Unix.
0
Comment
Question by:T_Myles
6 Comments
 
LVL 6

Expert Comment

by:sagiamar
ID: 33658127
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33658157
scp /source/file user@targethost:/target/directory/
or
scp user@sourcehost:/source/file /target/directory/
0
 

Author Comment

by:T_Myles
ID: 33658545
woolmilkporc:

I'm in the machine via ssh I want to send file to another remote server.
A directory is what I want to cp over.

Since I'm inside the machine, shouldn't there be a -R included, I'm confused about the second line.
If I can rap my head around the path I can get it.  
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 2

Expert Comment

by:anoym
ID: 33658625
To copy files and subdirectories I'm using:

# scp -r -p /source_directory/* username@ip_adresse:/target_directory

To copy a whole directory you can use:

# scp -r -p /source_directory username@ip_adresse:/target_directory

and pls check:

http://amath.colorado.edu/computing/software/man/scp.html

0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 33660113
My first line is for copying a file /source/file from the machine you're logged in to a remote server named targethost as user user into the directory /target/directory there.
My second line is for copying a file /source/file from a remote server named sourcehost as user user into the local directory /target/directory
By the way, with scp you can even copy a file/files from one remote machine to another remote machine while being logged in via ssh to a third, arbitrary machine, and moreover, you can give it a new name (the italic string in angle brackets (  <... > ) is meant to indicate the shell prompt!)
<user0@somehost0> ssh user1@somehost1  # (or via PuTTY, or whatever)
<user1@somehost1> (Logged in)
<user1@somehost1> scp user2@somehost2:/source/file user3@somehost3:/target/directory/new_filename
<user1@somehost1> exit
<user0@somehost0>
 
All of the above is for files, since in your question you asked for copying a file.
There is no "-R" (uppercase R) for scp. To have scp work recursively use the "-r" (lowercase r) flag, as indicated by anonym.
wmp
0
 

Author Closing Comment

by:T_Myles
ID: 33662943
Thanks for the detail explanation.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question