📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Linux Command Line Files and Directories

Files and Directories

5 min read Quiz at the end
mkdir creates directories and touch creates empty files. cp copies files, mv moves or renames them, and rm deletes them. Use rm -rf to delete directories — be very careful since there is no undo or recycle bin.

Creating and Managing Files

mkdir photos           # create directory
mkdir -p a/b/c         # create nested dirs
touch file.txt         # create empty file
rm file.txt            # delete file
rm -rf folder/         # delete folder (careful!)
cp file.txt backup.txt # copy file
mv file.txt docs/      # move file
mv old.txt new.txt     # rename file
Topic Quiz · 5 questions

Test your understanding before moving on

1. Which command creates a directory?
💡 mkdir (make directory) creates a new directory.
2. Which creates nested directories at once?
💡 mkdir -p creates parent directories as needed: mkdir -p a/b/c.
3. touch file.txt does what?
💡 touch creates an empty file if it doesn't exist, or updates its timestamp.
4. rm -rf folder does what?
💡 rm -rf recursively and forcefully deletes — no trash, no undo!
5. mv old.txt new.txt does what?
💡 mv moves or renames files: mv source destination.