CLI GUIDE

mkdir

Make Directory

What does it do?

Creates a new directory (folder). This is how you make folders in the terminal without using a file explorer.

Example:

$ mkdir new-project # Creates a folder called "new-project"
$ mkdir -p projects/web/portfolio # Creates multiple directories at once (-p creates parent directories)

When to use it:

  • When starting a new project
  • To organize files in structured folders
  • Create folder structures for web projects (assets, css, js, etc.)

Common options:

  • mkdir -p - Creates parent directories if they don't exist
  • mkdir -v - Verbose mode (shows what's happening)

touch

Create Empty File

What does it do?

Creates a new empty file. Fast way to create files without opening an editor. On Windows you can use echo. > filename.txt instead.

Example:

$ touch index.html # Creates an empty HTML file
$ touch style.css script.js README.md # Creates multiple files at once

When to use it:

  • Quickly create placeholder files
  • Set up file structure for a new project
  • Update timestamp on existing files

cp

Copy

What does it do?

Copies files or folders to a new location. The original remains intact.

Example:

$ cp file.txt backup.txt # Copies file.txt to backup.txt
$ cp file.txt /path/to/another/folder/ # Copies the file to another folder
$ cp -r folder/ backup-folder/ # Copies entire folder with all contents (-r = recursive)

When to use it:

  • Create backups of important files
  • Duplicate projects or configuration files
  • Copy files between folders

Common options:

  • cp -r - Copy folders recursively (with all contents)
  • cp -v - Verbose (show what's being copied)
  • cp -i - Interactive (ask before overwriting)

mv

Move / Rename

What does it do?

Moves files to a new location OR renames them. The original disappears (it's moved, not copied).

Example:

$ mv oldname.txt newname.txt # Renames the file
$ mv file.txt ../another-folder/ # Moves the file to another folder
$ mv *.txt documents/ # Moves all .txt files to the documents folder

When to use it:

  • Rename files or folders
  • Reorganize file structure
  • Move files to the correct location

Common options:

  • mv -i - Interactive (ask before overwriting)
  • mv -v - Verbose (show what's happening)
  • mv -n - No clobber (don't overwrite existing files)

rm

Remove

⚠️ What does it do?

Deletes files or folders PERMANENTLY. There is no recycle bin - when it's gone, it's gone! Be extra careful with this command.

Example:

$ rm file.txt # Deletes the file permanently
$ rm -i file.txt # Asks for confirmation first (-i is safer)
$ rm -r folder/ # Deletes entire folder with all contents (-r = recursive)
$ rm -rf / # ❌ NEVER DO THIS! Deletes your ENTIRE system

When to use it:

  • Delete files you no longer need
  • Clean up old projects
  • Remove temporary files

Common options:

  • rm -i - Interactive (ask before deleting - RECOMMENDED)
  • rm -r - Recursive (delete folders and contents)
  • rm -f - Force (forces deletion without asking - DANGEROUS)
  • rm -rf - Combination (EXTREMELY DANGEROUS)
💡 Pro-tip: Always use ls first to see what's in the folder. Use rm -i to get confirmation. ALWAYS double-check before pressing Enter!

cat

Concatenate / Display File

What does it do?

Displays the contents of a file directly in the terminal. Perfect for quickly checking what's in a file.

Example:

$ cat README.md # Displays the contents of README.md
$ cat file1.txt file2.txt > combined.txt # Combines two files into one new file

When to use it:

  • Quickly view the contents of small files
  • Combine multiple files
  • Debug configuration files

Next Steps

Now that you can manage files, learn Git for version control

Go to Git Commands →