Unlock Productivity: Create a Full‑Featured AI Coding Workflow on Ubuntu with CC Switch and Ollama
This step‑by‑step guide shows how to install Ollama on Ubuntu, download DeepSeek‑Coder‑V2 or Qwen2.5‑Coder models, set up Claude Code, Codex, and Gemini CLI clients, configure the open‑source CC Switch proxy to route their requests to the local Ollama engine, and run a test prompt that generates Python code without any external API keys.
Step 1 – Foundation: Install Ollama and Prepare Models
Ollama serves as the local AI inference engine. Install it with the official one‑liner: curl -fsSL https://ollama.com/install.sh | sh Configure the systemd service so Ollama listens on all interfaces: sudo systemctl edit ollama.service In the editor add:
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_ORIGINS=*"Reload and restart the service:
sudo systemctl daemon-reload
sudo systemctl restart ollamaDownload and run a programming‑oriented model. The guide recommends DeepSeek‑Coder‑V2 or Qwen2.5‑Coder (e.g., the 32B variant requiring ≥24 GB VRAM):
# Qwen2.5‑Coder 32B
ollama run qwen2.5-coder:32b
# or DeepSeek‑R1 14B
ollama run deepseek-r1:14bStep 2 – Tools: Install AI CLI Clients
Install the command‑line front‑ends that normally talk to cloud APIs. Ensure Node.js v18+ and npm are present.
Claude Code (Anthropic)
npm install -g @anthropic-ai/claude-codeCodex CLI (OpenAI compatible)
npm install -g @openai/codexGemini CLI (Google)
npm install -g gemini-chat-cliRunning these commands would normally prompt for an API key; the next step intercepts that traffic.
Step 3 – Hub: Install and Configure CC Switch
CC Switch (Claude Code Switch) is an open‑source proxy router that can rewrite requests from the above CLIs to any OpenAI‑compatible backend, such as Ollama.
Install CC Switch
npm install -g @songhe/cc-switch
# or download the Linux binary from GitHub Releases
# wget https://github.com/farion1231/cc-switch/releases/download/v3.10.0/CC-Switch-v3.10.0-linux-amd64.tar.gzAdd an Ollama configuration
# Create a new profile named local-ollama
ccs new local-ollamaDuring the interactive setup, provide:
Provider Type: OpenAI Compatible Base URL: http://localhost:11434/v1 API Key: ollama (placeholder)
Model: the name of the model you started, e.g.,
qwen2.5-coder:32bStart the proxy
# Switch to the new profile
ccs switch local-ollama
# Launch proxy mode (required by some clients)
ccs proxy startCC Switch now runs a background forwarding service and sets environment variables such as https_proxy, HTTP_PROXY, and CLAUDE_BASE_URL so the CLI tools connect to the local Ollama instance.
Final Test – Verify the Workflow
Run the Claude Code CLI: claude The prompt is processed locally; no login to Anthropic is needed. Example prompt: >> 帮我用 Python 写一个贪吃蛇游戏 Ollama performs the inference, and Claude Code returns the generated Python code within seconds.
Advanced Tips
Mixed profiles: Use ccs switch to toggle between a local DeepSeek profile and a cloud‑based Claude‑3.5 profile, keeping sensitive data local while delegating heavy reasoning to the cloud.
Hot model swapping: Change the model field in CC Switch configuration to instantly switch Claude CLI to DeepSeek or Llama backends.
Conclusion
By combining Ubuntu, Ollama, and CC Switch, you can enjoy the polished interfaces of major AI services while retaining full control over data and eliminating costly API subscriptions.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ubuntu
Focused on Ubuntu/Linux tech sharing, offering the latest news, practical tools, beginner tutorials, and problem solutions. Connecting open-source enthusiasts to build a Linux learning community. Join our QQ group or channel for discussion!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
