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/



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 now back in the top-most movies directory.

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


Using a single cp command, copy all the contents of frida.txt to lincoln.txt.


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.


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.


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.


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.
Already have an account?