How To Install Gemini CLI on Linux Mint 22

If you want a powerful AI assistant living directly inside your Linux terminal, Gemini CLI is one of the best free options available right now. This guide shows you exactly how to install Gemini CLI on Linux Mint 22, from setting up the correct Node.js version to authenticating with your Google account and running your first prompt. By the end, you will have a fully working Gemini CLI setup that lets you query AI, analyze local files, and automate tasks without ever leaving your terminal.
Linux Mint 22 ships with Node.js 18 by default, which is below the minimum version Gemini CLI requires. That single detail catches most users off guard and makes the installation fail before it even starts. This guide addresses that problem head-on in the first few steps so you do not waste time debugging a preventable error.
What Is Gemini CLI and Why Should Linux Mint Users Care?
Gemini CLI is a free, open-source AI agent developed by Google that brings the Gemini large language model directly into any modern Linux terminal. It is not a browser tab or a GUI application; it runs entirely from the command line, which makes it a natural fit for Linux Mint users who already live in the terminal.
Unlike the Gemini web interface, Gemini CLI can read and edit local files, execute shell commands, and work directly inside your project directories. That context-awareness is what makes it genuinely useful for sysadmins and developers, not just a novelty.
What Gemini CLI Can Do
Here is a practical breakdown of its core capabilities:
- Query and edit large codebases using a 1-million-token context window
- Generate apps from PDFs or image sketches using built-in multimodal support
- Automate repetitive shell tasks such as checking pull requests or running rebases
- Ground answers with Google Search, which is integrated natively into Gemini
- Run in non-interactive (headless) mode for scripts and CI/CD pipelines
- Reference local files using the
@filenamesyntax directly inside prompts - Integrate external services through Model Context Protocol (MCP) servers
Free Tier Limits
Gemini CLI is free to use with a personal Google account. The free tier provides up to 1,000 requests per day and 60 requests per minute on the Gemini 2.5 Pro model using OAuth login.
If you exceed those limits, Gemini automatically falls back to a less capable but less rate-restricted model. For most personal and development use on Linux Mint 22, the free tier is more than enough.
Users who need higher throughput or want to automate pipelines can authenticate with a paid Gemini API key from Google AI Studio.
Prerequisites: What You Need Before You Start
Before you begin the installation, confirm your environment meets these requirements. Skipping this step is the most common reason the installation fails on Linux Mint 22.
Operating system and hardware:
- Linux Mint 22 (based on Ubuntu 24.04 LTS)
- At least 4 GB of RAM for casual use; 16 GB recommended for long sessions with large codebases
- A stable internet connection (Gemini CLI is cloud-dependent and requires connectivity for every request)
Software requirements:
- Node.js 20.0.0 or higher — Node.js 18 (the default on Linux Mint 22) will not work
- npm — bundled with Node.js automatically
- Bash or Zsh shell — both are available by default on Linux Mint 22
- A Google account — required for free-tier OAuth authentication
sudo(root) privileges on your Linux Mint 22 machine
Tools installed by this guide:
- NodeSource APT repository (to get Node.js 20)
@google/gemini-clinpm package
Step 1: Update Your Linux Mint 22 System
Always update your system before installing new software. This refreshes your package index and applies pending security and compatibility patches, which prevents dependency conflicts during the Node.js installation.
Open your terminal and run:
sudo apt update
sudo apt upgrade -y
The sudo apt update command fetches the latest package list from all configured repositories. The sudo apt upgrade -y command installs all available updates without asking for confirmation at each step.
If the upgrade process installs a new kernel version, reboot your machine before continuing:
sudo reboot
A reboot after a kernel update is good practice and ensures your system environment is fully clean before you add new repositories.
Step 2: Install Node.js 20 on Linux Mint 22
This is the most important step in the entire process. Linux Mint 22 is based on Ubuntu 24.04 LTS, and its default APT repository only provides Node.js 18. Gemini CLI requires Node.js 20.0.0 or higher, so running sudo apt install nodejs without adding the correct repository will install the wrong version.
You need to add the NodeSource APT repository, which provides an up-to-date Node.js 20.x build for Debian-based systems including Linux Mint.
Add the NodeSource Repository
Run this command to download and execute the NodeSource setup script:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
Here is what this command does:
curl -fsSLdownloads the setup script silently and fails cleanly on any errorsudo -E bash -executes the script with root privileges while preserving the current user environment- The script adds the NodeSource Node.js 20.x repository to your APT sources
Security note: This script runs with root access. If you want to review what it does before executing it, open https://deb.nodesource.com/setup_20.x in your browser first.
Install Node.js 20
Now install Node.js from the newly added NodeSource repository:
sudo apt install -y nodejs
This command installs Node.js 20.x along with npm, which is the Node Package Manager you need to install Gemini CLI.
Verify Node.js and npm Are Installed Correctly
Confirm the installation succeeded by checking both version numbers:
node -v
npm -v
Expected output:
v20.x.x
10.x.x
Your node -v output must begin with v20 or higher. If it still shows v18.x.x, the NodeSource repository was not added correctly. Re-run the setup script from the previous step and look carefully for any error messages in the output.
Step 3: Install Gemini CLI on Linux Mint 22
With Node.js 20 confirmed, you are ready to install Gemini CLI. There are two approaches: a global npm installation (recommended for regular use) and the npx method (for one-time or testing use).
Option A: Global npm Installation (Recommended)
Installing Gemini CLI globally makes the gemini command available from any directory on your system at any time.
sudo npm install -g @google/gemini-cli
Breaking down this command:
sudoprovides root privileges needed for writing to the global npm directorynpm installdownloads and installs the package-ginstalls it globally (system-wide), not just in the current project folder@google/gemini-cliis the official package name on the npm registry
This installation downloads the stable release channel by default. Gemini CLI also offers preview and nightly release channels, but for production and everyday use on Linux Mint 22, the stable release is the right choice.
Option B: Run Without Installing (npx Method)
If you want to test Gemini CLI without writing anything permanently to your system, use npx:
npx https://github.com/google-gemini/gemini-cli
This method downloads and runs Gemini CLI directly from the GitHub source without a permanent installation. The trade-off is speed: npx re-downloads the package on every run, which adds startup delay. For daily use, the global npm installation is a much better experience.
Verify the Gemini CLI Installation
After the global install, confirm the gemini command is accessible:
gemini --version
You should see a version number printed in the terminal. If the terminal returns command not found, close the current terminal session and open a new one, then try again. A fresh session is sometimes needed for the updated PATH to take effect.
Step 4: Authenticate Gemini CLI with Your Google Account
Before Gemini CLI can process any prompts, you must authenticate. The CLI supports three authentication methods. For most Linux Mint 22 users, the Google OAuth login is the simplest and most generous option.
Method 1: Sign In with Google (Recommended)
Launch Gemini CLI for the first time:
gemini
On the first launch, the CLI displays an authentication prompt. Select Sign in with Google. A URL appears in your terminal. Click it or copy and paste it into any browser, sign in with your Google account, and approve the access request.
Your credentials are cached locally after the first login, so you will not need to authenticate again in future sessions. This method gives you 1,000 requests per day and 60 requests per minute on Gemini 2.5 Pro, all at no cost.
Method 2: Authenticate with a Gemini API Key
This method suits users who want higher quotas, need to run Gemini CLI in headless or automated mode, or prefer not to use browser-based OAuth.
First, get your API key from Google AI Studio at https://aistudio.google.com. Then set the environment variable in your terminal:
export GEMINI_API_KEY="your_api_key_here"
To make this permanent so you do not have to re-export it every session, add the line to your shell configuration file:
echo 'export GEMINI_API_KEY="your_api_key_here"' >> ~/.bashrc
source ~/.bashrc
If you use Zsh instead of Bash, replace ~/.bashrc with ~/.zshrc. When you launch Gemini CLI after setting this variable, select Use Gemini API key when prompted for the authentication method.
Method 3: Vertex AI (Enterprise Users Only)
Vertex AI authentication is designed for teams using Google Cloud infrastructure. It requires a Google Cloud project with billing enabled and the Vertex AI API activated. For individual developers and sysadmins using Linux Mint 22 personally, Methods 1 and 2 cover virtually every use case.
Step 5: Launch Gemini CLI and Run Your First Prompt
With authentication complete, you can start using Gemini CLI immediately. Before launching, navigate to a relevant project directory so the CLI has local context to work with.
cd ~/your-project-folder
gemini
The terminal displays a startup banner and then the prompt: “How can I assist you?” Type your question or task and press Enter.
Basic Usage Examples
Here are practical examples that show immediate real-world value:
Ask a general question:
gemini -p "What is the difference between a hard link and a symbolic link in Linux?"
Analyze a file in the current directory:
@app.py Explain what this script does and identify any potential bugs
Generate a commit message from your latest git changes:
git diff | gemini -p "Write a clear git commit message for these changes"
Search for large log files:
gemini -p "List all .log files in this directory that are larger than 50MB"
Useful Slash Commands for Daily Use
Once inside the interactive session, these slash commands improve your workflow:
/compress— Compresses the current session context to reduce token usage; essential for staying within free-tier limits on long sessions/help— Displays all available commands and flags/stats— Shows your current token usage and session duration/clear— Clears the screen and resets the context window/quit— Exits Gemini CLI cleanly (you can also pressCtrl+D)
Step 6: Configure Gemini CLI on Linux Mint 22 for Persistent Settings
To avoid re-exporting variables or re-entering preferences every session, you can store your Gemini CLI on Linux Mint 22 setup configuration in a .env file.
Create a directory for Gemini settings in your home folder:
mkdir -p ~/.gemini
Then create the environment file:
nano ~/.gemini/.env
Add your configuration inside the file. For example, if you use an API key:
GEMINI_API_KEY=your_api_key_here
Save the file with Ctrl+O, then Ctrl+X to exit nano. Gemini CLI automatically loads variables from ~/.gemini/.env at startup, so you do not need to export them manually in every terminal session.
How to Uninstall Gemini CLI
If you need to remove Gemini CLI from your Linux Mint 22 system, uninstall the global npm package:
sudo npm uninstall -g @google/gemini-cli
Verify the removal:
gemini --version
The terminal should return command not found. If you added a GEMINI_API_KEY export line to ~/.bashrc or ~/.zshrc, open that file in a text editor and delete that line manually.
Troubleshooting Common Gemini CLI Issues on Linux Mint 22
Even a clean installation can run into issues. Here are the most common problems and their solutions.
Problem 1: “command not found: gemini” After Installation
Cause: The npm global binary directory is not in your system’s PATH variable.
Fix: Close the current terminal and open a new session. If the problem continues, find the npm global binary directory and add it to your PATH:
npm bin -g
Copy the path that command returns, then add it to your shell config:
echo 'export PATH="$PATH:/path/from/above"' >> ~/.bashrc
source ~/.bashrc
Problem 2: Node.js Version Error on First Launch
Cause: Node.js 18 is still installed. This happens if the NodeSource repository was not added correctly in Step 2.
Fix: Check your current Node.js version with node -v. If it shows v18.x.x, re-run the NodeSource setup script and reinstall:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
Problem 3: Free Tier Rate Limit Error
Cause: You have hit the 1,000 requests/day or 60 requests/minute cap on the Gemini 2.5 Pro free tier.
Fix: Wait for the quota to reset (daily limits reset every 24 hours). For immediate relief, switch to the faster Flash model:
gemini -m gemini-2.5-flash
Alternatively, obtain a paid API key from Google AI Studio for higher throughput.
Problem 4: Authentication Loop or Login Not Completing
Cause: The browser did not complete the OAuth flow, possibly due to a VPN, firewall, or a browser session that expired mid-flow.
Fix: Copy the full URL displayed in the terminal manually into a browser where you are already logged into your Google account. Disable any VPN or proxy temporarily and ensure your browser can reach Google’s authentication endpoints.
Problem 5: Gemini CLI Is Slow to Start
Cause: Using the npx method instead of the global npm installation re-downloads the package on every launch.
Fix: Switch to the global installation if you have not already:
sudo npm install -g @google/gemini-cli
After switching, the gemini command starts almost instantly on every run.
Congratulations! You have successfully installed Gemini CLI. Thanks for using this tutorial for installing the latest version of Gemini CLI on Linux Mint 22. For additional help or useful information, we recommend you check the official Google Gemini website.