Log in from a computer to take this course

You'll need to log in from a computer to start Learn the Command Line. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

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.

For this exercise, we need to start in the drama/biopic directory. Use pwd to check where you are. If you aren’t in the drama/biopic directory, you can use the command cd /home/ccuser/workspace/movies/drama/biopic to quickly get there. As you move to the correct file path, ignore any errors that pop up.

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

2.

Using a single cp command, 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 its 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, then 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.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?