Install Gemini CLI on Linux
Complete guide for installing Gemini CLI on various Linux distributions.
Ubuntu / Debian / Linux Mint
1. Update package list:
sudo apt update
2. Install Node.js and npm:
# Install Node.js 18.x
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install nodejs
3. Install Gemini CLI:
sudo npm install -g @google/gemini-cli
4. Verify installation:
gemini --version
Fedora / RHEL / CentOS
1. Install Node.js:
# For Fedora
sudo dnf install nodejs npm
# For RHEL/CentOS 8+
sudo dnf module enable nodejs:18
sudo dnf install nodejs npm
2. Install Gemini CLI:
sudo npm install -g @google/gemini-cli
Arch Linux / Manjaro
1. Install Node.js and npm:
sudo pacman -S nodejs npm
2. Install Gemini CLI:
sudo npm install -g @google/gemini-cli
Install with Docker
Run Gemini CLI in a Docker container for isolation and reproducibility, especially useful in CI/CD pipelines or shared environments.
1. Create a Dockerfile:
# Dockerfile
FROM node:18-alpine
RUN npm install -g @google/gemini-cli
ENTRYPOINT ["gemini"]
2. Build and run:
# Build the image
docker build -t gemini-cli .
# Run with API key
docker run -e GEMINI_API_KEY=your-key gemini-cli "Hello world"
# Mount a local directory for file access
docker run -e GEMINI_API_KEY=your-key -v $(pwd):/workspace -w /workspace gemini-cli "Explain this code" < app.py
3. Or use a one-liner without Dockerfile:
docker run --rm -e GEMINI_API_KEY=your-key node:18-alpine sh -c "npm install -g @google/gemini-cli && gemini 'Hello'"
Install Using NVM (Recommended)
Node Version Manager (nvm) allows you to install Node.js without sudo:
1. Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Reload shell configuration
source ~/.bashrc
2. Install Node.js:
nvm install node
nvm use node
3. Install Gemini CLI:
npm install -g @google/gemini-cli
Fix npm Permissions (Alternative to sudo)
If you want to avoid using sudo for npm installations:
# Create a directory for global packages
mkdir ~/.npm-global
# Configure npm to use the new directory
npm config set prefix '~/.npm-global'
# Add to PATH (add to ~/.bashrc or ~/.zshrc)
export PATH=~/.npm-global/bin:$PATH
# Reload shell configuration
source ~/.bashrc
Run as a systemd Service (Advanced)
For automation use cases, you can set up Gemini CLI as a systemd service that processes requests from a queue or file watcher.
1. Create a service file:
# /etc/systemd/system/gemini-cli.service
[Unit]
Description=Gemini CLI Service
After=network.target
[Service]
Type=simple
User=your-username
Environment=GEMINI_API_KEY=your-api-key
ExecStart=/usr/bin/gemini --daemon
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
2. Enable and start:
sudo systemctl daemon-reload
sudo systemctl enable gemini-cli
sudo systemctl start gemini-cli
# Check status
sudo systemctl status gemini-cli
Note: This is an advanced setup for automation. Most users will run Gemini CLI directly from the terminal. See our automation guide for more use cases.
Common Issues
EACCES permission denied
Use the npm permissions fix above or install with nvm
Command not found: gemini
Add npm global bin directory to PATH:
echo 'export PATH="$(npm bin -g):$PATH"' >> ~/.bashrc
source ~/.bashrc
Old Node.js version
Update Node.js to version 16 or higher using nvm or your package manager
Permission issues with global npm packages
If you encounter permission errors when installing or running Gemini CLI, here are three solutions ranked by preference:
Best: Use NVM (see above) — avoids all permission issues
Good: Change npm's default directory to a user-owned location
Avoid: Using sudo for npm install — can cause ownership conflicts
Related Questions
Next Steps
Excellent! Gemini CLI is now installed on your Linux system. Configure your API key to start using it: