Skip to content

DocuHub CLI Command Reference

Essential Commands for Managing docs.isutech.co.za


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


Terminal window
# SSH as root
ssh root@46.224.40.5
# SSH as specific user
ssh username@46.224.40.5
# SSH with key file
ssh -i ~/.ssh/your_key root@46.224.40.5
Terminal window
# Exit current session
exit
# Or press Ctrl+D

Automated Update (Recommended):

Terminal window
# Run the automated update script
sudo /var/www/docs/scripts/update-docs.sh
# View what happened
tail -50 /var/log/docs-update.log

Manual Update (If script fails):

Terminal window
# 1. Navigate to repo
cd /var/www/docs/repo
# 2. Activate virtual environment
source /var/www/docs/venv/bin/activate
# 3. Pull latest changes
git pull origin main
# 4. Rebuild documentation
mkdocs build --clean
# 5. Reload nginx (if needed)
sudo systemctl reload nginx
Terminal window
# Check current commit
cd /var/www/docs/repo && git log --oneline -1
# Check if site is built
ls /var/www/docs/repo/site/ | wc -l # Should show many files
# Check nginx status
sudo systemctl status nginx
# Check last update
tail -10 /var/log/docs-update.log

Terminal window
# Navigate to repo
cd /var/www/docs/repo
# Check current status
git status
# View recent commits
git log --oneline -10
# Check current branch
git branch
# Show remote URL
git remote -v
Terminal window
# Standard pull
git pull origin main
# Pull and reset to remote (if conflicts)
git fetch --all
git reset --hard origin/main
# Pull specific branch
git pull origin branch-name
Terminal window
# Show uncommitted changes
git diff
# Show changes in specific file
git diff path/to/file.md
# Show changes between commits
git diff commit1 commit2
# Show files changed in last commit
git diff-tree --no-commit-id --name-only -r HEAD
Terminal window
# Discard local changes (DESTRUCTIVE!)
git reset --hard HEAD
# Discard changes to specific file
git 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

Terminal window
# Activate virtual environment first
source /var/www/docs/venv/bin/activate
# Navigate to repo
cd /var/www/docs/repo
# Standard build
mkdocs build
# Clean build (removes old files first)
mkdocs build --clean
# Build with verbose output
mkdocs build --verbose
# Build to custom directory
mkdocs build --site-dir /path/to/output
Terminal window
# Serve on default port (8000)
mkdocs serve
# Serve on specific port
mkdocs serve --dev-addr=0.0.0.0:8001
# Serve with auto-reload
mkdocs serve --livereload
# Access: http://46.224.40.5:8000 (if firewall allows)
Terminal window
# Check mkdocs.yml for errors
mkdocs build --strict
# Show MkDocs version
mkdocs --version
# Show installed plugins
pip list | grep mkdocs

Terminal window
# Check status
sudo systemctl status nginx
# Start nginx
sudo systemctl start nginx
# Stop nginx
sudo systemctl stop nginx
# Restart nginx (brief downtime)
sudo systemctl restart nginx
# Reload nginx (no downtime)
sudo systemctl reload nginx
# Enable auto-start on boot
sudo systemctl enable nginx
Terminal window
# Test nginx config for errors
sudo nginx -t
# Test and show full config
sudo nginx -T
# If test passes, reload
sudo nginx -t && sudo systemctl reload nginx
Terminal window
# View DocuHub site config
sudo cat /etc/nginx/sites-available/docs.isutech.co.za
# View enabled sites
ls -la /etc/nginx/sites-enabled/
# View main nginx config
sudo cat /etc/nginx/nginx.conf
Terminal window
# Edit site config
sudo nano /etc/nginx/sites-available/docs.isutech.co.za
# After editing, always test
sudo nginx -t
# If test passes, reload
sudo systemctl reload nginx

