Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am scping into a virtual server and need to copy some files into the /var/www/ directory so apache2 can serve 'em up. However, by default, the files that I upload go into the users dirctory. I need to get them two levels up. How would I do this over scp?

share|improve this question
    
How are you specifying the path at the second part of the scp command? –  Thomas W. Nov 15 '13 at 3:34
    
Like so: ~/var/www –  TJonS Nov 15 '13 at 3:37
add comment

1 Answer

up vote 3 down vote accepted

If you are not specifying user@host:/var/www as the destination path you're going to run into this issue. Note that the user you upload as MUST have access to write to the directory.

Assuming that the user has write permissions to /var/www, then make sure your scp command follows this general pattern, with [options] being replaced by whatever options you need:

scp [options] /local/path user@remotehost:/remote/path

Replace the local path and the remote path with the actual paths though.


IF YOU DO NOT WANT TO HAVE THE UPLOAD IN YOUR HOME DIRECTORY, DO NOT USE ~ AT ALL FOR THE BEGINNING OF THE REMOTE PATH!

~ is a shortcut to add /home/$USER to the path if it appears at the beginning of a path, and is the exact reason you're running into this "Uploading to Home Directory" issue, based on your comment on your question. Just do user@host:/var/www like I specified in my answer here for the remote path.

share|improve this answer
    
I just tried that. It said the following: scp: /home/ubuntu/var/www: No such file or directory What should I do now? –  TJonS Nov 15 '13 at 3:39
    
@TJonS, you just pointed out your own problem. "Like so: ~/var/www – TJonS 15 mins ago" <-- that's your comment. ~ is a shortcut for /home/$USER. Remove the `~ and it'll work. –  Thomas W. Nov 15 '13 at 3:53
    
Just realized that. Thanks :) –  TJonS Nov 15 '13 at 3:53
    
@Thomas W. Why do you not recommend the usage of ~ in remote paths? I mean for the question it's obvious, but it sounds like "in GENERAL don't use ~". Because it refers to a variable? –  chaos Nov 15 '13 at 7:11
    
@Chaos reread the context of the initial question and then all comments and then reread your comments and my answer. I did not say "In General" don't use. If you read TJonS comments later, you'll see that he failed and used ~ in the path which led to the whole problem in the first place. If I had said "Don't use ~ ever!" that would be a different story. Context of the question and comments and answers is very important here. To please you, though, I've edited my question, although you need to read up on why context of an answer in relation to the question is important. –  Thomas W. Nov 15 '13 at 18:44
show 1 more comment

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.