Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

>_
Terminal & Command Line
0/10 completed
Beginner
What is the terminal?Navigating foldersWorking with files and foldersViewing files
Intermediate
Wildcards and finding filesPipes and redirectionText processing: grep, sort, cut and friends
Advanced
Environment variables and PATHPermissions and processes
Pro
Shell productivity: aliases, scripts and dotfiles
Tracks / Terminal & Command Line / Beginner

Working with files and folders

Now let's create, copy, move, rename and delete. These are the everyday file operations you'll use constantly.

Creating folders and files

Linux terminal (simulator) · editable
Command Does
mkdir name Make a directory
mkdir -p a/b/c Make nested folders, including any missing parents
touch file Create an empty file (or update its timestamp)
echo "text" > file Create a file with content (more on > in the Pipes lesson)

Copying: cp

Linux terminal (simulator) · editable
  • cp source destination copies a file.
  • cp file folder/ copies it into a folder, keeping the name.
  • cp -r copies a folder and everything inside it (recursively).

Moving and renaming: mv

There's no separate "rename" command. Renaming is moving to a new name:

Linux terminal (simulator) · editable
  • mv old new renames.
  • mv file folder/ moves it into a folder.
  • mv a.txt b.txt docs/ moves several files at once.

Deleting: rm and rmdir

Linux terminal (simulator) · editable
Command Deletes
rm file A file
rm file1 file2 Several files
rmdir folder An empty folder
rm -r folder A folder and everything inside it
rm -rf folder The same, with no questions or errors (force)

⚠️ There is no recycle bin in the terminal. rm deletes permanently. Double-check the path before running rm -r, and never run commands like rm -rf / or rm -rf ~. (The simulator will stop you, but a real computer won't.) Use rm -i to be asked before each deletion.

Overwriting: a silent danger

cp and mv overwrite existing files without asking:

Linux terminal (simulator) · editable

Use cp -i and mv -i (interactive) to be prompted first, or -n to never overwrite.

Practice: organise your Downloads

The ~/Downloads folder is a mess. Organise it:

  1. Create the folders images and documents inside Downloads.
  2. Move the .jpg and .png files into images.
  3. Move report.pdf into documents.
  4. Delete installer.dmg.
  5. Show the result with tree Downloads.
Linux terminal (simulator) · editable
✎ Check your understanding

1.How do you rename old.txt to new.txt?

2.Which command deletes a folder that still has files in it?

← Navigating folders