LESSON 5 of 5//File Operations
Removing with rm and rmdir
The rm command removes files permanently — there is no trash can. The rmdir command removes empty directories. Use these commands with care.
!
No undo!
Unlike dragging to the Trash, rm deletes files permanently. There is no recovery. Always double-check your command before pressing Enter, especially with -rf flags.
Removing files and directorieszsh // interactive
➜~rm temp-file.txt
# Remove with confirmation prompt
➜~rm -i important-file.txt
remove important-file.txt? y
# Remove directory and all contents
➜~rm -rf node_modules
# Remove empty directory
➜~rmdir empty-folder
Safe practice
Before running rm -rf, run ls on the same path first to verify you're targeting the right files. Example: ls node_modules then rm -rf node_modules.
PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: