Files and Directories
📂 Basic File Operations
File Creation and Viewing
# Create files
touch file.txt # Create empty file
echo "content" > file.txt # Create with content
cat > file.txt # Create and input content
nano file.txt # Create/edit with text editor
# View files
cat file.txt # Display file content
less file.txt # Page through file
head -n 10 file.txt # Show first 10 lines
tail -n 10 file.txt # Show last 10 lines
tail -f file.txt # Follow file updatesFile Manipulation
# Copy files
cp source.txt dest.txt # Copy file
cp -r source_dir dest_dir # Copy directory
cp -p source.txt dest.txt # Preserve attributes
cp -i source.txt dest.txt # Interactive mode
# Move/rename files
mv old.txt new.txt # Rename file
mv file.txt /path/to/dir/ # Move file
mv -i source dest # Interactive mode
mv -u source dest # Update only if newer
# Delete files
rm file.txt # Remove file
rm -r directory # Remove directory
rm -f file.txt # Force remove
rm -i file.txt # Interactive mode📁 Directory Operations
Directory Management
Directory Information
🔍 File Search and Location
Find Command
Locate and Which
📊 File Attributes
File Information
File Compression
🔒 File Permissions and Ownership
Permission Management
Special Permissions
🔗 Links and References
Link Creation
💡 Best Practices
🔧 Troubleshooting
Common Issues
File Recovery
📝 Advanced Operations
File Monitoring
Batch Operations
Last updated