DocuHub CLI Command Reference
DocuHub CLI Command Reference
Section titled “DocuHub CLI Command Reference”Essential Commands for Managing docs.isutech.co.za
🎯 Quick Reference
Section titled “🎯 Quick Reference”Server: 46.224.40.5 (Hetzner)
Domain: docs.isutech.co.za
Repo Location: /var/www/docs/repo
Virtual Env: /var/www/docs/venv
Update Script: /var/www/docs/scripts/update-docs.sh
Logs: /var/log/docs-update.log
🔐 SSH Access
Section titled “🔐 SSH Access”Connect to Server
Section titled “Connect to Server”# SSH as rootssh root@46.224.40.5
# SSH as specific userssh username@46.224.40.5
# SSH with key filessh -i ~/.ssh/your_key root@46.224.40.5Exit SSH Session
Section titled “Exit SSH Session”# Exit current sessionexit
# Or press Ctrl+D📦 Daily Operations
Section titled “📦 Daily Operations”Update DocuHub (Most Common)
Section titled “Update DocuHub (Most Common)”Automated Update (Recommended):
# Run the automated update scriptsudo /var/www/docs/scripts/update-docs.sh
# View what happenedtail -50 /var/log/docs-update.logManual Update (If script fails):
# 1. Navigate to repocd /var/www/docs/repo
# 2. Activate virtual environmentsource /var/www/docs/venv/bin/activate
# 3. Pull latest changesgit pull origin main
# 4. Rebuild documentationmkdocs build --clean
# 5. Reload nginx (if needed)sudo systemctl reload nginxQuick Status Check
Section titled “Quick Status Check”# Check current commitcd /var/www/docs/repo && git log --oneline -1
# Check if site is builtls /var/www/docs/repo/site/ | wc -l # Should show many files
# Check nginx statussudo systemctl status nginx
# Check last updatetail -10 /var/log/docs-update.log📚 Git Operations
Section titled “📚 Git Operations”Check Repository Status
Section titled “Check Repository Status”# Navigate to repocd /var/www/docs/repo
# Check current statusgit status
# View recent commitsgit log --oneline -10
# Check current branchgit branch
# Show remote URLgit remote -vPull Latest Changes
Section titled “Pull Latest Changes”# Standard pullgit pull origin main
# Pull and reset to remote (if conflicts)git fetch --allgit reset --hard origin/main
# Pull specific branchgit pull origin branch-nameCheck What Changed
Section titled “Check What Changed”# Show uncommitted changesgit diff
# Show changes in specific filegit diff path/to/file.md
# Show changes between commitsgit diff commit1 commit2
# Show files changed in last commitgit diff-tree --no-commit-id --name-only -r HEADUndo Changes (Caution!)
Section titled “Undo Changes (Caution!)”# Discard local changes (DESTRUCTIVE!)git reset --hard HEAD
# Discard changes to specific filegit checkout -- path/to/file.md
# Undo last commit (keep changes)git reset --soft HEAD~1
# Undo last commit (discard changes)git reset --hard HEAD~1🏗️ MkDocs Operations
Section titled “🏗️ MkDocs Operations”Build Documentation
Section titled “Build Documentation”# Activate virtual environment firstsource /var/www/docs/venv/bin/activate
# Navigate to repocd /var/www/docs/repo
# Standard buildmkdocs build
# Clean build (removes old files first)mkdocs build --clean
# Build with verbose outputmkdocs build --verbose
# Build to custom directorymkdocs build --site-dir /path/to/outputServe Locally (Testing)
Section titled “Serve Locally (Testing)”# Serve on default port (8000)mkdocs serve
# Serve on specific portmkdocs serve --dev-addr=0.0.0.0:8001
# Serve with auto-reloadmkdocs serve --livereload
# Access: http://46.224.40.5:8000 (if firewall allows)Validate Configuration
Section titled “Validate Configuration”# Check mkdocs.yml for errorsmkdocs build --strict
# Show MkDocs versionmkdocs --version
# Show installed pluginspip list | grep mkdocs🌐 Nginx Operations
Section titled “🌐 Nginx Operations”Nginx Service Management
Section titled “Nginx Service Management”# Check statussudo systemctl status nginx
# Start nginxsudo systemctl start nginx
# Stop nginxsudo systemctl stop nginx
# Restart nginx (brief downtime)sudo systemctl restart nginx
# Reload nginx (no downtime)sudo systemctl reload nginx
# Enable auto-start on bootsudo systemctl enable nginxTest Configuration
Section titled “Test Configuration”# Test nginx config for errorssudo nginx -t
# Test and show full configsudo nginx -T
# If test passes, reloadsudo nginx -t && sudo systemctl reload nginxView Nginx Configuration
Section titled “View Nginx Configuration”# View DocuHub site configsudo cat /etc/nginx/sites-available/docs.isutech.co.za
# View enabled sitesls -la /etc/nginx/sites-enabled/
# View main nginx configsudo cat /etc/nginx/nginx.confEdit Nginx Configuration
Section titled “Edit Nginx Configuration”# Edit site configsudo nano /etc/nginx/sites-available/docs.isutech.co.za
# After editing, always testsudo nginx -t
# If test passes, reloadsudo systemctl reload nginx📊 Logs & Monitoring
Section titled “📊 Logs & Monitoring”View Update Logs
Section titled “View Update Logs”# View last 50 linestail -50 /var/log/docs-update.log
# View last 100 linestail -100 /var/log/docs-update.log
# Follow log in real-timetail -f /var/log/docs-update.log
# View entire logcat /var/log/docs-update.log
# View log with timestampscat /var/log/docs-update.log | grep "Started"
# Clear log (if needed)sudo truncate -s 0 /var/log/docs-update.logView Nginx Logs
Section titled “View Nginx Logs”# Access log (requests)sudo tail -50 /var/log/nginx/docs-access.log
# Error logsudo tail -50 /var/log/nginx/docs-error.log
# Follow access log in real-timesudo tail -f /var/log/nginx/docs-access.log
# Search for 404 errorssudo grep "404" /var/log/nginx/docs-access.log
# Count requests by IPsudo awk '{print $1}' /var/log/nginx/docs-access.log | sort | uniq -c | sort -nr | head -10System Logs
Section titled “System Logs”# View system journal for nginxsudo journalctl -u nginx -n 50
# Follow nginx logssudo journalctl -u nginx -f
# View logs for todaysudo journalctl -u nginx --since today
# View logs with errorssudo journalctl -u nginx -p err🔧 Troubleshooting Commands
Section titled “🔧 Troubleshooting Commands”Site Not Updating
Section titled “Site Not Updating”# 1. Check current git commitcd /var/www/docs/repogit log --oneline -1
# 2. Force pull latestgit fetch --allgit reset --hard origin/main
# 3. Rebuildsource /var/www/docs/venv/bin/activatemkdocs build --clean
# 4. Check built filesls -la site/
# 5. Reload nginxsudo systemctl reload nginx
# 6. Clear browser cache (Ctrl+Shift+R)Permission Issues
Section titled “Permission Issues”# Fix ownership (if docs user exists)sudo chown -R docs:docs /var/www/docs/
# Or fix to current usersudo chown -R $USER:$USER /var/www/docs/
# Fix permissionschmod -R 755 /var/www/docs/repo/site/chmod +x /var/www/docs/scripts/update-docs.sh
# Check current permissionsls -la /var/www/docs/Build Failures
Section titled “Build Failures”# Check MkDocs is installedsource /var/www/docs/venv/bin/activatemkdocs --version
# Reinstall MkDocs Materialpip install --upgrade mkdocs-material
# Check for syntax errors in mkdocs.ymlcd /var/www/docs/repomkdocs build --strict --verbose
# Check Python versionpython --version # Should be 3.7+Nginx Not Serving Site
Section titled “Nginx Not Serving Site”# Check nginx is runningsudo systemctl status nginx
# Test configurationsudo nginx -t
# Check which port nginx is listening onsudo netstat -tulpn | grep nginx
# Check firewallsudo ufw status
# Test from server itselfcurl http://localhost/
# Test with specific domaincurl -H "Host: docs.isutech.co.za" http://localhost/SSL/HTTPS Issues
Section titled “SSL/HTTPS Issues”# Check SSL certificatessudo certbot certificates
# Test auto-renewalsudo certbot renew --dry-run
# Force renew certificatesudo certbot renew --force-renewal
# Check SSL certificate expiryecho | openssl s_client -servername docs.isutech.co.za -connect docs.isutech.co.za:443 2>/dev/null | openssl x509 -noout -dates🗂️ File Operations
Section titled “🗂️ File Operations”Navigate Directory Structure
Section titled “Navigate Directory Structure”# Go to repo rootcd /var/www/docs/repo
# Go to docs foldercd /var/www/docs/repo/docs
# Go to prospectscd /var/www/docs/repo/docs/prospects
# Go to built sitecd /var/www/docs/repo/site
# List files with detailsls -lah
# Count files in directoryfind . -type f | wc -l
# Find specific filesfind . -name "*.md" -type fView File Contents
Section titled “View File Contents”# View entire filecat filename.md
# View first 20 lineshead -20 filename.md
# View last 20 linestail -20 filename.md
# Search within filegrep "search term" filename.md
# Search recursively in all markdown filesgrep -r "search term" docs/*.md
# Count lines in filewc -l filename.mdCheck Disk Space
Section titled “Check Disk Space”# Check overall disk usagedf -h
# Check repo sizedu -sh /var/www/docs/repo
# Check site build sizedu -sh /var/www/docs/repo/site
# Find large filesdu -ah /var/www/docs/repo | sort -rh | head -20
# Check log file sizesls -lh /var/log/docs-update.logls -lh /var/log/nginx/docs-*.log🔄 Automation & Cron
Section titled “🔄 Automation & Cron”View Scheduled Jobs
Section titled “View Scheduled Jobs”# View cron jobs for current usercrontab -l
# View cron jobs for rootsudo crontab -l
# View system cron jobscat /etc/crontabls -la /etc/cron.d/Edit Cron Jobs
Section titled “Edit Cron Jobs”# Edit current user's crontabcrontab -e
# Edit root's crontabsudo crontab -e
# Example: Run update every 10 minutes*/10 * * * * /var/www/docs/scripts/update-docs.sh
# Example: Run daily at 2am0 2 * * * /var/www/docs/scripts/update-docs.shCron Log Monitoring
Section titled “Cron Log Monitoring”# View cron execution logsudo grep CRON /var/log/syslog | tail -50
# Check if update script ransudo grep "update-docs.sh" /var/log/syslog | tail -20🔒 Security & Backups
Section titled “🔒 Security & Backups”Create Backup
Section titled “Create Backup”# Backup entire docs directorysudo tar -czf /backup/docs-backup-$(date +%Y%m%d).tar.gz /var/www/docs/
# Backup just the reposudo tar -czf /backup/docs-repo-$(date +%Y%m%d).tar.gz /var/www/docs/repo/
# Backup configuration filessudo tar -czf /backup/nginx-config-$(date +%Y%m%d).tar.gz /etc/nginx/sites-available/docs.isutech.co.za
# List backupsls -lh /backup/docs-*Restore from Backup
Section titled “Restore from Backup”# Extract backupsudo tar -xzf /backup/docs-backup-20250102.tar.gz -C /
# Verify contentstar -tzf /backup/docs-backup-20250102.tar.gz | head -20Check Security
Section titled “Check Security”# Check for unauthorized changescd /var/www/docs/repogit status
# Check file permissionsls -la /var/www/docs/
# Check nginx security headerscurl -I https://docs.isutech.co.za | grep -E "X-Frame|X-Content|X-XSS|Strict"
# Check SSL gradeecho | openssl s_client -connect docs.isutech.co.za:443 2>/dev/null | openssl x509 -noout -text | grep "Signature Algorithm"🧹 Maintenance Commands
Section titled “🧹 Maintenance Commands”Clean Up Old Builds
Section titled “Clean Up Old Builds”# Remove old site buildsrm -rf /var/www/docs/repo/site/*
# Clean git repositorycd /var/www/docs/repogit clean -fd # Remove untracked files (careful!)git gc # Garbage collect
# Remove old log entries (keep last 1000 lines)sudo tail -1000 /var/log/docs-update.log > /tmp/docs-update.logsudo mv /tmp/docs-update.log /var/log/docs-update.logUpdate Dependencies
Section titled “Update Dependencies”# Activate virtual environmentsource /var/www/docs/venv/bin/activate
# Update pippip install --upgrade pip
# Update MkDocs Materialpip install --upgrade mkdocs-material
# Show installed packagespip list
# Show outdated packagespip list --outdatedSystem Updates
Section titled “System Updates”# Update package listssudo apt update
# Upgrade packagessudo apt upgrade -y
# Reboot if needed (check first)[ -f /var/run/reboot-required ] && echo "Reboot required" || echo "No reboot needed"
# Reboot serversudo reboot📱 Remote Operations
Section titled “📱 Remote Operations”Run Commands from Local Machine
Section titled “Run Commands from Local Machine”# Execute single commandssh root@46.224.40.5 "cd /var/www/docs/repo && git pull"
# Run update scriptssh root@46.224.40.5 "/var/www/docs/scripts/update-docs.sh"
# Check logsssh root@46.224.40.5 "tail -20 /var/log/docs-update.log"
# Get server statusssh root@46.224.40.5 "systemctl status nginx"Copy Files to/from Server
Section titled “Copy Files to/from Server”# Copy file TO serverscp local-file.md root@46.224.40.5:/var/www/docs/repo/docs/
# Copy file FROM serverscp root@46.224.40.5:/var/log/docs-update.log ~/Downloads/
# Copy entire directory TO serverscp -r local-folder/ root@46.224.40.5:/var/www/docs/
# Copy entire directory FROM serverscp -r root@46.224.40.5:/var/www/docs/backup/ ~/backups/Sync Files with rsync (Recommended)
Section titled “Sync Files with rsync (Recommended)”rsync is the preferred tool for file transfers — it’s faster than scp for repeated syncs because it only transfers changed files. It also preserves permissions, timestamps, and supports compression.
Common Flags:
| Flag | Purpose |
|---|---|
-a | Archive mode (preserves permissions, timestamps, symlinks) |
-v | Verbose output (shows files being transferred) |
-z | Compress data during transfer |
-P | Show progress bar + allow resume of partial transfers |
--delete | Remove files at destination that no longer exist at source |
--dry-run | Preview what will happen without making changes |
-e ssh | Use SSH as transport (default on modern systems) |
Sync Files FROM Server to Local Machine:
# Sync a single file from serverrsync -avz root@46.224.40.5:/var/www/docs/repo/docs/operations/docshub-cli-reference.md ~/Desktop/
# Sync an entire directory from serverrsync -avz root@46.224.40.5:/var/www/docs/repo/docs/ ~/Desktop/docs-backup/
# Sync reports or generated files from a projectrsync -avz root@46.224.40.5:/var/www/tumi/docs/data/ ~/Desktop/TUMI/Reports/
# Sync with progress bar (useful for large transfers)rsync -avzP root@46.224.40.5:/var/www/docs/repo/docs/ ~/Desktop/docs-backup/
# Sync server logs to local for analysisrsync -avz root@46.224.40.5:/var/log/docs-update.log ~/Downloads/logs/Sync Files TO Server from Local Machine:
# Push a single file to serverrsync -avz ~/Documents/new-page.md root@46.224.40.5:/var/www/docs/repo/docs/
# Push an entire directory to serverrsync -avz ~/Projects/docs-content/ root@46.224.40.5:/var/www/docs/repo/docs/
# Push and delete files on server that were removed locally (mirror sync)rsync -avz --delete ~/Projects/docs-content/ root@46.224.40.5:/var/www/docs/repo/docs/Preview Before Syncing (Dry Run):
# See what WOULD be transferred without actually doing itrsync -avz --dry-run root@46.224.40.5:/var/www/docs/repo/docs/ ~/Desktop/docs-backup/
# Preview a mirror sync (shows files that would be deleted)rsync -avz --delete --dry-run ~/Projects/docs-content/ root@46.224.40.5:/var/www/docs/repo/docs/Advanced rsync Patterns:
# Exclude specific files or directoriesrsync -avz --exclude='*.log' --exclude='.git/' root@46.224.40.5:/var/www/docs/repo/ ~/backups/
# Only sync markdown filesrsync -avz --include='*/' --include='*.md' --exclude='*' root@46.224.40.5:/var/www/docs/repo/docs/ ~/Desktop/md-only/
# Sync with bandwidth limit (500 KB/s) — useful on slow connectionsrsync -avz --bwlimit=500 root@46.224.40.5:/var/www/docs/repo/docs/ ~/Desktop/docs-backup/
# Sync using a specific SSH keyrsync -avz -e "ssh -i ~/.ssh/your_key" root@46.224.40.5:/var/www/docs/repo/docs/ ~/Desktop/docs-backup/
# Sync between two directories on the same machinersync -avz /var/www/docs/repo/docs/ /backup/docs-snapshot/rsync vs scp — When to Use Which:
| Scenario | Use |
|---|---|
| Quick one-off single file copy | scp |
| Repeated syncs of the same directory | rsync |
| Large directories with few changes | rsync |
| Need to preserve exact permissions | rsync -a |
| Mirror a folder (delete extras at destination) | rsync --delete |
| Resume an interrupted transfer | rsync -P |
🚀 Advanced Operations
Section titled “🚀 Advanced Operations”Search Across All Documentation
Section titled “Search Across All Documentation”# Search for text in all markdown filescd /var/www/docs/repo/docsgrep -r "search term" . --include="*.md"
# Case-insensitive searchgrep -ri "search term" . --include="*.md"
# Search and show line numbersgrep -rn "search term" . --include="*.md"
# Search with context (2 lines before/after)grep -rn -C 2 "search term" . --include="*.md"Batch Operations
Section titled “Batch Operations”# Count total documentation filesfind /var/www/docs/repo/docs -name "*.md" | wc -l
# Find recently modified files (last 7 days)find /var/www/docs/repo/docs -name "*.md" -mtime -7
# Find large files (>1MB)find /var/www/docs/repo/docs -size +1M
# Replace text in all files (careful!)find . -name "*.md" -exec sed -i 's/old-text/new-text/g' {} \;Performance Monitoring
Section titled “Performance Monitoring”# Check server loaduptime
# Check memory usagefree -h
# Check disk I/Oiostat
# Check CPU usagetop -b -n 1 | head -20
# Check nginx worker processesps aux | grep nginx
# Check connections to nginxnetstat -an | grep :80 | wc -lnetstat -an | grep :443 | wc -l📝 Useful Aliases (Optional Setup)
Section titled “📝 Useful Aliases (Optional Setup)”Add these to ~/.bashrc or ~/.bash_aliases for shortcuts:
# DocuHub aliasesalias docs='cd /var/www/docs/repo'alias docslogs='tail -50 /var/log/docs-update.log'alias docsupdate='sudo /var/www/docs/scripts/update-docs.sh'alias docsstatus='cd /var/www/docs/repo && git log --oneline -1'alias docsbuild='cd /var/www/docs/repo && source /var/www/docs/venv/bin/activate && mkdocs build --clean'
# Nginx aliasesalias nginxtest='sudo nginx -t'alias nginxreload='sudo nginx -t && sudo systemctl reload nginx'alias nginxlogs='sudo tail -50 /var/log/nginx/docs-error.log'alias nginxstatus='sudo systemctl status nginx'
# After adding, reload bashsource ~/.bashrc🆘 Emergency Commands
Section titled “🆘 Emergency Commands”Site is Down
Section titled “Site is Down”# 1. Check if nginx is runningsudo systemctl status nginx
# 2. If not running, start itsudo systemctl start nginx
# 3. Check nginx configsudo nginx -t
# 4. Check error logssudo tail -50 /var/log/nginx/docs-error.log
# 5. Restart nginx (last resort)sudo systemctl restart nginx
# 6. Check DNSnslookup docs.isutech.co.za
# 7. Check firewallsudo ufw statusRollback to Previous Version
Section titled “Rollback to Previous Version”# 1. View recent commitscd /var/www/docs/repogit log --oneline -10
# 2. Rollback to specific commitgit reset --hard COMMIT_HASH
# 3. Rebuildsource /var/www/docs/venv/bin/activatemkdocs build --clean
# 4. Reload nginxsudo systemctl reload nginx
# 5. To undo rollback (go back to latest)git reset --hard origin/mainmkdocs build --cleanSSL Certificate Expired
Section titled “SSL Certificate Expired”# 1. Check certificate statussudo certbot certificates
# 2. Renew certificatesudo certbot renew
# 3. Reload nginxsudo systemctl reload nginx
# 4. Verify SSL is workingcurl -I https://docs.isutech.co.za📖 Command Quick Reference Card
Section titled “📖 Command Quick Reference Card”One-Liners for Common Tasks
Section titled “One-Liners for Common Tasks”# Quick updatessh root@46.224.40.5 "/var/www/docs/scripts/update-docs.sh && tail -10 /var/log/docs-update.log"
# Check if site is upcurl -I https://docs.isutech.co.za | head -1
# View today's updatesssh root@46.224.40.5 "grep '$(date +%Y-%m-%d)' /var/log/docs-update.log"
# Count documentation filesssh root@46.224.40.5 "find /var/www/docs/repo/docs -name '*.md' | wc -l"
# Get current commit hashssh root@46.224.40.5 "cd /var/www/docs/repo && git rev-parse --short HEAD"
# Check nginx syntax and reloadssh root@46.224.40.5 "sudo nginx -t && sudo systemctl reload nginx"📚 Additional Resources
Section titled “📚 Additional Resources”Internal Documentation:
- Phase 2 Deployment Guide - Initial setup
- Hetzner Server Guide - Server management
External References:
✅ Best Practices
Section titled “✅ Best Practices”-
Always test before deploying:
Terminal window mkdocs build --strict # Catches config errorssudo nginx -t # Validates nginx config -
Check logs after operations:
Terminal window tail -20 /var/log/docs-update.logsudo tail -20 /var/log/nginx/docs-error.log -
Use clean builds when updating:
Terminal window mkdocs build --clean # Removes stale files -
Hard refresh browser after updates:
Ctrl+Shift+R(Windows/Linux)Cmd+Shift+R(Mac)
-
Keep backups before major changes:
Terminal window sudo tar -czf /backup/docs-pre-update-$(date +%Y%m%d).tar.gz /var/www/docs/
Last Updated: February 11, 2026 Maintained By: iSu Technologies Operations Team Questions? Contact Operations Lead or check internal wiki