I am trying to copy a file from inside a bunch of folders to the current directory I am in. Playing around with the terminal, I see that when I specify the entire location it works:

joostin@ubuntu:~$ cp ~/unixstuff/vol/examples/tutorial/science.txt .

But when I go into the unixstuff folder and try to bring it into the current directly I get an error. Any idea what is going on?

joostin@ubuntu:~$ cd unixstuff
joostin@ubuntu:~/unixstuff$ cp /vol/examples/tutorial/science.txt .
cp: cannot stat ‘/vol/examples/tutorial/science.txt’: No such file or directory

There is no such directory /vol, but it is vol (without slash), so try just

 cp vol/examples/tutorial/science.txt .

/vol/examples/tutorial/science.txt is an absolute path. When a path begins with / (slash), it starts from the root directory. If you want the path to start at the current directory (relative path), it must not start with a slash.

joostin@ubuntu:~$ cd unixstuff
joostin@ubuntu:~/unixstuff$ cp vol/examples/tutorial/science.txt .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.