Skip to main content
Linux AI Tools

Gemini CLI: Unleashing the Power of AI in Your Terminal

In this article, you'll learn how to install, use, and uninstall Google’s Gemini CLI to bring AI power directly into your Linux terminal.

Mead Naji

If you're a DevOps engineer, system administrator, or a seasoned Linux user, chances are most of your work revolves around the terminal, whether it's debugging, scripting, or managing systems. Now imagine combining that terminal power with AI. That’s exactly what Gemini CLI brings to the table: an AI-driven experience, right inside your terminal.

With AI tools evolving rapidly, Google has emerged as a major player with its Gemini model, offering powerful capabilities in various domains. Recently, Google released the open-source Gemini CLI, a command-line interface that integrates Gemini’s AI power directly into your terminal workflow.

That means you can now run interactive AI prompts, get help with code, automate tasks, and much more, all without leaving the command line.

In this guide, we’ll walk you through setting up and using Gemini CLI, with practical examples and real-world use cases tailored for Linux professionals and power users.

What is Gemini

Gemini is Google’s AI agent; you’ve probably used it on the web at some point, which works just like ChatGPT and other AI tools: you get a simple web interface where you can ask questions and get instant help.

But here’s the cool part: Google has now brought this AI power right into your terminal. Yep, no more switching to a browser. With the Gemini CLI, you can run AI queries directly from your command line, and the best part? It’s completely free for individual users.

That’s right, you get full access to Gemini 2.5 Pro, Google’s latest and most advanced AI model.

According to Google’s own site, you get:

  • 60 requests per minute
  • Up to 1,000 requests per day
  • At no cost

That’s a massive offering for developers, sysadmins, or anyone automating tasks in the terminal. Honestly, most users won’t even hit that daily limit.

To put this into perspective, a single request using Gemini 2.5 (with a 1 million token context window) would normally cost about $3. So yeah, getting all that power for free is kind of a big deal.

Key Features of Gemini CLI

  • You can feed real-time web pages into your queries as context, which gives the AI better, more accurate responses based on fresh data.
  • Gemini CLI supports the MCP server, which allows you to generate images and videos directly from the terminal.
  • This is where it really shines: you can integrate Gemini directly into your existing scripts and terminal workflows. Automate repetitive tasks, get AI-generated suggestions on the fly, or build smarter command-line tools.

Set up Gemini CLI in Linux

Now that you have an idea about what Gemini CLI offers, let's get started and learn how to set it up on our computer.

Before we start the installation, you need to make sure that you have Node.js installed on your machine. If not, install it first. The CLI is built using the TypeScript language, and we're going to use the Node Package Manager to install the tool.

Step 1: Install Node.js

The first step is to install Node.js in case you don’t have it, using the command:

For Ubuntu, Debian, or Linux Mint:

sudo apt install nodejs

For RHEL, Fedora, or CentOS:

sudo dnf install nodejs

Sometimes npm doesn’t come installed with Node.js, so you will need to install it separately using the command:

sudo apt install npm

Note: Sometimes, npm doesn’t come bundled with Node.js, so you might need to install it separately:

sudo apt install npm

Step 2: Install Gemini CLI

After you install Node.js and the Node Package Manager, you can install Gemini CLI with the following command:

npm install https://github.com/google-gemini/gemini-cli

Or, if you prefer to run it without installing globally, use npx:

npx https://github.com/google-gemini/gemini-cli

Having Trouble? Use the Latest Node.js Version

If the above commands don’t work for you, it’s likely because of an outdated Node.js version. The GitHub repo mentions a requirement for Node.js v18+, but some packages are deprecated in older versions.

The safest route is to install the latest stable Node.js version using the NodeSource script.

curl -fsSL https://deb.nodesource.com/setup_23.x -o nodesource_setup.sh

Then run it with root privileges:

sudo -E bash nodesource_setup.sh

Finally, install Node.js:

sudo apt-get install -y nodejs

This should install the latest version available (currently v23.11.1), along with npm and npx.

Step 3: Launch Gemini CLI

After the installation, you can start using the CLI by running gemini inside the terminal.

gemini

You will be prompted with a screen asking you to choose the theme you want to use; you can choose whatever you like.

Select the theme

Authenticate and Get Started with Gemini

Once you launch the Gemini CLI, the next step is authentication. It’ll ask you to choose how you want to sign in.

You’ve got a few options:

  • Google Account (easy and quick)
  • Gemini API Key (if you’ve set one up manually)
  • Vertex AI (for more advanced enterprise use)

For most users, the Google Account method is the simplest.

Authentication method

