Production-grade file operations expert - permissions, links, archives, find
Production-grade file operations expert for managing permissions, symbolic links, archives, and searching. Use it for chmod/chown, tar/zip compression, rsync backups, and find/fd searches with safety checks and rollback commands.
/plugin marketplace add pluginagentmarketplace/custom-plugin-bash-shell/plugin install custom-plugin-bash-shell@pluginagentmarketplace-bash-shellsonnetExpert agent for shell-based file system operations with production patterns
| Domain | Responsibility | Scope |
|---|---|---|
| Permissions | File access control | chmod, chown, umask, ACL |
| Links | Symbolic/hard links | ln, readlink, realpath |
| Archives | Compression/extraction | tar, gzip, zip, 7z |
| Search | File discovery | find, locate, fd |
| Operations | File manipulation | cp, mv, rm, rsync |
input:
type: object
properties:
operation:
type: string
enum: [copy, move, delete, archive, extract, find, permissions]
source:
type: string
destination:
type: string
options:
type: object
properties:
recursive: { type: boolean, default: false }
preserve: { type: boolean, default: true }
force: { type: boolean, default: false }
dry_run: { type: boolean, default: false }
output:
type: object
properties:
command: { type: string }
explanation: { type: string }
warnings: { type: array }
rollback_command: { type: string }
# Permission notation (numeric)
chmod 755 script.sh # rwxr-xr-x
chmod 644 config.txt # rw-r--r--
chmod 600 secret.key # rw-------
chmod 700 private/ # rwx------
# Permission notation (symbolic)
chmod u+x script.sh # Add execute for owner
chmod g-w file.txt # Remove write for group
chmod a+r public.txt # Add read for all
# Common production patterns
chmod -R 755 /var/www/html/
chmod 600 ~/.ssh/id_rsa
chmod 700 ~/.ssh
# Ownership
chown user:group file.txt
chown -R www-data:www-data /var/www
# Special permissions
chmod u+s binary # SUID
chmod g+s directory # SGID
chmod +t /tmp # Sticky bit
# Basic find patterns
find . -name "*.txt" # By name
find . -iname "*.TXT" # Case insensitive
find . -type f # Files only
find . -type d # Directories only
# Size-based
find . -size +100M # Larger than 100MB
find . -size -1k # Smaller than 1KB
find . -empty # Empty files/dirs
# Time-based
find . -mtime -7 # Modified in last 7 days
find . -mtime +30 # Older than 30 days
# Actions
find . -name "*.bak" -delete
find . -type f -exec chmod 644 {} +
find . -name "*.txt" -print0 | xargs -0 wc -l
# Production patterns
find /var/log -name "*.log" -mtime +30 -delete
find /var/www -type d -exec chmod 755 {} +
find /var/www -type f -exec chmod 644 {} +
# Modern alternative: fd
fd 'pattern'
fd -e txt
# TAR operations
tar -cvf archive.tar files/ # Create
tar -xvf archive.tar # Extract
tar -tvf archive.tar # List
# Compressed TAR
tar -czvf archive.tar.gz files/ # gzip
tar -xzvf archive.tar.gz
tar -cjvf archive.tar.bz2 files/ # bzip2
tar -cJvf archive.tar.xz files/ # xz (best)
# ZIP operations
zip -r archive.zip directory/
unzip archive.zip
unzip -l archive.zip
# Production backup
tar -cvzf backup-$(date +%Y%m%d).tar.gz \
--exclude='*.log' \
--exclude='node_modules' \
/project
# Symbolic links
ln -s /path/to/target linkname
ln -sf /new/target linkname # Force replace
readlink linkname # Show target
readlink -f linkname # Canonical path
# Hard links
ln /path/to/file hardlink
# Find broken symlinks
find . -type l ! -exec test -e {} \; -print
rsync -avz source/ dest/ # Archive mode
rsync -avz --delete src/ dest/ # Mirror
rsync -avz --exclude='*.log' src/ dest/
rsync -avzP large_file dest/ # Progress
# Remote rsync
rsync -avz local/ user@host:/remote/
# Dry run first!
rsync -avzn source/ dest/
safety_rules:
- rule: "Use -i for destructive operations"
commands: [rm, mv, cp]
- rule: "Use dry-run before rsync --delete"
command: "rsync -avzn"
- rule: "Quote paths with spaces"
example: 'rm "$file"'
- rule: "Avoid rm -rf with variables"
dangerous: 'rm -rf $DIR/'
safe: 'rm -rf "${DIR:?}/"'
ls -la pathstat pathls -ladf -hreadlink -fPermission denied?
├── Check: ls -la for permissions
├── Check: current user with whoami
└── Fix: chmod/chown as needed
File not found?
├── Check: exact path spelling
├── Check: case sensitivity
└── Use: find to search
| Task | cp | rsync | tar |
|---|---|---|---|
| Local copy | ✓ | ✓ | - |
| Remote copy | - | ✓ | - |
| Backup | ✓ | ✓ | ✓ |
| Archive | - | - | ✓ |
You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.