How to Install Grok CLI (Windows / Mac / Linux)

This guide shows how to install Grok CLI (the grok command), which lets you use Grok Build, xAI's coding agent, in the t…

WindowsmacOSUbuntuGrok CLI 1.0x64arm64About 6 min

This guide shows how to install Grok CLI (the grok command), which lets you use Grok Build, xAI's coding agent, in the terminal, on Windows PowerShell, macOS, and Ubuntu, and how to sign in. It also covers updating, uninstalling, and fixing terminal display problems.

1. Requirements

  • One of Windows (x64 or ARM64), macOS (Apple Silicon or Intel), or Linux such as Ubuntu (x86_64 or arm64)
  • A Grok account (you sign in with a browser the first time you run it) or an xAI API key
  • An internet connection

Grok CLI is installed with a single install script and does not need Node.js or Python.

2. Install on Windows (PowerShell)

Open PowerShell from the Start menu and run the command below. If you see PS at the start of the prompt, you are in PowerShell.

irm https://x.ai/cli/install.ps1 | iex

The install script puts grok.exe in the %USERPROFILE%\.grok\bin folder and adds that folder to the front of your user PATH. The change also applies right away to the PowerShell window you installed from, so you don't need to reopen it. When the installation finishes, it shows the installed version and location, such as Grok 1.0.70 installed to …\grok.exe.

Check the installed version with the command below. If a version number appears, it is installed.

grok version

3. Install on macOS

Open Terminal and run the install script. On an Apple Silicon Mac, it installs the Apple Silicon files even from a terminal opened with Rosetta.

curl -fsSL https://x.ai/cli/install.sh | bash

grok is installed to ~/.grok/bin/grok, and the actual files are stored in the ~/.grok/downloads folder. The install script adds a PATH line to your shell configuration file (~/.zshrc for zsh, ~/.bashrc for bash). When you see Restart your terminal, then run 'grok' or 'agent' to get started! on the last line, open a new terminal and run it.

grok version

4. Install on Ubuntu

Use the same install script as on macOS. The script downloads files with curl or wget. If you don't have curl, install it first with sudo apt install curl.

curl -fsSL https://x.ai/cli/install.sh | bash

If you use bash, a PATH line is added to ~/.bashrc. To use it right away in the terminal where you installed it, reload ~/.bashrc. There is no output. You can also close and reopen the terminal or reconnect over SSH.

source ~/.bashrc
grok version

5. First run and sign-in

Go to the project folder you want to work in and run grok. On the first run, a browser opens for sign-in; once you finish signing in, you can start working right away in the terminal.

cd your-project
grok

To start, you can ask for an overview of the project, such as Explain this repo., or ask about a specific file by putting its path after @, such as @src/main.rs Walk me through this file.

To sign in on its own, run grok login.

grok login

Sign in on a server without a browser

Where you can't open a browser, such as on an Ubuntu server you connect to over SSH, use device code sign-in. Follow the instructions on the screen and sign in with a browser on another PC.

grok login --device-auth

You can also use an API key. If you put your xAI API key in the XAI_API_KEY environment variable and run it, it starts without browser sign-in. Replace xai-... below with your own key.

export XAI_API_KEY="xai-..."
grok

Your sign-in information is saved in ~/.grok/auth.json (%USERPROFILE%\.grok\auth.json on Windows). Signing out deletes the saved sign-in information.

grok logout

6. Update

The command below checks for a new version and installs it. To only check, add --check; to install a specific version, add the version, as in --version 1.0.70.

grok update

Running the install script again also updates it to the latest stable version.

7. Uninstall

The official documentation has no separate uninstall command. First sign out with grok logout, then delete the folder the install script created. This folder contains the executable, the settings file (config.toml), your sign-in information, and the shell completion files. This cannot be undone.

On macOS and Ubuntu, run the command below. Then remove the export PATH="$HOME/.grok/bin:$PATH" line that was added to ~/.zshrc or ~/.bashrc, along with the completion line below it.

rm -rf ~/.grok

In Windows PowerShell, run the command below. Then remove the %USERPROFILE%\.grok\bin entry from your user PATH in Settings › System › About › Advanced system settings › Environment Variables.

Remove-Item -Recurse -Force "$env:USERPROFILE\.grok"
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\grok"

8. Troubleshooting

Running /terminal-setup inside Grok CLI shows the features detected in your terminal, the clipboard connection status, and how to fix any problems.

The grok command is not found after installation

On macOS and Ubuntu, this happens because a terminal that was open before the installation cannot read the new PATH. Open a new terminal or run source ~/.bashrc (source ~/.zshrc for zsh). If the installation output showed an Add … to your PATH message, you need to add export PATH="$HOME/.grok/bin:$PATH" to your shell configuration file yourself.

Error: Grok is not yet available for your system

This message appears when you install on an unsupported operating system or CPU. The install script supports only x86_64 (x64) and ARM64 on Windows, macOS, and Linux.

Colors on the screen look wrong

Add export COLORTERM=truecolor to your shell configuration file. If you use it inside tmux, also add set -g default-terminal "tmux-256color" and set -as terminal-features ",*:RGB" to ~/.tmux.conf and reload it with tmux source-file ~/.tmux.conf.

Copied text does not go to the clipboard

In iTerm2, turn on Applications in terminal may access clipboard in Settings › General › Selection. If you connect over SSH from the default macOS Terminal app, copies made on the remote machine do not reach your computer's clipboard. In that case, connect by putting grok wrap in front of the connection command, as in grok wrap ssh user@host (experimental feature).

Shift+Enter does not insert a new line

The built-in terminals in VS Code, Cursor, Windsurf, and Zed cannot tell Shift+Enter from Enter. In these terminals, use Alt+Enter to insert a new line. In WezTerm, add config.enable_kitty_keyboard = true to wezterm.lua and restart it.