Codecademy Logo

Viewing and Changing the File System

Print Cheatsheet

Command Options

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.

ls List Command Options

The shell command ls is used to list the contents in a directory. It can be combined with the following command options:

  • -a: lists all contents, including hidden files and directories.
  • -l: lists all contents, in long format.
  • -t: lists all contents, by the time they were last modified.
$ ls -a $ ls -l $ ls -t

cp Copy

The shell command cp is used to copy files or directories.

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

$ cp file1 file1_copy $ cp file1 file2 destination_folder

mv Move

The shell command mv is used to move a file into a directory. Use mv with the source file as the first argument and the destination directory as the second argument.

$ mv index.html website/

rm Remove

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

$ rm -r bad_selfies

Related Courses


Learn the Command Line

Beginner friendly

4 Lessons