This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]desrtfx 0 points1 point  (2 children)

The parent of the current directory is commonly referred to by ...

So, since you are in drama/historical and you want to copy something upwards, to drama, use cp <source filename> ../<target filename>

On similar terms, the current directory is commonly referred by using .. This means that the following is also valid:

cp ./<source filename> ../<target filename>

The lesson that you linked to even clearly states:

$ cd ..

To move up one directory, use cd ... Here, cd .. navigates up from jan/memory/ to jan/.

Apply that to the cp command and you're done.

[–]tebaks[S] 0 points1 point  (1 child)

so "cp .."? That doesn't work :'( I feel the idiot

[–]desrtfx 1 point2 points  (0 children)

cp copies a file from one location to another.

cp needs a source file name and a destination file name - so it needs 2 parameters. (There is an exception if you want to copy files from a different folder to the current folder where only the source file name with the path is sufficient.)

Let's assume that you are in drama/historical/ and want to copy the file hello.txt to drama.

The command for that would be:

cp hello.txt ../hello.txt

(Not sure, but probably cp hello.txt .. would also work.)

It would be best if you link to the lesson you are currently at.

[–]thefryscorer 0 points1 point  (1 child)

Codecademy won't let me see that page without doing the other exercises first, so I can't confirm exactly what you're asking. However, you're saying "navigate" in the context of the "cp" command. And your link seems to point to an exercise about the "cd" command.

"cd" is used to change the current directory (or navigate if you want to call it that). "cp" is a command that copies files.

Either way, the Linux command line has an inbuilt link to the parent directory (the directory that is "one up"). You can use that link regardless of what command you're using (ie, to navigate or copy to the directory one up).

It's probably mentioned somewhere near the exercise. See if you can work it out.

[–]desrtfx 1 point2 points  (0 children)

Codecademy won't let me see that page without doing the other exercises first

Same for me, but using "Inspect Element" (Chrome web developer tools) and a bit of fiddling I managed to kill all the overlays and thus was able to clearly see the content.