Back to Blog
BlogApril 7, 20262

How to Install Gemini CLI on Ubuntu: Complete Step-by-Step Tutorial

How to Install Gemini CLI on Ubuntu: Complete Step-by-Step Tutorial

Prerequisites

Before starting the Gemini CLI installation on Ubuntu, prepare the following:

  • Ubuntu version: 20.04 LTS or newer (22.04, 24.04, and 26.04 are fully supported).
  • Administrative access: Sudo privileges for package management.
  • Internet connection: Required for downloading Node.js, npm packages, and authentication.
  • Google account: Needed for OAuth sign-in to access Gemini models.
  • Recommended hardware: At least 4 GB RAM and 2 CPU cores for smooth performance during interactive sessions.

Basic knowledge assumed: You know how to open a terminal and run basic apt and bash commands.

Step 1: Update System Packages

Start by refreshing your package list and upgrading existing packages to prevent dependency conflicts:

sudo apt update && sudo apt upgrade -y

This step ensures you have the latest security updates and repository information.

Step 2: Install Node.js 20 or Higher

Gemini CLI requires Node.js version 20 or newer. Ubuntu's default repositories often include older versions (e.g., Node 18 on Ubuntu 24.04).

Recommended Method: NodeSource Repository

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

Alternative: Using nvm (Node Version Manager)

For easier version management:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20
nvm alias default 20

Verify the installation:

node --version
npm --version

You should see output similar to v20.x.x for Node.js and a matching npm version.

Step 3: Install Gemini CLI

Global Installation (Recommended for Daily Use)

npm install -g @google/gemini-cli

This makes the gemini command available system-wide.

Quick Test Without Permanent Install

If you want to try it first:

npx @google/gemini-cli

User-Level Installation (Avoid Permission Issues)

If you encounter permission errors with global install:

mkdir -p ~/.local/bin
npm config set prefix '~/.local'
export PATH="$HOME/.local/bin:$PATH"
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
npm install -g @google/gemini-cli

Step 4: Verify the Installation

Check that Gemini CLI is correctly installed:

gemini --version

Expected output shows the current version of Gemini CLI.

Step 5: Launch and Authenticate

Run the CLI for the first time:

gemini

The tool will prompt you to sign in with Google. A browser window opens automatically. Complete the OAuth flow and return to the terminal.

After successful authentication, the interactive Gemini CLI interface loads. Use /help to see available commands.

Best practice: Navigate to your project directory before launching:

cd ~/my-project
gemini

Common Issues & Troubleshooting

  • 'gemini: command not found': Restart your terminal or run source ~/.bashrc. Check your PATH with echo $PATH.

  • Permission denied during npm install: Use the user-level installation method above instead of sudo npm.

  • Node.js version error: Re-run the NodeSource setup or switch versions with nvm. Confirm with node --version.

  • Authentication fails: Disable browser pop-up blockers, ensure cookies are enabled, and try again. Clear npm cache if needed: npm cache clean --force.

  • Network timeout or download errors (e.g., ripgrep prebuilt): Ensure stable internet. Retry the install or use npx as a workaround.

  • Missing build tools: Install development dependencies:

sudo apt install -y build-essential python3
  • WSL-specific issues: Run commands in a standard Ubuntu terminal rather than WSL if compilation errors occur.

For more help, refer to the official GitHub repository: https://github.com/google-gemini/gemini-cli.

Next Steps

  • Explore core commands: Type /help, /model, or /settings inside the CLI.
  • Use in projects: Ask Gemini to explain code, refactor functions, or generate new files with natural language prompts.
  • Customize: Edit configuration files in ~/.config/gemini-cli/ for themes, default models, and extensions.
  • Update regularly: Run npm update -g @google/gemini-cli to get the latest improvements.
  • Integrate tools: Experiment with built-in extensions and MCP servers for advanced agentic workflows like git integration.

You are now ready to use Gemini CLI as a powerful AI coding assistant directly in your Ubuntu terminal. Start with simple prompts in a project folder and gradually build more complex agentic tasks.

Happy coding with Gemini!

Share this article