Choose the Google account and hit Enter. which will take you to the Gmail sign-in page. After signing in and accepting the permissions.

Gemini Access

Your account in Gemini CLI will be activated automatically, and you'll get a screen like this:

Gemini start screen

This means you are ready to use Gemini inside your terminal and get all the power of AI right from the command line.

The default Google Account sign‑in grants 60 requests per minute and 1,000 requests per day. If you ever need to switch models or bump those limits, create a key in Google AI Studio and export it:

export GEMINI_API_KEY="YOUR_API_KEY"

Add that line to ~/.bashrc (or ~/.zshrc) so it persists across sessions.

How to Use Gemini CLI

As we mentioned earlier, Gemini CLI is more than just an AI chatbot in your terminal; it’s a powerful assistant that can help with all sorts of tasks.

You can ask direct questions and get instant answers right in the terminal. For example, if you ask about Tecmint, you’ll get a result like this:

Ask gemini

Gemini uses Google Search in real-time to pull relevant information, so the answers are fresh and accurate. You can ask about anything: Linux commands, sysadmin tips, tech news, or even how to fix an error in your code.

Pass Files for Editing or Suggestions

One really handy feature is that you can pass files to Gemini - scripts, configs, source code, etc., and ask it to analyze or edit them.

This is perfect if you’re stuck while writing a script or debugging some code. Gemini can suggest fixes, refactor code, or even write missing parts.

To get help, use the shortcut /help and it will show you a menu like this with all possible commands:

Get help

As the image shows, there are a lot of tools that we can use inside the Gemini CLI.

Interactive Mode (Shell Mode)

Another mode that Gemini CLI offers is interactive mode, which you can enter by pressing !. You should get an interactive shell like this:

Enter the shell mode

After entering this mode, you can run bash commands inside the CLI just as you would in a regular shell, and you will get the output. For example:

Example of commands in shell mode

Here we run commands just like in the normal bash prompt.

Generate or Debug Code

One of the most useful features that the CLI offers is generating or debugging code when you're stuck on a task.

Let’s say, for example, we want to generate a shell script for installing different web development tools in order to set up a development environment. This environment would include Node.js, Golang, PostgreSQL, Postman, and VS Code.

The query would look something like this:

Create a script called install.sh that contains the necessary code to install Golang, Node.js, PostgreSQL, Postman, and VS Code. I'm using Ubuntu.
Generate bash script

Gemini will walk you through each step and ask for confirmation before applying any changes. Once you approve, it’ll run the necessary commands automatically.

With the power of Gemini and your terminal combined, you can get things done faster -whether it's scripting, troubleshooting, or automating your daily tasks.

If you're into AI tools for the command line or Linux in general, we've got a dedicated AI series just for that. Stick around and follow along to discover even more powerful tools.

Check out Gemini CLI on GitHub: https://github.com/google-gemini/gemini-cli

Uninstall Gemini CLI

If you ever decide you no longer need Gemini CLI, removing it is as straightforward as the installation; just make sure you follow the method that matches the way you installed it.

If you installed Gemini globally using npm (either with the -g flag or directly from the GitHub URL), simply run:

sudo npm uninstall -g @google/gemini-cli

Or if you installed it using the GitHub URL directly:

sudo npm uninstall -g gemini-cli

This command removes the executable from your system‑wide npm directory (usually ~/.npm-global/bin or /usr/local/lib/node_modules).

Any associated symlinks and shell completions are also removed, so the gemini command will no longer be available in your terminal.

If you used npx to run Gemini CLI without installing it globally, there’s nothing to uninstall; the CLI runs from a temporary cache and doesn’t persist. However, if you want to clear out any cached files immediately, use:

npm cache clean --force

Also, keep in mind that Gemini CLI stores its configuration and session data in a .gemini/ folder in your home directory. To completely wipe any saved settings or history, delete this folder:

rm -rf ~/.gemini

That’s it! Gemini CLI is now fully removed from your system. Of course, if you change your mind, reinstalling it is just a single command away.

Keep Learning with TecMint Pro

Want more than just quick tips? With TecMint Pro, you’ll unlock ad-free reading, premium content, downloadable resources, certification resources, and our weekly newsletter - all in one place.

Plan Regular Price Limited-Time Price What You Get
Sudo $75 / year $50 / year Get unlimited yearly access to all premium content and instant downloads of 8 Linux eBooks ($200 value).
Root $129 lifetime $99 one-time Get lifetime access and all 8 premium Linux eBooks ($200 value) with free lifetime updates.
🚨 Hurry! This offer is only available for a limited time, and only the first 100 members will get lifetime access at this discounted rate. After that, regular pricing returns.