File Operations¶
Commands for creating, copying, moving, and deleting files and directories.
Create and Copy¶
Command |
Description |
Examples |
|---|---|---|
|
Create directory |
|
|
Copy file or directory |
|
Move and Rename¶
Command |
Description |
Examples |
|---|---|---|
|
Move or rename |
|
Delete¶
Command |
Description |
Examples |
|---|---|---|
|
Remove file/directory |
|
|
Remove empty directory |
|
Warning
Commands that write to files (cp, mv, rm) will overwrite existing files without warning. There is no undo button—be deliberate with these commands.
Common Patterns¶
ls -la # List all (including hidden)
cp source dest # Copy
mv old new # Move/rename
rm file # Delete (be careful!)
rm -r dir # Delete directory
mkdir -p a/b/c # Create nested directories
Tips¶
Always double-check paths before running
rmUse
rm -ifor interactive confirmation before deletingcp -iprompts before overwriting filesTest commands with
lsfirst to verify paths