TracksPractical Coding FoundationsUsing the TerminalCreating and Managing Files(4 of 6)

Creating and Managing Files

The terminal excels at file management. Operations that require multiple clicks in a graphical interface become single commands. This speed advantage multiplies when you're working with many files at once.

Creating Folders

The mkdir command (make directory) creates new folders:

Create nested folders in one command with the -p option:

mkdir -p projects/web/css

Creating Files

The touch command creates empty files (or updates timestamps on existing ones):

In PowerShell, use New-Item:

New-Item notes.txt -ItemType File

Or the shorter alias: ni notes.txt

Copying Files

The copy command duplicates files or folders:

cp original.txt backup.txt           # Copy file
cp -r my-folder my-folder-backup     # Copy folder (-r for recursive)
Copy-Item original.txt backup.txt
Copy-Item my-folder my-folder-backup -Recurse

Moving and Renaming

Moving and renaming use the same command — because renaming is just "moving" a file to a new name:

mv old-name.txt new-name.txt    # Rename
mv file.txt Documents/          # Move to folder
mv file.txt Documents/new.txt   # Move and rename
Move-Item old-name.txt new-name.txt
Move-Item file.txt Documents/

Deleting Files (Be Careful!)

Warning: Terminal deletion is permanent. There's no Recycle Bin or Trash — files are gone immediately.

rm unwanted.txt              # Delete file
rm -r unwanted-folder        # Delete folder and contents
Remove-Item unwanted.txt
Remove-Item unwanted-folder -Recurse

Before deleting, double-check your command. A typo like rm -r / instead of rm -r ./folder could be catastrophic. Many developers add the -i flag (interactive) to confirm each deletion: rm -i file.txt.

Why This Matters

These commands become second nature quickly. When you need to reorganize a project, rename dozens of files, or clean up old work, the terminal handles it in seconds. Combined with patterns like *.txt (all text files), you gain powerful batch operations that GUIs simply can't match.

See More

You need to be signed in to leave a comment and join the discussion