Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am newbie struggling to move a file on a Linux VPS using PuTTY.

I can log in with a user in PuTTY at this point I can navigate to see the file I wish to move (~/servers/apache-solr-3.6.2/example/webapps/solr.war).

By using cd .. a couple of times from the directory I begin at when I first log in to PuTTY I can then navigate to the location I wish to move the file to: usr/local/jakarta/apache-tomcat-5.5.36/webapps/

I know that I need to use cp to copy the file and have tried variations on: cp ~/servers/apache-solr-3.6.2/example/webapps/solr.war usr/local/jakarta/apache-tomcat-5.5.36/webapps

However each time I get 'No such file or directory'

I have tried excluding the ~/ and the start and I have tried specifying solr.war at the end of the command.

Please excuse the newbie question, but I would really appreciate some advice on what I am doing wrong here.

share|improve this question
Download WinSCP and log in using the same credentials. It's likely to work and will be a better interface if all you want to do is move files. – LawrenceC Jun 26 '13 at 13:46
shouldn't it be /usr/local/jakarta/apache-tomcat-5.5.36/webapps (slash at front before usr) ? – James Jun 26 '13 at 14:53
@ultrasawblade Does that support copying/moving on the remote machine? It's not very elegant to download to the local machine and then upload again. – Bob Jun 26 '13 at 16:53

Some general notes:

  • The format of the copy (cp) command is cp source destination
  • In the *nix (Unix, Linux etc) world, directories are represented by / as opposed to \ in Windows. The root of the filesystem (Windows' C:\) is /. So, the Windows path


    is this on Linux

  • ~/ is your home directory, also known as $HOME.

  • You don't need to cd to the directory you need to copy things to/from, you can just give the full path to it.

  • You don't need to type the entire path out. On most Linux systems, when you start typing a path, you can hit Tab to complete it. If there is more than one possible completion, hit Tab twice to see them. For example, type

    ls /bo

    and hit Tab, it will automatically be completed to

    ls /boot

So, putting all this together, instead of writing the whole path, try writing the beginning and using Tab to autocomplete. I suspect your file is not in ~/servers but in /servers so try:

cp /servers/apac Tab

Does that autocomplete? If not, try

cp ~/servers/apac Tab

Once you find the correct source directory, use the Tab trick again to find the right destination directory.

share|improve this answer

If you are typing exactly:

cp ~/servers/apache-solr-3.6.2/example/webapps/solr.war usr/local/jakarta/apache-tomcat-5.5.36/webapps

try typing this instead:

cp ~/servers/apache-solr-3.6.2/example/webapps/solr.war /usr/local/jakarta/apache-tomcat-5.5.36/webapps

Without the / in front of usr it's likely trying to go to your current directory plus usr/local/jakarta/apache-tomcat-5.5.36/webapps instead of off /.

EDIT: If you really have a usr directory in your home directory and are trying to copy to something like /home/your_user_name/usr/local... then specify the full path.

share|improve this answer

Copying a file requires two things:

  1. Correct locations
  2. Correct permissions

Looks like you are struggling with the location part.

Try navigation to both locations and running the command "pwd". pwd returns the complete file path of where you are.

Copy the pwd output from both locations to use your cp command.


cp 'pwd output source'/solr.war 'pwd output destination location'

For permissions: You need to verify that you have permission to write to the destination you are trying to write to as well as read the file you are trying to read. Do an ls -al on the file you are trying to copy and an ls -al on the destination folder, and provide that output. You can also Google file permissions. Or you can read this article to understand the permissions for yourself:

share|improve this answer
I thought this at first too but he left / off of usr... – LawrenceC Jun 26 '13 at 13:53

You skipped / before usr.

Solution (first line yours, second correct):

cp ~/servers/apache-solr-3.6.2/example/webapps/solr.war usr/local/jakarta/apache-tomcat-5.5.36/webapps

cp ~/servers/apache-solr-3.6.2/example/webapps/solr.war /usr/local/jakarta/apache-tomcat-5.5.36/webapps/

I recommend you to review this and this short videos to understand basic Linux terminal commands.

share|improve this answer

The solution to this was based on a combination of contributions from the other answers - thank you all. september and ultrasawblade were correct to point our that i needed a forward slash before usr:

    cp ~/servers/apache-solr-3.6.2/example/webapps/solr.war /usr/local/jakarta/apache-tomcat-5.5.36/webapps/

Thanks gabe for pointing out the possibility of permissions problems. So for me the above command didn't work because I didn't have the correct permissions as the user I was logged in as.

Thanks terdon for pointing out that ~/ means the home directory for the current user which is basically equivalent to /home/username/. Knowing this meant I could log in as the root user (avoiding permissions issues) and type the following command (which worked):

    cp /home/username/servers/apache-solr-3.6.2/example/webapps/solr.war /usr/local/jakarta/apache-tomcat-5.5.36/webapps/ 

Thanks for all of your help with this. Gabe and septemebr - thank you for the links to those resources - they were helpful.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .