A collection of utility scripts for managing Ollama models on Linux systems. These tools help simplify common administration tasks for your Ollama server.
Ollama is a framework that allows you to run large language models locally. These utilities help you manage your Ollama installation more efficiently.
Automatically checks for and pulls the latest versions of all installed Ollama models. Builds a dependency tree so that standard registry models are updated first, and custom models (e.g. those created with ollama_set_ctx.sh) are updated by detecting their base model and rebuilding after the base is pulled.
Features:
- Updates all models in sequence with clear feedback
- Standard models: pulls from registry and optionally restores your PARAMETER overrides (e.g.
num_ctx) - Custom models: detects the base model via hash matching; if the hash link is broken (e.g. base was updated), falls back to property fingerprint matching (architecture + parameters + quantization) to identify the correct parent (e.g.
gemma3:27b-it-qatforgemma3:100k_num_ctx), then pulls the base and rebuilds the custom model
A powerful utility to optimize and manage the context window size for your Ollama models. Ollama per default limits context size for models and with this utility you can set it to the models trained context size.
Features:
- Interactive per-model confirmation [y/N/all]
- Non-interactive mode with
-yfor batch processing - Global context size cap with
-m <value> - Force mode to overwrite existing context settings
- Single model or batch mode operation
- Support for international number formats
Backs up all Modelfiles for installed models into a dated directory (ollama_modelfile_backups_YYYYMMDD/). Each model is saved as <model_name>.Modelfile (colons in names replaced with underscores for filesystem safety). Use these files to restore or inspect configurations later.
./ollama_backup.sh
# To restore a model: ollama create <model_name> -f ollama_modelfile_backups_YYYYMMDD/<filename>A utility script to display a detailed list of Ollama models. It provides information such as architecture, parameters, quantization, disk size, maximum context length, used context length, VRAM usage, and processor. It supports filtering by regex patterns, quick mode, caching, and interactive UI.
Features:
- Detailed model information
- NAME - Name of the model
- ID - Unique identifier from ollama
- ARCH - Architecture of the model (e.g., qwen2, qwen3, etc.)
- PARAMS - Number of parameters (e.g., 7B, 13B, 70B)
- QUANT - Quantization type (e.g., Q4_K_M, Q8_0, F16)
- DISK - Disk size of the model
- CTX(MAX) - Maximum context length of the model
- CTX(USED) - measured size of the context with current settings
- VRAM - measured VRAM/RAM usage with current settings
- PROCESSOR - measured model fit into GPU or CPU (eg. 100% GPU, 64%/36% CPU/GPU)
- Regex filtering
- Sort by column:
--sort NAME|ARCH|PARAMS|QUANT|DISK|CTX|VRAM|PROCESSOR(numeric-aware for PARAMS, DISK, CTX, VRAM);--reversefor descending order - Quick mode for fast limited output (excluding CTX(USED), VRAM, PROCESSOR)
- Caching for improved performance
- Interactive UI with animations for progress
- Exportable to CSV format
USAGE:
./ollama_ls_details.sh [OPTIONS] [PATTERN]
OPTIONS:
-p, --pattern <regex> Filter models by a regular expression.
-s, --sort <COLUMN> Sort by column: NAME, ARCH, PARAMS, QUANT, DISK, CTX, VRAM, PROCESSOR.
--reverse Reverse sort order (default: ascending).
--quick Quick mode. Skips the slow VRAM/PROCESSOR loading.
--no-progress Disable the interactive UI and animations.
--no-cache Force a fresh run, ignoring and not writing to the cache.
-h, --help Display this help menu and exit.
ARGUMENTS:
[PATTERN] (Optional) A regex pattern to filter models.- Linux operating system
- Ollama installed and configured
- Bash shell
-
Clone this repository (replace
YOUR_USERNAMEwith your GitHub username or fork path):git clone https://github.com/YOUR_USERNAME/ollama-admin-tools.git cd ollama-admin-tools -
Make the scripts executable:
chmod +x *.sh
By default, these tools connect to your local Ollama instance. To manage a remote Ollama server:
export OLLAMA_HOST="http://your-remote-server:11434"To check and update all your installed models to their latest versions (including custom models by base detection):
./ollama_update_all.sh# Display help information:
./ollama_set_ctx.sh --help
# Single Model Operations:
./ollama_set_ctx.sh llama3.3:latest # Update using native context
./ollama_set_ctx.sh -y llama3.3:latest # Update without confirmation prompt
./ollama_set_ctx.sh -f llama3.3:latest # Force update even if context already set
./ollama_set_ctx.sh -s 4096 llama3.3:latest # Set specific context size (4096)
./ollama_set_ctx.sh -s 32k llama3.3:latest # Set specific context size (32k)
./ollama_set_ctx.sh -m 8192 llama3.3:latest # Cap context at 8192
./ollama_set_ctx.sh -m 8k llama3.3:latest # Cap context at 8K (equivalent to 8192)
# New Model Operations:
./ollama_set_ctx.sh -a llama3.3:latest # Auto-named model with native context (e.g., 'llama3.3:128k_num_ctx')
./ollama_set_ctx.sh -a -m 16k llama3.3:latest # Auto-named model with capped context (e.g., 'llama3.3:16k_num_ctx')
./ollama_set_ctx.sh -a -s 4096 llama3.3:latest # Auto-named model with specific context (e.g., 'llama3.3:4k_num_ctx')
./ollama_set_ctx.sh -o llama3.3:full_context llama3.3:latest # Custom-named model with native context
./ollama_set_ctx.sh -o llama3.3:large -m 32k llama3.3:latest # Custom-named model with capped context
./ollama_set_ctx.sh -o llama3.3:4k -s 4096 llama3.3:latest # Custom-named model with specific context
# Batch Operations (All Installed Models):
./ollama_set_ctx.sh # Interactive update of all models (native context)
./ollama_set_ctx.sh -y # Non-interactive update of all models (native context)
./ollama_set_ctx.sh -y -f # Force update all models, no confirmations
./ollama_set_ctx.sh -y -m 8k # Update all models, cap at 8K
./ollama_set_ctx.sh -y -s 4096 # Update all models to exactly 4096 context
./ollama_set_ctx.sh -a # Create auto-named copies of all models with their native max context
./ollama_set_ctx.sh -a -m 16k # Create auto-named copies capped at 16K
# Combined Options:
./ollama_set_ctx.sh -y -f -m 32k llama3.3:latest # Force update with no confirmation, cap at 32K
./ollama_set_ctx.sh -y -f -a -m 16k llama3.3:latest # Create auto-named model, force, no confirmation, cap at 16KIf you have a system with limited RAM but want to use the maximum practical context size:
# Set all models to use at most 8k context but keeping their original names.
./ollama_set_ctx.sh -y -m 8kOr create copies with new auto named models:
# Create new models to use at most 8k context with auto generated names.
./ollama_set_ctx.sh -y -m 8k -aAdd to your crontab for weekly updates:
0 2 * * 0 /path/to/ollama_update_all.sh > /path/to/update_log.txt 2>&1 && /path/to/ollama_set_ctx.sh -y -m 32k -a >> /path/to/update_log.txt 2>&1Contributions are welcome! Feel free to submit pull requests or create issues for bugs and feature requests.
MIT License