FAQ: Manipulation - cp Part I

Let’s try the cp command out in our environment.

In a single command, navigate to the drama/biopic/ directory. Keep in mind that we’re starting in the top-most movies directory.

Then, list all files and directories in the working directory using ls .

cd/home/ccuser/workspace/movies/drama/biopic
bash: cd/home/ccuser/workspace/movies/drama/biopic: No such file or directory
$

When I tried CD that is what I got in return

Not sure why the instructions say cp, the command for changing directory is cd. You’re closer to it but there must be a space in-between cd and the path you’re trying to change to, cd /some/path

I’m not sure if the absolute path is accepted or not; if it fails consider using the relative path in a manner similar to the one I provided in a previous post-

Yes I tried that to as well and I got the same pathway issue
Let’s try the cp command out in our environment.

In a single command, navigate to the drama/biopic/ directory. Keep in mind that we’re starting in the top-most movies directory.

Then, list all files and directories in the working directory using ls .

$ cd /home/ccuser/workspace/movies/drama/biopic
$ ls
cleopatra.txt frida.txt lincoln.txt notorious.txt ray.txt
$

The correct path for step 1 is
cd drama/biopic

now I am on step 2 where it says Using a single cp command, copy all the contents of frida.txt to lincoln.txt .
cp frida.txt
cp: missing destination file operand after ‘frida.txt’
Try ‘cp --help’ for more information.
$ cp frida.txt/lincoln.txt
cp: missing destination file operand after ‘frida.txt/lincoln.txt’
Try ‘cp --help’ for more information.
$

For step 5 this is what I have gotten and I am still stuck on this any help?
cp biopic/cleopatra.txt historical/
cp: cannot stat ‘biopic/cleopatra.txt’: No such file or directory
$ cp biopic/cleopatra.txt historical.txt
cp: cannot stat ‘biopic/cleopatra.txt’: No such file or directory
$ cp biopic/cleopatra.txt …/historical
cp: cannot stat ‘biopic/cleopatra.txt’: No such file or directory
$ cp biopic/cleopatra.txt historical/
cp: cannot stat ‘biopic/cleopatra.txt’: No such file or directory
$ cd movies/biopic
bash: cd: movies/biopic: No such file or directory
$ cd movies/
$ cd drama/
$ cd biopic/
$ cp biopic/cleopatra.txt historical/
cp: cannot stat ‘biopic/cleopatra.txt’: No such file or directory
$ cp cleopatra.txt historical/
cp: cannot create regular file ‘historical/’: Not a directory
$ cp cleopatra.txt historical.txt/
cp: cannot create regular file ‘historical.txt/’: Not a directory
$

In a single command, make a copy of cleopatra.txt to go into the historical/ directory.

Pay attention to your current position, which you can always access using the command pwd .

Use cp with the first argument being the file name, and the second argument being the destination directory’s path.

The current directory is drama/ , so the relative path to cleopatra.txt is biopic/cleopatra.txt .

historical/ is inside the current directory drama/ , so you can refer to the name directly.

cp biopic/cleopatra.txt historical/ 

I’d suggest using the get-help portion of these forums for issues with each individual instruction (assuming you cannot already find an answer in the FAQ). The Question/Answer back and forth is better in get-help rather than the FAQs.

Make sure to link the relevant lesson and give the following a read for general advice on how best to set up a question-

i am stick on #5 i wrote
cp biopic/cleopatra.txt historical and result is

cp: cannot stat ‘biopic/cleopatra.txt’: No such file or directory

please help…

Hey can anyone assist me? I see a lot of people are having a problem with number 5. I’m clearly taking the wrong path but is there anyone that can help me move forward?

cd drama first
then cp biopic/cleopatra.txt historical

I’m on stuck on part 5

In a single command, make a copy of cleopatra.txt to go into the historical/ directory.

I put
cp biopic/cleopatra.txt historical/
but get an error There should be a version of cleopatra.txt inside the drama/historical/ directory! Did you use a cp command to make a copy to the right destination?

I ls and get
action comedy drama genres.txt

I’m currently waiting for an answer for Step 5 on this part. I’m seriously going to throw this computer outside right now. I’m doing just allright on this tutorial and i’m just stuck on this step for one hour. If someone can just tell me what to type down for this part, that would be much appreciated.

Thank you in advance.

3 Likes

Double check the hint on this one. The previous poster appears to be in the movies directory at /home/ccuser/workspace/movies/ (the contents of ls match the movies directory in the image on the RHS). You’d want to be in the /home/ccuser/workspace/movies/drama directory, try pwd to double-check where you’re at and cd to move into it.

The cp command given in the hint uses relative paths which would only work if you were in exactly the right directory.

1 Like

Finally got it, thanks so much!

2 Likes

Agreed! I can’t stand that either.

Why does this come?

It says file not found. But when I use pwd, it shows that I am on movies. If movies cannot be found on cd then how does pwd say I am on movies?

You are right…wasted a lot of time in this. I now understand what they wanted me to do.

Here is where I went wrong with this exercise:

I put cp biopic/cleopatra.txt/historical

When I should’ve put: cp biopic/cleopatra.txt historical

The difference being: I placed a forward slash (/) in-front of the historical directory.

I having a problem with step 5 as well.
n a single command, make a copy of cleopatra.txt to go into the historical/ directory.

Hello,

  1. Firstly it’s important to know which working directory you’re in. To check this, use the pwd command to see where you are in the file structure.

  2. Once you know where you are, navigate to the Biopic folder

  3. Next, type this command in: cp biopic/cleopatra.txt historical - This will copy the cleopatra.txt file to the historical folder.

  4. Once done, navigate to the historical folder from the biopic folder using this command: cd …/historical and finally check if the file was successfully copied to this folder by using the ls command

I figured out how to get past step 5 in “cp part 1.” what you have to do is type in “cd /home/ccuser/workspace/movies/drama/historical” this will put you in the historical directory. Next, you type “touch cleopatra.txt” to add cleopatra.txt to historical. You’re Welcome

2 Likes