What is it?
Basic file operations — create, copy, move, delete — use a handful of commands.
Why does it matter?
File operations are the most common terminal tasks. Knowing the options prevents data loss.
Learn touch, cp, mv, rm, mkdir — file and directory manipulation.
Real-World Use Cases
- 💡 Real-world use - Practical application.
- ⚡ Performance - Critical skill.
- 🏢 Professional - Industry standard.
- 📚 Learning - Career essential.
Core Concept
Key commands:
touch→ create empty file / update timestampcp→ copy files/directoriesmv→ move or renamerm→ delete files/directories
Example
# Create files & directories
touch file1.txt
mkdir project
# Copy file
cp file1.txt project/
# Copy directory
cp -r project backup_project
# Move / rename
mv file1.txt file2.txt
mv file2.txt project/
# Delete file
rm project/file2.txt
# Delete directory
rm -r backup_project
Best Practice
- Use
-ifor safety (interactive) - Avoid accidental deletes
- Prefer verbose mode for clarity
- Use absolute paths in scripts
- Backup before bulk operations
- Use
rsyncinstead ofcpfor large data
Q: How do I safely delete files in Linux?
rm removes permanently with no trash bin. Use rm -i for interactive confirmation. Check with ls before rm -rf.
Comments (0)
No comments yet. Be the first!
Leave a Comment