Learn
Manipulation
cp Part I

Let’s move on to copying, moving, and removing files and directories from the command line. The cp command copies files or directories. Below, we copy the contents of a source file into a destination file:

cp source.txt destination.txt

We could also copy a file to a destination directory:

cp source.txt destination/

Instructions

1.

Let’s try this out in our environment.

In a single command, navigate to the drama/biopic/ directory. Keep in mind that we’re now back in the movies directory.

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

2.

Copy all the contents of frida.txt to lincoln.txt.

3.

Use cat on lincoln.txt to confirm that the information about Frida Kahlo has been copied into the lincoln.txt file.

To clear the terminal of the text after it’s output, use the clear command.

4.

Great job! You just copied the contents of a file using the command line!

Now, let’s navigate one level up to the drama/ directory.

and list all files and directories in the working directory.

5.

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.

6.

List all files and directories in the historical/ directory without changing the working directory. You should see a new copy of cleopatra.txt in this directory.

Folder Icon

Sign up to start coding

Already have an account?