LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-15-2009, 02:46 AM   #1
7mza
Member
 
Registered: May 2008
Location: Jordan
Distribution: use fedora but prefer Slackware
Posts: 98

Rep: Reputation: 15
Exclamation help with understanding scp command


hi , i read tutorial about scp command but still didnt understand how it work ,
if i want to upload files from localhost to server what should i do ?
i got the syntax to upload file from host to server :
scp filename1 name@website:filename2 ??
so filename1 is the file on my localhost right ?
i dont know what`s filename2 mean ?
if i want to upload on specific path on server is this possible using scp ?
last Question , which faster scp or ftp for uploading files ?
 
Old 09-15-2009, 02:55 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by 7mza View Post
hi , i read tutorial about scp command but still didnt understand how it work ,
if i want to upload files from localhost to server what should i do ?
i got the syntax to upload file from host to server :
scp filename1 name@website:filename2 ??
so filename1 is the file on my localhost right ?
i dont know what`s filename2 mean ?
if i want to upload on specific path on server is this possible using scp ?
last Question , which faster scp or ftp for uploading files ?
ftp would probably be faster as scp has to encrypt files first...but here is the advantage. encryption.

the syntax is pretty simple.

from localhost to remote server

Code:
scp filename  user@remoteserver:/path/to/remotedestination
and

Code:
scp filename  user@remotehost:/directory/
There are also a few fancy flags you can add.

see man scp

Last edited by centosboy; 09-15-2009 at 02:56 AM.
 
Old 09-15-2009, 03:02 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
scp filename1 name@website:filename2
filename2 means that filename1 will be loaded onto the server and renamed as filename2 at the same time. Basically the syntax of a scp command is similar to that of cp. You have just to take in mind that to specify a remote path the syntax is
Code:
user@host:/path/to/remote/file
where the hostname (or IP address) and the colon are mandatory. If you omit the username, scp will try to connect using the same username as in your local machine. From what stated above, you can copy to a spcecific loaction on the remote server, by typing the path immediately after the colon:
Code:
scp filename1 user@host:/home/user/my_files/
this will copy your local file to the directory /home/user/my_files/ on the remote host. You can also use relative path, taking in mind they refer to your home directory on the remote server. If your home was /home/user in the example above, you could also do simply:
Code:
scp filename1 user@host:my_files/
Some useful options of scp are -p to preserve the timestamp of the original file and -r to recursively copy a directory or an entire directory tree. For example:
Code:
scp -pr /path/to/your/local/dir user@host:
Since I did not specify any path on the remote server (but not the mandatory ":" at the end) this will copy the local directory to your home dir on the remote host.

Finally, you may have some problem to specify file names on the remote server if they contain blank spaces. The correct way to do that is to double escape them so that a single escape character is passed intact to the remote server:
Code:
scp -pr user@host:"/path/to/dir\\ with\\ spaces/" .
moreover, this show you how to retrieve a directory (or a file) in the opposite way: FROM the remote server to the LOCAL machine (in this specific example to the current directory "."). Hope this helps.
 
Old 09-15-2009, 03:08 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by 7mza View Post
last Question , which faster scp or ftp for uploading files ?
They are two completely different things and they cannot be compared in term of speed. Theoretically ftp is faster, since it does not use encryption, but I think that the speed of the transfer is mainly due to network issues.

scp uses encryption to send both the password and the data. In this sense is far more secure. It also permits passwordless connection if you set-up a private/public key authentication (plenty of on-line documentation about this topic).
 
Old 09-15-2009, 03:09 AM   #5
7mza
Member
 
Registered: May 2008
Location: Jordan
Distribution: use fedora but prefer Slackware
Posts: 98

Original Poster
Rep: Reputation: 15
tnx alot

tnx guys its really helpfull and i got the idea
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp command zchoyt Linux - General 10 04-02-2014 07:47 AM
scp command Swapna173 Linux - Newbie 5 05-21-2009 01:54 AM
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 06:02 AM
SCP Command yusufs Linux - Newbie 3 11-07-2007 02:44 PM
command of scp Paxmaster Linux - General 4 01-06-2005 12:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration