Working with Files
Beginner
Overview
touch creates an empty file (or updates a timestamp). mkdir makes directories — add -p to create nested paths in one go.
cp copies, mv moves or renames, and rm deletes. Directories need the recursive flag -r for cp and rm.
rm is permanent — there is no recycle bin. Be especially careful with rm -rf, and never run it on / or with unverified variables.
Cheatsheet
touch file.txtCreate an empty filemkdir -p a/b/cCreate nested directoriescp -r src dstCopy a directory recursivelymv old.txt new.txtRename or move a filerm -r buildDelete a directory and its contentscat file.txtPrint a file's contentsTry it
A safe, simulated terminal. Run the suggested commands to see typical output.
simulated terminal
Type a command and press Enter, or click a suggestion below to run it.
Quick quiz
1. Which flag lets mkdir create parent directories as needed?
2. How do you delete a directory and everything inside it?