Terminal window
# View last 50 lines
tail -50 /var/log/docs-update.log
# View last 100 lines
tail -100 /var/log/docs-update.log
# Follow log in real-time
tail -f /var/log/docs-update.log
# View entire log
cat /var/log/docs-update.log
# View log with timestamps
cat /var/log/docs-update.log | grep "Started"
# Clear log (if needed)
sudo truncate -s 0 /var/log/docs-update.log
Terminal window
# Access log (requests)
sudo tail -50 /var/log/nginx/docs-access.log
# Error log
sudo tail -50 /var/log/nginx/docs-error.log
# Follow access log in real-time
sudo tail -f /var/log/nginx/docs-access.log
# Search for 404 errors
sudo grep "404" /var/log/nginx/docs-access.log
# Count requests by IP
sudo awk '{print $1}' /var/log/nginx/docs-access.log | sort | uniq -c | sort -nr | head -10
Terminal window
# View system journal for nginx
sudo journalctl -u nginx -n 50
# Follow nginx logs
sudo journalctl -u nginx -f
# View logs for today
sudo journalctl -u nginx --since today
# View logs with errors
sudo journalctl -u nginx -p err

Terminal window
# 1. Check current git commit
cd /var/www/docs/repo
git log --oneline -1
# 2. Force pull latest
git fetch --all
git reset --hard origin/main
# 3. Rebuild
source /var/www/docs/venv/bin/activate
mkdocs build --clean
# 4. Check built files
ls -la site/
# 5. Reload nginx
sudo systemctl reload nginx
# 6. Clear browser cache (Ctrl+Shift+R)
Terminal window
# Fix ownership (if docs user exists)
sudo chown -R docs:docs /var/www/docs/
# Or fix to current user
sudo chown -R $USER:$USER /var/www/docs/
# Fix permissions
chmod -R 755 /var/www/docs/repo/site/
chmod +x /var/www/docs/scripts/update-docs.sh
# Check current permissions
ls -la /var/www/docs/
Terminal window
# Check MkDocs is installed
source /var/www/docs/venv/bin/activate
mkdocs --version
# Reinstall MkDocs Material
pip install --upgrade mkdocs-material
# Check for syntax errors in mkdocs.yml
cd /var/www/docs/repo
mkdocs build --strict --verbose
# Check Python version
python --version # Should be 3.7+
Terminal window
# Check nginx is running
sudo systemctl status nginx
# Test configuration
sudo nginx -t
# Check which port nginx is listening on
sudo netstat -tulpn | grep nginx
# Check firewall
sudo ufw status
# Test from server itself
curl http://localhost/
# Test with specific domain
curl -H "Host: docs.isutech.co.za" http://localhost/
Terminal window
# Check SSL certificates
sudo certbot certificates
# Test auto-renewal
sudo certbot renew --dry-run
# Force renew certificate
sudo certbot renew --force-renewal
# Check SSL certificate expiry
echo | openssl s_client -servername docs.isutech.co.za -connect docs.isutech.co.za:443 2>/dev/null | openssl x509 -noout -dates

Terminal window
# Go to repo root
cd /var/www/docs/repo
# Go to docs folder
cd /var/www/docs/repo/docs
# Go to prospects
cd /var/www/docs/repo/docs/prospects
# Go to built site
cd /var/www/docs/repo/site
# List files with details
ls -lah
# Count files in directory
find . -type f | wc -l
# Find specific files
find . -name "*.md" -type f
Terminal window
# View entire file
cat filename.md
# View first 20 lines
head -20 filename.md
# View last 20 lines
tail -20 filename.md
# Search within file
grep "search term" filename.md
# Search recursively in all markdown files
grep -r "search term" docs/*.md
# Count lines in file
wc -l filename.md
Terminal window
# Check overall disk usage
df -h
# Check repo size
du -sh /var/www/docs/repo
# Check site build size
du -sh /var/www/docs/repo/site
# Find large files
du -ah /var/www/docs/repo | sort -rh | head -20
# Check log file sizes
ls -lh /var/log/docs-update.log
ls -lh /var/log/nginx/docs-*.log

Terminal window
# View cron jobs for current user
crontab -l
# View cron jobs for root
sudo crontab -l
# View system cron jobs
cat /etc/crontab
ls -la /etc/cron.d/
Terminal window
# Edit current user's crontab
crontab -e
# Edit root's crontab
sudo crontab -e
# Example: Run update every 10 minutes
*/10 * * * * /var/www/docs/scripts/update-docs.sh
# Example: Run daily at 2am
0 2 * * * /var/www/docs/scripts/update-docs.sh
Terminal window
# View cron execution log
sudo grep CRON /var/log/syslog | tail -50
# Check if update script ran
sudo grep "update-docs.sh" /var/log/syslog | tail -20

Terminal window
# Backup entire docs directory
sudo tar -czf /backup/docs-backup-$(date +%Y%m%d).tar.gz /var/www/docs/
# Backup just the repo
sudo tar -czf /backup/docs-repo-$(date +%Y%m%d).tar.gz /var/www/docs/repo/
# Backup configuration files
sudo tar -czf /backup/nginx-config-$(date +%Y%m%d).tar.gz /etc/nginx/sites-available/docs.isutech.co.za
# List backups
ls -lh /backup/docs-*
Terminal window
# Extract backup
sudo tar -xzf /backup/docs-backup-20250102.tar.gz -C /
# Verify contents
tar -tzf /backup/docs-backup-20250102.tar.gz | head -20
Terminal window
# Check for unauthorized changes
cd /var/www/docs/repo
git status
# Check file permissions
ls -la /var/www/docs/
# Check nginx security headers
curl -I https://docs.isutech.co.za | grep -E "X-Frame|X-Content|X-XSS|Strict"
# Check SSL grade
echo | openssl s_client -connect docs.isutech.co.za:443 2>/dev/null | openssl x509 -noout -text | grep "Signature Algorithm"

Terminal window
# Remove old site builds
rm -rf /var/www/docs/repo/site/*
# Clean git repository
cd /var/www/docs/repo
git 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.log
sudo mv /tmp/docs-update.log /var/log/docs-update.log
Terminal window
# Activate virtual environment
source /var/www/docs/venv/bin/activate
# Update pip
pip install --upgrade pip
# Update MkDocs Material
pip install --upgrade mkdocs-material
# Show installed packages
pip list
# Show outdated packages
pip list --outdated
Terminal window
# Update package lists
sudo apt update
# Upgrade packages
sudo apt upgrade -y
# Reboot if needed (check first)
[ -f /var/run/reboot-required ] && echo "Reboot required" || echo "No reboot needed"
# Reboot server
sudo reboot

Terminal window
# Execute single command
ssh root@46.224.40.5 "cd /var/www/docs/repo && git pull"
# Run update script
ssh root@46.224.40.5 "/var/www/docs/scripts/update-docs.sh"
# Check logs
ssh root@46.224.40.5 "tail -20 /var/log/docs-update.log"
# Get server status
ssh root@46.224.40.5 "systemctl status nginx"
Terminal window
# Copy file TO server
scp local-file.md root@46.224.40.5:/var/www/docs/repo/docs/
# Copy file FROM server
scp root@46.224.40.5:/var/log/docs-update.log ~/Downloads/
# Copy entire directory TO server
scp -r local-folder/ root@46.224.40.5:/var/www/docs/
# Copy entire directory FROM server
scp -r root@46.224.40.5:/var/www/docs/backup/ ~/backups/

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:

FlagPurpose
-aArchive mode (preserves permissions, timestamps, symlinks)
-vVerbose output (shows files being transferred)
-zCompress data during transfer
-PShow progress bar + allow resume of partial transfers
--deleteRemove files at destination that no longer exist at source
--dry-runPreview what will happen without making changes
-e sshUse SSH as transport (default on modern systems)

Sync Files FROM Server to Local Machine:

Terminal window
# Sync a single file from server
rsync -avz root@46.224.40.5:/var/www/docs/repo/docs/operations/docshub-cli-reference.md ~/Desktop/
# Sync an entire directory from server
rsync -avz root@46.224.40.5:/var/www/docs/repo/docs/ ~/Desktop/docs-backup/
# Sync reports or generated files from a project
rsync -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 analysis
rsync -avz root@46.224.40.5:/var/log/docs-update.log ~/Downloads/logs/

Sync Files TO Server from Local Machine:

Terminal window
# Push a single file to server
rsync -avz ~/Documents/new-page.md root@46.224.40.5:/var/www/docs/repo/docs/
# Push an entire directory to server
rsync -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):

Terminal window
# See what WOULD be transferred without actually doing it
rsync -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:

Terminal window
# Exclude specific files or directories
rsync -avz --exclude='*.log' --exclude='.git/' root@46.224.40.5:/var/www/docs/repo/ ~/backups/
# Only sync markdown files
rsync -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 connections
rsync -avz --bwlimit=500 root@46.224.40.5:/var/www/docs/repo/docs/ ~/Desktop/docs-backup/
# Sync using a specific SSH key
rsync -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 machine
rsync -avz /var/www/docs/repo/docs/ /backup/docs-snapshot/

rsync vs scp — When to Use Which:

ScenarioUse
Quick one-off single file copyscp
Repeated syncs of the same directoryrsync
Large directories with few changesrsync
Need to preserve exact permissionsrsync -a
Mirror a folder (delete extras at destination)rsync --delete
Resume an interrupted transferrsync -P

Terminal window
# Search for text in all markdown files
cd /var/www/docs/repo/docs
grep -r "search term" . --include="*.md"
# Case-insensitive search
grep -ri "search term" . --include="*.md"
# Search and show line numbers
grep -rn "search term" . --include="*.md"
# Search with context (2 lines before/after)
grep -rn -C 2 "search term" . --include="*.md"
Terminal window
# Count total documentation files
find /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' {} \;
Terminal window
# Check server load
uptime
# Check memory usage
free -h
# Check disk I/O
iostat
# Check CPU usage
top -b -n 1 | head -20
# Check nginx worker processes
ps aux | grep nginx
# Check connections to nginx
netstat -an | grep :80 | wc -l
netstat -an | grep :443 | wc -l

Add these to ~/.bashrc or ~/.bash_aliases for shortcuts:

Terminal window
# DocuHub aliases
alias 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 aliases
alias 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 bash
source ~/.bashrc

Terminal window
# 1. Check if nginx is running
sudo systemctl status nginx
# 2. If not running, start it
sudo systemctl start nginx
# 3. Check nginx config
sudo nginx -t
# 4. Check error logs
sudo tail -50 /var/log/nginx/docs-error.log
# 5. Restart nginx (last resort)
sudo systemctl restart nginx
# 6. Check DNS
nslookup docs.isutech.co.za
# 7. Check firewall
sudo ufw status
Terminal window
# 1. View recent commits
cd /var/www/docs/repo
git log --oneline -10
# 2. Rollback to specific commit
git reset --hard COMMIT_HASH
# 3. Rebuild
source /var/www/docs/venv/bin/activate
mkdocs build --clean
# 4. Reload nginx
sudo systemctl reload nginx
# 5. To undo rollback (go back to latest)
git reset --hard origin/main
mkdocs build --clean
Terminal window
# 1. Check certificate status
sudo certbot certificates
# 2. Renew certificate
sudo certbot renew
# 3. Reload nginx
sudo systemctl reload nginx
# 4. Verify SSL is working
curl -I https://docs.isutech.co.za

Terminal window
# Quick update
ssh root@46.224.40.5 "/var/www/docs/scripts/update-docs.sh && tail -10 /var/log/docs-update.log"
# Check if site is up
curl -I https://docs.isutech.co.za | head -1
# View today's updates
ssh root@46.224.40.5 "grep '$(date +%Y-%m-%d)' /var/log/docs-update.log"
# Count documentation files
ssh root@46.224.40.5 "find /var/www/docs/repo/docs -name '*.md' | wc -l"
# Get current commit hash
ssh root@46.224.40.5 "cd /var/www/docs/repo && git rev-parse --short HEAD"
# Check nginx syntax and reload
ssh root@46.224.40.5 "sudo nginx -t && sudo systemctl reload nginx"

Internal Documentation:

External References:


  1. Always test before deploying:

    Terminal window
    mkdocs build --strict # Catches config errors
    sudo nginx -t # Validates nginx config
  2. Check logs after operations:

    Terminal window
    tail -20 /var/log/docs-update.log
    sudo tail -20 /var/log/nginx/docs-error.log
  3. Use clean builds when updating:

    Terminal window
    mkdocs build --clean # Removes stale files
  4. Hard refresh browser after updates:

    • Ctrl+Shift+R (Windows/Linux)
    • Cmd+Shift+R (Mac)
  5. 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