Key Concepts

Review core concepts you need to learn to master this subject

Copy Files and Directories

cp file1 duplicate_file1 cp file1 file2 destination_folder

The cp command is used to copy files or directories.

The basic argument structure is cp source destination, where the source is the file or directory to copy to the destination file or directory.

Command Options

cp file1 duplicate_file1 cp file1 file2 destination_folder

Options can be used to modify the behavior of shell commands. Shell command options are commonly represented by a single letter preceded by a -. For example, -l, -a, and -d could all be options that follow a shell command.

mv shell command

cp file1 duplicate_file1 cp file1 file2 destination_folder

Files can be moved using the mv shell command.

Delete files and directories

cp file1 duplicate_file1 cp file1 file2 destination_folder

The rm shell command is used to delete files and directories. The -r flag deletes a directory and all of its files and directories (rm -r).

List contents in a directory

cp file1 duplicate_file1 cp file1 file2 destination_folder

The ls shell command is used to list the contents in a directory.

Manipulation
Lesson 1 of 1
  1. 1
    So far we’ve used the command line to navigate the filesystem. We can do more with the command line to view directories and files. We can also use the command line to copy, move, and remove files …
  2. 2
    $ ls -a . .. .preferences action drama comedy genres.txt 1. The ls command lists all files and directories in the working directory. 2. The -a modifies the behavior of the ls command to al…
  3. 3
    $ ls -l drwxr-xr-x 5 cc eng 4096 Jun 24 16:51 action drwxr-xr-x 4 cc eng 4096 Jun 24 16:51 comedy drwxr-xr-x 6 cc eng 4096 Jun 24 16:51 drama -rw-r–r– 1 cc eng 0 Jun 24 16:51 …
  4. 4
    $ ls -alt drwxr-xr-x 4 cc eng 4096 Jun 29 12:22 . -rw-r–r– 1 cc eng 0 Jun 29 12:22 .gitignore drwxr-xr-x 5 cc eng 4096 Jun 30 14:20 .. drwxr-xr-x 2 cc eng 4096 Jun 29 12:22 satire drwxr-xr-x …
  5. 5
    cp frida.txt lincoln.txt The cp command copies files or directories. Here, we copy the contents of frida.txt into lincoln.txt.
  6. 6
    cp biopic/cleopatra.txt historical/ To copy a file into a directory, use cp with the source file as the first argument and the destination directory as the second argument. Here, we copy the fil…
  7. 7
    cp satire/ In addition to using filenames as arguments, we can use special characters like to select groups of files. These special characters are called wildcards. The * selects all file…
  8. 8
    The mv command moves files. It’s similar to cp in its usage. mv superman.txt superhero/ To move a file into a directory, use mv with the source file as the first argument and the destination di…
  9. 9
    rm waterboy.txt The rm command deletes files and directories. Here we remove the file waterboy.txt from the filesystem. rm -r comedy The -r is an option that modifies the behavior of th…
  10. 10
    Congratulations! You learned how to use the command line to view and manipulate the filesystem. What can we generalize so far? Options modify the behavior of commands: ls -a lists all conten…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo