Skip to Content

File Operations

TL;DR

CMDOP CLI provides complete file operations on remote machines via cmdop files subcommands. List directories, download/upload files and directories, read/tail/follow files, delete, copy, move, and sync. Supports recursive transfers with progress display, rsync-like directory sync with --delete and --dry-run options. Use hostname:path syntax to target remote files.

Transfer and manage files on remote machines.

How do I list a remote directory?

# List files and directories at a remote path cmdop files ls <hostname>:<path>

Example:

# List log files on the production server cmdop files ls prod-server:/var/log

Output:

NAME SIZE MODIFIED app.log 1.2 MB 2 hours ago nginx/ - 1 day ago syslog 45 KB just now

What listing options are available?

# Include hidden files cmdop files ls prod-server:/home/deploy --all # Long format cmdop files ls prod-server:/var/log --long # JSON output cmdop files ls prod-server:/var/log --json

How do I download a file?

# Download a file from remote to local filesystem cmdop files get <hostname>:<remote> <local>

Examples:

# Download single file cmdop files get prod-server:/var/log/app.log ./app.log # Download to current directory cmdop files get prod-server:/var/log/app.log . # Download with different name cmdop files get prod-server:/var/log/app.log ./logs/production.log

How do I download a directory?

# Download an entire directory recursively cmdop files get prod-server:/app/logs ./local-logs --recursive

How do I upload a file?

# Upload a local file to a remote machine cmdop files put <local> <hostname>:<remote>

Examples:

# Upload single file cmdop files put ./config.yaml prod-server:/app/config.yaml # Upload with different name cmdop files put ./local.conf prod-server:/etc/app/production.conf

How do I upload a directory?

# Upload an entire directory recursively cmdop files put ./dist prod-server:/app/public --recursive

How do I read a remote file?

# Print remote file contents to stdout cmdop files cat <hostname>:<path>

Example:

# Read hostname from remote machine cmdop files cat prod-server:/etc/hostname

How do I tail a remote file?

# Last 100 lines cmdop files cat prod-server:/var/log/app.log --tail 100 # Follow (like tail -f) cmdop files cat prod-server:/var/log/app.log --follow

How do I delete a remote file?

# Delete a file on a remote machine cmdop files rm <hostname>:<path>

Examples:

# Delete file cmdop files rm prod-server:/tmp/old-file.txt # Delete directory cmdop files rm prod-server:/tmp/old-dir --recursive

How do I create a remote directory?

# Create a directory on a remote machine cmdop files mkdir <hostname>:<path>

Example:

# Create a logs directory on the production server cmdop files mkdir prod-server:/app/logs

How do I copy a remote file?

# Copy a file on a remote machine cmdop files cp <hostname>:<source> <hostname>:<dest>

Example:

# Create a backup copy of a config file cmdop files cp prod-server:/app/config.yaml prod-server:/app/config.yaml.backup

How do I move or rename a remote file?

# Move or rename a file on a remote machine cmdop files mv <hostname>:<source> <hostname>:<dest>

Example:

# Move uploaded file to its final location cmdop files mv prod-server:/tmp/upload.txt prod-server:/app/data.txt

How do I get file info?

# Show size, permissions, owner, and modification time cmdop files info <hostname>:<path>

Output:

Path: /var/log/app.log Size: 1,234,567 bytes Mode: 0644 Owner: deploy Group: deploy Modified: 2026-02-14 10:30:00

How do I sync a directory?

# Sync local directory to remote (only transfers changed files) cmdop files sync <local> <hostname>:<remote>

Only transfers changed files (like rsync):

cmdop files sync ./project prod-server:/app

Options:

# Delete files on remote not in local cmdop files sync ./project prod-server:/app --delete # Dry run cmdop files sync ./project prod-server:/app --dry-run

What does the progress display look like?

Large transfers show progress:

Uploading: data.tar.gz [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 60% 120 MB/200 MB 5.2 MB/s ETA: 15s

What are some scripting examples?

Backup

#!/bin/bash DATE=$(date +%Y%m%d) cmdop files get prod-server:/data/db.sqlite ./backup/db-$DATE.sqlite cmdop files get prod-server:/data/uploads ./backup/uploads-$DATE --recursive

Deploy

#!/bin/bash # Upload new version cmdop files put ./dist prod-server:/app/public-new --recursive # Swap directories cmdop exec prod-server "mv /app/public /app/public-old && mv /app/public-new /app/public" # Restart cmdop exec prod-server "systemctl restart app"

Config Sync

#!/bin/bash SERVERS="web-1 web-2 web-3" for server in $SERVERS; do cmdop files put ./config.yaml $server:/app/config.yaml done
Last updated on