How to Install and Use Gemini CLI on Ubuntu 24.04: Complete Guide

install gemni cli

The rise of AI-powered developer tools has made command-line interfaces (CLI) more powerful than ever. Gemini CLI, part of Google’s Gemini ecosystem, allows developers to interact directly with Gemini models from their terminal.

In this guide, you’ll learn how to install Gemini CLI on Ubuntu 24.04, configure it, and use it for day-to-day AI-assisted development tasks.

Table of Contents

  1. What is Gemini CLI?
  2. Why Use Gemini CLI on Ubuntu 24.04?
  3. Installing Gemini CLI on Ubuntu 24.04
    • Update System Packages
    • Install Required Dependencies
    • Download Gemini CLI
    • Install the Binary
  4. Verifying the Installation
  5. Basic Commands in Gemini CLI
  6. Configuring Gemini CLI for API Access
  7. Example Use Cases of Gemini CLI
    • Running AI-Powered Commands
    • Managing Projects from the Terminal
    • Scripting Automation with Gemini
  8. Troubleshooting Common Issues
  9. Updating or Uninstalling Gemini CLI
  10. Best Practices for Using Gemini CLI on Ubuntu
  11. Conclusion

1. What is Gemini CLI?

Gemini CLI is a command-line tool designed to let developers interact with Google’s Gemini large language models. Instead of relying on graphical interfaces or cloud dashboards, Gemini CLI provides a lightweight and efficient way to:

  • Run AI prompts directly from the terminal.
  • Automate workflows by integrating Gemini into shell scripts.
  • Quickly experiment with AI-powered features in a development environment.

2. Why Use Gemini CLI on Ubuntu 24.04?

Ubuntu 24.04 is a stable, developer-friendly Linux distribution that is widely adopted for both local and cloud environments. Using Gemini CLI on Ubuntu enables:

  • Seamless integration with existing Linux workflows.
  • Easy automation using Bash scripts and cron jobs.
  • Access to the latest Gemini AI models without switching to a browser or external app.

3. Installing Gemini CLI on Ubuntu 24.04

Step 0: Prerequisites

Before installing Gemini CLI, ensure you have:

  • A system running Ubuntu 24.04.
  • curl and wget installed.
  • A Google Cloud account with Gemini API access enabled.
  • Internet connection to download binaries.

Step 1: Update System Packages

Always start by updating your system:

sudo apt update && sudo apt upgrade -y

Step 2: Install Required Dependencies

Install essential tools:

sudo apt install curl wget unzip -y

Step 3: Download Gemini CLI

Visit the official Gemini CLI GitHub releases page or use curl to fetch the binary:

curl -LO https://github.com/google/gemini-cli/releases/latest/download/gemini-cli-linux-amd64.zip

Step 4: Install the Binary

Unzip and move the binary to /usr/local/bin:

unzip gemini-cli-linux-amd64.zip
sudo mv gemini /usr/local/bin/gemini
sudo chmod +x /usr/local/bin/gemini

4. Verifying the Installation

Run the following to confirm installation:

gemini --version

You should see the installed version printed on the terminal.

5. Basic Commands in Gemini CLI

Here are some basic commands:

  • Check help menu:
  gemini help
  • Run a quick prompt:
  gemini prompt "Write a Python script that prints Hello World"
  • List available models:
  gemini models list

basic-commands-gemini6. Configuring Gemini CLI for API Access

You’ll need to authenticate with your Google Cloud Gemini API key.

export GEMINI_API_KEY="your_api_key_here"

To make it permanent, add the line above to your ~/.bashrc or ~/.zshrc.

7. Example Use Cases of Gemini CLI

Running AI-Powered Commands

Developers can quickly generate code snippets, documentation, or config files:

gemini prompt "Generate a Dockerfile for a Node.js application"

Managing Projects from the Terminal

Gemini CLI can assist with project planning by generating task lists:

gemini prompt "Create a sprint backlog for a web app project"

Scripting Automation with Gemini

Embed Gemini CLI into Bash scripts for automated tasks:

#!/bin/bash
RESPONSE=$(gemini prompt "Summarize today's tech news in 3 sentences")
echo $RESPONSE >> news-summary.txt

8. Troubleshooting Common Issues

  • Command not found: Ensure /usr/local/bin is in your PATH.
  • API authentication error: Double-check your GEMINI_API_KEY.
  • Permission denied: Verify execution rights:
  chmod +x /usr/local/bin/gemini

9. Updating or Uninstalling Gemini CLI

Update

Simply download the latest binary and replace the existing one:

curl -LO https://github.com/google/gemini-cli/releases/latest/download/gemini-cli-linux-amd64.zip
unzip gemini-cli-linux-amd64.zip
sudo mv gemini /usr/local/bin/gemini

Uninstall

To remove Gemini CLI:

sudo rm /usr/local/bin/gemini

10. Best Practices for Using Gemini CLI on Ubuntu

  • Store your API key securely (avoid committing it to Git).
  • Combine Gemini CLI with tools like tmux or screen for multitasking.
  • Use aliases in your shell for faster prompts, e.g.:
  alias gprompt="gemini prompt"
  • Update regularly to access new features and models.

12. Conclusion

Gemini CLI is a powerful tool for developers who prefer the speed and flexibility of the terminal. Installing it on Ubuntu 24.04 takes only a few steps, and once configured, you can harness the capabilities of Gemini models for coding, project management, and automation.

By integrating Gemini CLI into your daily workflow, you can streamline tasks, boost productivity, and bring AI assistance directly into your Linux environment.

(Visited 29 times, 3 visits today)

You may also like