Applies to: ChatGPT desktop app for Linux (preview), Codex CLI 0.162.1, the OpenAI API, llm 0.36 and Ollama; terminal steps tested on Ubuntu 26.04 LTS

You can use ChatGPT on Linux in four ways. In any browser at chatgpt.com. With the official ChatGPT desktop app for Linux, which OpenAI offers as a preview for Ubuntu 24.04 and 26.04, Debian 13, Fedora 43 and 44 and Arch Linux. In the terminal with Codex CLI, OpenAI’s command-line tool, which signs in with your ChatGPT account and also works on a server without a desktop. Or from scripts through the OpenAI API. If you would rather not send anything to a cloud service, run an open model on your own machine or server with Ollama.

ChatGPT desktop app for Linux

According to OpenAI’s install guide, the preview app comes as a .deb package for Ubuntu and Debian and an .rpm package for Fedora, each for x64 and ARM64. Check which one you need with uname -m (x86_64 means x64, aarch64 means ARM64). Download the package from OpenAI’s Linux app page, then install it from the download folder:

# Ubuntu 24.04 or 26.04, Debian 13
sudo apt install ./chatgpt_amd64.deb
# Fedora 43 or 44
sudo dnf install ./chatgpt.x86_64.rpm

Start it from the applications menu or with chatgpt. The installer also adds OpenAI’s package repository, so the app updates with the rest of the system (sudo apt update && sudo apt install --only-upgrade chatgpt). Being a preview, it lacks some features of the Windows and macOS apps: OpenAI lists Computer Use as not yet available on Linux, and native Wayland support as experimental. It is a desktop program; on a headless server, use Codex CLI or the API below.

ChatGPT in the terminal: Codex CLI

Codex CLI is OpenAI’s open-source coding agent for the terminal. It answers questions, reads the files in your current folder and can propose and run commands. According to its README on GitHub, you install it on Linux with OpenAI’s installer or with npm:

curl -fsSL https://chatgpt.com/codex/install.sh | sh
# or, if you use Node.js
npm install -g @openai/codex

Lab output from Ubuntu 26.04 (shortened):

==> Installing Codex CLI
==> Detected platform: Linux (x64)
==> Resolved version: 0.162.1
...
==> PATH was added to /root/.profile
Codex CLI 0.162.1 installed successfully.
$ codex --version
codex-cli 0.162.1

The installer puts codex in ~/.local/bin of the user who runs it and adds that folder to the PATH in ~/.profile, so open a new terminal before the first run. Install it as the normal user you work with, not as root.

Run codex and choose Sign in with ChatGPT. The README says Codex is included in the ChatGPT Plus, Pro, Business, Edu and Enterprise plans; you can use an API key instead, which is billed separately at API rates.

On a server without a browser (a VPS over SSH), OpenAI’s documentation recommends the device code sign-in: it prints a link and a one-time code that you open on any other device.

codex login --device-auth
codex login status            # lab output before signing in: Not logged in
# or, with an API key kept in an environment variable:
printenv OPENAI_API_KEY | codex login --with-api-key

The sign-in is stored in ~/.codex/auth.json (or the system key store). OpenAI says to treat that file like a password: do not commit it to Git, paste it into a ticket or share it in chat.

Start it in the folder you want help with. A few patterns (options from codex --help and codex exec --help):

cd /etc/nginx
codex "nginx -t fails after my last change, find out why"   # interactive session
journalctl -u nginx -n 50 | codex exec --skip-git-repo-check "explain these errors"
codex --sandbox read-only --ask-for-approval on-request         # read-only sandbox, asks for approval

codex exec gives a one-off answer and adds piped text to the prompt. Outside a Git repository it stops with "Not inside a trusted directory and --skip-git-repo-check was not specified" (our lab), hence the extra option in folders such as /etc. The sandbox modes are read-only, workspace-write and danger-full-access. On a live server, start with read-only and read every command before you approve it. If sign-in or connections fail, codex doctor checks login, network and disk; in our lab it reported "no Codex credentials were found" before sign-in.

The OpenAI API from the command line

For scripts and automation, call the API directly. Create an API key in your OpenAI Platform account. According to OpenAI, API use is billed through that Platform account at API rates, separately from a ChatGPT subscription. Keep the key out of your shell history and out of files you share: read -rs reads it without showing it on screen.

read -rs OPENAI_API_KEY && export OPENAI_API_KEY
curl https://api.openai.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{"model": "MODEL", "input": "Explain what /etc/fstab does in two sentences."}'

Replace MODEL with a current model name from OpenAI’s model list. Without a valid key the API answers with an error instead of a reply; lab example:

$ curl -s https://api.openai.com/v1/models
{
  "error": {
    "message": "Missing bearer authentication in header",
    "type": "invalid_request_error",
...

A plain chat command for the shell: llm

If you only want to ask questions and pipe text in, without an agent that runs commands, the open-source llm tool (Apache 2.0, not made by OpenAI) is simpler. It uses your OpenAI API key, or local Ollama models through a plugin. We installed llm 0.36 and the llm-ollama 0.17.1 plugin on Ubuntu 26.04; the prompt examples are from its README:

sudo apt install pipx
pipx install llm
llm keys set openai                     # paste the API key when asked
llm "Explain chmod 750 in one line"
cat error.log | llm -s "What is the likely cause?"
llm install llm-ollama                  # adds your local Ollama models

Local AI in the terminal with Ollama

Ollama downloads open models and runs them on your own computer or server. With a local model your prompts stay on the machine, and you need no account or API key (Ollama also offers optional cloud models, which do send data out). According to Ollama’s documentation:

curl -fsSL https://ollama.com/install.sh | sh
ollama run gemma4          # downloads the model on first use, then opens a chat
ollama ls                  # models on disk
ollama ps                  # models loaded in memory
ollama rm gemma4           # delete a model

Small models answer on a CPU, slowly (see running lightweight AI models on a low-cost VPS); for larger models and quick replies you want a GPU with enough memory. Our Ollama guides cover the details:

Codex CLI can also use a local model: codex --oss uses an open-source provider, and --local-provider ollama picks Ollama (both in codex --help). Ollama’s documentation also offers ollama launch codex and recommends a context window of at least 64k tokens for Codex.

Which should you use?

  • Chatting on a Linux desktop: the browser or the ChatGPT desktop app.
  • Help with commands, configs and code in a terminal or over SSH: Codex CLI with your ChatGPT plan.
  • Scripts, cron jobs and automations: the OpenAI API with a key kept in an environment variable.
  • Private data, no per-request cost, or no internet: Ollama on your own hardware.

Whichever you use, review commands an AI suggests before you run them on a live server, and never paste passwords, private keys or customer data into a prompt. If you want a private model on your own server without doing the setup yourself, Ucartz offers private LLM installation (we install Ollama with a chat interface or API) and GPU dedicated servers.

Official documentation: Codex CLI on GitHub, Ollama on GitHub.

Was this answer helpful?

Still stuck? Open a ticket