AI

Cursor CLI (cursor-agent) Cheat Sheet: Commands, Flags, MCP (PDF)

Cursor CLI runs Cursor’s coding agent in a terminal, with the same rules, MCP servers and models you already use in the editor. It works over SSH and in CI too. The command is now agent, and the installer still adds a cursor-agent symlink next to it, so older scripts keep running.

Original content from computingforgeeks.com - post 180137

This cheat sheet covers install, login, headless print mode, models, rules files, MCP and permissions. We ran the commands on this page in November 2026 on Ubuntu 26.04 with Cursor CLI 2026.11.10, on a lab VM with no Cursor account, so anything that needs a login stops at the authentication error we show you. What a signed-in run returns, and the macOS and Windows installers, are marked as coming from Cursor’s docs.

Cursor CLI Cheat Sheet (Quick Reference)

We ran nearly every command row below on the lab VM (agent persist only as persist list, and agent ls needs a real terminal); rows that need an account stopped at an authentication error, and the flags also match agent --help on the same build. Cursor ships a new build every few days, so treat agent --help as the final word when a flag here disappears. The sections after the tables show the real output and explain the parts that tripped us up, such as the MCP approval step and the sandbox on Ubuntu.

Install and update

CommandWhat it does
curl https://cursor.com/install -fsS | bashInstall on Linux, macOS or WSL into ~/.local/bin
irm 'https://cursor.com/install?win32=true' | iexInstall on native Windows from PowerShell
agent --versionPrint the installed build
agent aboutVersion, latest build, model, shell and account
agent about --format jsonThe same details as JSON for scripts
agent updateUpdate now (the CLI also updates itself)

Sign in and accounts

CommandWhat it does
agent loginSign in through the browser
NO_OPEN_BROWSER=1 agent loginPrint the sign-in link instead of opening a browser
agent statusShow login state (alias: agent whoami)
agent status --format jsonLogin state as JSON
agent logoutSign out and clear stored tokens
export CURSOR_API_KEY=your-api-key-hereAuthenticate scripts and CI with a user API key
agent --api-key your-api-key-herePass the key for one run (lands in shell history)
agent team listList the teams on the account
agent team switchSwitch the active team

Start and resume chats

CommandWhat it does
agentOpen the interactive agent in the current folder
agent "fix the failing test"Start with an initial prompt
agent lsPick a previous chat to resume
agent resumeResume the latest chat
agent --continueContinue the previous session
agent create-chatCreate an empty chat and print its ID
agent persistStart a session that survives SSH disconnects
agent persist listList persistent sessions to attach or stop
agent -w feature-xWork in a new git worktree under ~/.cursor/worktrees
agent --add-dir ../shared-libAdd a second workspace root

Print mode (headless)

CommandWhat it does
agent -p "summarise this repo"Run one prompt, print the answer, exit
agent -p --output-format json "..."Print the result as JSON
agent -p --output-format stream-json "..."Stream events as NDJSON
--stream-partial-outputEmit text deltas (stream-json only)
agent -p --force "..."Allow commands unless denied (alias –yolo)
--trustTrust the workspace without a prompt
--approve-mcpsApprove every configured MCP server
--workspace ~/demoRun against another directory

Models and modes

CommandWhat it does
agent modelsList the models your account can use
agent --list-modelsSame list, then exit
agent --model gpt-5Pick a model for this run
agent --planStart in read-only plan mode
agent --mode askStart in read-only Q&A mode
agent --auto-reviewAuto-run safe calls, ask about the rest

Permissions and sandbox

Command or tokenWhat it does
~/.cursor/cli-config.jsonGlobal settings and permissions
.cursor/cli.jsonProject permissions only
Shell(git)Match a shell command by its base name
Read(src/**)Match file reads by glob
Write(**/*.key)Match file writes by glob
WebFetch(docs.github.com)Match web fetches by domain
Mcp(datadog:*)Match MCP tools as server:tool
agent sandbox enableRun agent commands in the sandbox
agent sandbox disableBack to allowlist mode (default)
agent sandbox run touch notes.txtTest one command inside the sandbox
agent sandbox run --network -- curl -sI https://example.comSandboxed command with network on

MCP servers and rules

Command or pathWhat it does
.cursor/mcp.jsonProject MCP servers (global: ~/.cursor/mcp.json)
agent mcp listShow each server and its state
agent mcp enable filesystemApprove a server so it loads
agent mcp list-tools filesystemList a server’s tools and arguments
agent mcp disable filesystemStop loading a server
agent mcp login githubSign in to a remote MCP server that needs a login
.cursor/rules/*.mdcProject rules with frontmatter
AGENTS.mdPlain markdown instructions, root or subfolder
agent generate-ruleCreate a rule interactively (alias: agent rule)

Slash commands inside a chat

Slash commandWhat it does
/modelSwitch the model
/planSwitch to plan mode
/askSwitch to ask mode
/resumeOpen an earlier chat
/clearStart a new chat (also /new)
/summarizeCompress the context (also /compress)
/rewindRoll the chat back to an earlier point
/shellRun a shell command from the chat
/mcp listManage MCP servers
/run-everythingToggle auto-run of every tool call
/sandboxSandbox settings
/configOpen settings
/quitLeave the CLI (also /exit)

Keyboard shortcuts

KeysWhat it does
Shift+TabRotate Agent, Plan and Ask modes
Shift+EnterNew line in the prompt (or Ctrl+J)
Ctrl+RReview the agent’s changes
@Add files or folders as context
&Hand the chat to a Cloud Agent (start of message)
Ctrl+DExit (press twice)

The slash commands and shortcuts come from Cursor’s slash command and usage docs. Without an account, plain agent opens a screen that says only “Press any key to log in…”, so we could not reach a chat to type them. Everything else in the tables was checked against the build’s own help output, so those rows match what the binary accepts today. If a slash command is missing on your machine, run /help inside a chat, since the list changes with almost every release.

How do you install Cursor CLI on Linux and macOS?

One script installs Cursor CLI on Linux, macOS and WSL, and it needs no root because everything lands in your home directory. It downloads the package for your architecture into ~/.local/share/cursor-agent/versions/ and creates two symlinks in ~/.local/bin. Run it as the user who will use the agent:

curl https://cursor.com/install -fsS | bash

On our Ubuntu 26.04 VM the installer detected linux/x64, pulled the matching tarball and finished with a reminder about PATH. The download URL shows the build it picked, which helps when two machines behave differently.

✓ Detected linux/x64
â–¸ Creating installation directory...
✓ Directory created
â–¸ Downloading Cursor Agent package...
  Download URL: https://downloads.cursor.com/lab/2026.11.10-731fb78/linux/x64/agent-cli-package.tar.gz
✓ Package downloaded and extracted
â–¸ Finalizing installation...
✓ Package installed successfully
â–¸ Creating bin directory...
✓ Bin directory ready
â–¸ Creating symlinks to agent executable...
✓ Symlink created

✨ Installation Complete!

Ubuntu’s default ~/.profile only adds ~/.local/bin to PATH when the folder exists at login, and a fresh account does not have it yet. Skip this step and the install looks broken, because agent returns “command not found” until your next login. Add the folder to ~/.bashrc yourself so new shells find it (use ~/.zshrc on macOS):

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Both names point to the same launcher, which you can confirm with a listing of the bin folder:

ls -l ~/.local/bin

So cursor-agent is not a separate tool or an older binary. It is a second symlink to the current version, which means scripts written for the old name get the same build and the same flags. Both links move to the new version folder when the CLI updates itself.

lrwxrwxrwx 1 harrison harrison 81 Nov 11 07:03 agent -> /home/harrison/.local/share/cursor-agent/versions/2026.11.10-731fb78/cursor-agent
lrwxrwxrwx 1 harrison harrison 81 Nov 11 07:03 cursor-agent -> /home/harrison/.local/share/cursor-agent/versions/2026.11.10-731fb78/cursor-agent

Plan for disk space on small VMs and CI runners. The install directory measured 538 MB on our VM, because each version folder ships its own Node runtime, ripgrep and the sandbox helper. On Windows, Cursor’s installation page gives a PowerShell one-liner, irm 'https://cursor.com/install?win32=true' | iex, which we did not test.

Both symlinks and the size check from our Ubuntu 26.04 VM:

Cursor CLI agent and cursor-agent symlinks in ~/.local/bin and a 538 MB install directory on Ubuntu 26.04

A new build lands in its own folder under versions/ and both links are repointed to it. The install script does not delete older folders, so check that directory now and then on a runner with a small disk.

Check the install with the version flag and agent about, which also tells you whether a newer build exists and which account is signed in:

agent --version
agent about

A working install looks like this. “Not logged in” is expected until you run agent login, and “up to date” means agent update has nothing to fetch. “Subscription Tier Unknown” only reflects the missing login, so it changes to your plan once you sign in.

Cursor CLI agent --version, cursor-agent --version and agent about output on Ubuntu 26.04

Before you move on, check these on your own machine:

  • agent --version prints a dated build such as 2026.11.10-731fb78.
  • command -v agent resolves to a path under ~/.local/bin.
  • agent about shows “(up to date)” next to the latest build.

How do you log in on a server without a browser?

Use NO_OPEN_BROWSER=1 agent login on an SSH session and open the printed link on any machine where you are signed in to Cursor. The CLI waits for that browser step to finish, so leave the command running while you approve it. The help text for agent login names this variable as the switch that stops it from opening a browser, which you want on any box with no desktop.

NO_OPEN_BROWSER=1 agent login

The link carries a one-time challenge, so treat it like a password until you have used it. We redacted both values here.

Starting login process...
Authenticating with Cursor...
Waiting for browser authentication...
Open a browser and navigate to this link: https://cursor.com/loginDeepControl?challenge=REDACTED&uuid=REDACTED&mode=login&redirectTarget=cli&supportsSelectedTeamLogin=true

For scripts and CI, skip the browser and use a user API key from the Cursor dashboard under API Keys. A key works without any stored login, so a fresh runner can start a job with nothing but the secret. Export it once per shell, or store it as a secret in your CI system and map it to CURSOR_API_KEY:

export CURSOR_API_KEY="your-api-key-here"

A wrong key fails before any request reaches a model, and the message even names where the key came from. That matters when both a stored login and an exported key exist, because the environment variable is the one the CLI used. This is what we got with a deliberately bad value.

âš  Warning: The provided API key is invalid.
The API key was loaded from the CURSOR_API_KEY environment variable.
Please check you have the right key, create a new one, or authenticate without it.

A CI job should check the login before it spends minutes on a prompt. The JSON form of agent status is easy to test with jq.

agent status --format json

On our account-less VM it reported this:

{
  "status": "unauthenticated",
  "isAuthenticated": false,
  "hasAccessToken": false,
  "hasRefreshToken": false,
  "message": "Not logged in"
}

With no account, isAuthenticated is false and both token fields are false too. Fail the job when agent status --format json | jq -e .isAuthenticated exits non-zero, because every later step would stop with an authentication error anyway, and one early failure is easier to read in a CI log than a stack of identical errors.

Here is the whole headless login path from one session: the printed link, the JSON status, the jq check returning false, and the warning a bad key produces.

Cursor CLI NO_OPEN_BROWSER agent login link, agent status JSON, jq check and invalid CURSOR_API_KEY warning

The jq -e line exits 1 on false, which is exactly what a CI step needs to fail fast.

Print mode, -p or --print, runs one prompt without the interactive screen, prints the answer and exits. That makes it the mode for cron jobs, git hooks and pipelines, and the docs say the CLI also switches to it on its own when stdout is not a terminal or stdin is piped. The help text is blunt about the risk: print mode “has access to all tools, including write and shell”, so a prompt can edit files and run commands in the workspace.

A typical headless call trusts the workspace, picks an output format and names the folder explicitly, so the job never stops on a prompt it cannot answer. The --trust flag matters most here, because a new folder otherwise asks for trust and a job has nobody to say yes.

agent -p --trust --output-format json --workspace ~/demo "List the TODO comments in this repo"

Without a login, print mode stops at once with exit code 1, which is the failure your pipeline sees when the secret is missing or expired. Note that the message mentions only CURSOR_API_KEY, so check the secret name in your CI settings first.

Error: Authentication required. Please run 'agent login' first, or set CURSOR_API_KEY environment variable.

Every print-mode variant we tried, plus agent models and the bracketed --model form from the next section, stopped at an authentication error:

Cursor CLI agent -p, json output, models and --model commands returning Authentication required without a login

Pick the output format by what reads the result. The --output-format flag only works together with --print.

  • text is the default and prints only the final answer, which suits a log or a PR comment.
  • json prints one result object with result, is_error and duration_ms when the run ends, which suits a script that checks a field.
  • stream-json prints one JSON event per line as the run goes, and --stream-partial-output adds the text as it is generated.

According to Cursor’s output format reference, the stream starts with a system init event (model, working directory, session ID), then user, assistant and tool_call events, and ends with a result event. A failed run writes no JSON at all, only an error on stderr and a non-zero exit code, which matches what we saw: --output-format json without a login printed the same plain “Authentication required” line. So check the exit code before you parse anything. We could not capture a successful stream on an account-less VM, so test one run against your parser before you rely on field names.

Shell commands the agent wants to run still follow your permission rules in print mode. Add --force (alias --yolo) only when the job runs in a throwaway container, because it allows every command that a deny rule does not block. For anything shared, list the commands the job needs in .cursor/cli.json instead, as shown in the permissions section.

How do you choose a model in Cursor CLI?

Pass --model on the command line, or type /model inside a chat, and the default is “Auto” until you change it. The model list depends on your plan and team, so the CLI asks Cursor’s servers for it, and neither agent models nor --list-models works before login:

agent models

Unlike print mode, this error also names --auth-token and CURSOR_AUTH_TOKEN as ways in. Neither appears in agent --help, so treat the API key as the supported route for scripts.

Error: Authentication required. Run 'agent login', pass --api-key/--auth-token, or set CURSOR_API_KEY/CURSOR_AUTH_TOKEN.

Once you are signed in, copy the exact model ID from that list rather than guessing, because IDs change as Cursor adds and retires models, and the list also depends on your plan. The help text shows two forms: a plain ID such as gpt-5 or sonnet-4-thinking, and a parameterized one with quoted bracket overrides for context size and effort:

agent --model 'claude-opus-4-8[context=1m,effort=high,fast=false]' -p "Review the last commit"

On our account-less VM this command stopped at the same “Authentication required” line as every other prompt, before the model was checked, so we could not see a model answer. Keep the single quotes around a bracketed ID, because bash and zsh treat square brackets as a filename glob. Modes are separate from models: --plan and --mode ask keep the agent read-only whichever model answers, and Shift+Tab rotates between Agent, Plan and Ask inside a chat.

Where do Cursor CLI rules files go?

Project rules live in .cursor/rules/ as .mdc files, and the CLI reads the same rules the editor does. A plain .md file in that folder is ignored, so put free-form instructions in AGENTS.md at the repo root or in a subfolder instead. Cursor’s 2026.10.22 changelog says nested AGENTS.md files now apply as soon as the agent edits a file in that folder.

Create the folder and open a rule file for shell scripts. Small rules scoped by glob beat one large always-on file, since only the matching ones reach the model.

mkdir -p .cursor/rules
vim .cursor/rules/shell.mdc

The frontmatter decides when the rule loads. This one attaches only when a file under scripts/ is in context.

---
description: Shell script conventions
globs: scripts/**/*.sh
alwaysApply: false
---
- Start every script with set -euo pipefail.
- Quote every variable expansion.

The three frontmatter fields combine into four behaviours, per Cursor’s rules docs:

  • A rule with alwaysApply: true loads in every chat.
  • A rule with globs and alwaysApply: false loads when a matching file is in context.
  • A rule with only a description loads when the agent decides it is relevant.
  • A rule with none of them loads only when you @-mention it.

Pick the description-only form for advice the agent needs now and then, and keep alwaysApply: true for the few rules that must hold in every chat. Next, open AGENTS.md at the repo root for the instructions that apply everywhere:

vim AGENTS.md

Keep it short and specific, because every line costs context on every request.

# Project notes for agents
- Run npm test before proposing a commit.
- Never edit files under vendor/.

If you already keep an AGENTS.md for Codex CLI, Cursor picks up the same file, so one set of instructions serves both agents. Cursor’s CLI docs say it also reads a CLAUDE.md at the project root, the file the Claude Code cheat sheet covers. Both are applied as rules, so if a repo keeps the same text in each, the agent gets it twice. Keep the shared instructions in only one of them.

To draft a rule with help from the agent, run agent generate-rule and describe what the rule should do. It opens a prompt even without a login, while plain agent stops at the login screen; both are below, with the two rule files from this section:

Cursor CLI interactive agent asking to log in, the generate-rule prompt and the project rules files

We stopped the rule prompt at that first question, because writing the rule itself goes through the model and needs an account.

How do you add an MCP server to Cursor CLI?

Cursor CLI has no mcp add command. You describe servers in .cursor/mcp.json for one project or ~/.cursor/mcp.json for all of them, the same files the editor uses, and the CLI only manages approval and status. Most reference servers start through npx, so install Node.js first if the machine lacks it:

sudo apt install -y nodejs npm

Then open the project file:

vim .cursor/mcp.json

This entry starts the reference filesystem server with npx and limits it to the project folder. Replace /home/harrison/demo with the absolute path of your own project, because JSON does not expand ~ or $HOME and a wrong path also ends as “Connection failed”. Per the docs, the CLI reads project, then global, then nested config, the same order the editor uses.

{ "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/harrison/demo"] } } }

A new server is never loaded until you approve it, so the first agent mcp list reports “not loaded (needs approval)” and list-tools refuses with “MCP server “filesystem” has not been approved”. Approve it, then list its tools:

agent mcp enable filesystem
agent mcp list
agent mcp list-tools filesystem

After approval the server reports “ready” and the CLI prints all 16 tools with their argument names. That list is the quickest way to write precise Mcp(filesystem:read_file) permission rules, because the tool names must match exactly. We captured these from a script, so they print as plain lines; the docs say agent mcp list opens an interactive menu when you run it in a real terminal.

Cursor CLI agent mcp list, enable and list-tools showing 16 filesystem MCP server tools

Our first attempt failed differently. The VM had no Node.js yet, so npx did not exist and agent mcp list printed only filesystem: Error: Connection failed, without naming the missing command. If you see that line for a stdio server, run its command by hand first. Installing nodejs and npm from the Ubuntu archive, as shown at the start of this section, fixed it.

To turn a server off without deleting its config, disable it. agent mcp list then shows filesystem: disabled, and the CLI stops asking for approval. agent mcp login only works on a server name that exists in one of the mcp.json files; on our VM, agent mcp login github ended with “MCP client “github” not found in config” because we never defined it.

agent mcp disable filesystem

In print mode there is nobody to approve a server, so either run agent mcp enable once on the runner or add --approve-mcps to the command. The second option approves every server in the file, including any that a pull request adds to .cursor/mcp.json, so we would only use it on repositories where you review that file.

How do Cursor CLI permissions work?

Permissions are allow and deny lists of tokens such as Shell(git) or Write(src/**), and a deny always wins over an allow. Global rules live in ~/.cursor/cli-config.json, which the CLI creates on first run. A project can add its own in .cursor/cli.json, and that file can only hold permissions.

Look at the global file first, because the defaults explain why the agent asks before almost every command.

cat ~/.cursor/cli-config.json

A fresh install allows only Shell(ls), runs in allowlist approval mode with the sandbox off, and attributes commits and PRs to the agent. In practice that means every command other than ls waits for you in a chat, so a long task stalls until you answer:

{
  "permissions": {
    "allow": [
      "Shell(ls)"
    ],
    "deny": []
  },
  "version": 1,
  "editor": {
    "vimMode": false
  },
  "display": {
    "showLineNumbers": false,
    "showThinkingBlocks": false,
    "showStatusIndicators": false,
    "showStatusLineRunningTime": false,
    "mode": "zen"
  },
  "notifications": true,
  "hints": true,
  "modelSlashCommands": true,
  "steering": true,
  "rewind": true,
  "hasChangedDefaultModel": false,
  "exploreSubagentModel": "default",
  "network": {
    "useHttp1ForAgent": false
  },
  "approvalMode": "allowlist",
  "autoAcceptWebSearch": false,
  "sandbox": {
    "mode": "disabled",
    "networkAccess": "user_config_with_defaults"
  },
  "runEverythingSettingsPromptStreak": 0,
  "attribution": {
    "attributeCommitsToAgent": true,
    "attributePRsToAgent": true
  }
}

Those two attribution keys add a “Made with Cursor” trailer to commits and a footer to PRs, according to the configuration docs. Set both to false if your repo forbids tool attribution, because the agent will otherwise add it to every commit it writes.

A project file is the better place for command rules, because it travels with the repo and applies to everyone who runs the agent there. Open .cursor/cli.json:

vim .cursor/cli.json

This set lets the agent run git and npm and edit src/, while blocking rm, secrets and key files.

{
  "permissions": {
    "allow": ["Shell(git)", "Shell(npm)", "Read(src/**)", "Write(src/**)"],
    "deny": ["Shell(rm)", "Read(.env*)", "Write(**/*.key)"]
  }
}

A broken JSON file is easy to miss, so validate it before a pipeline depends on it. python3 -m json.tool .cursor/cli.json printed the file back cleanly on our VM. Then check these points:

  • Every token uses one of the five types: Shell, Read, Write, WebFetch or Mcp.
  • Every secret path you care about appears in deny, not just missing from allow.
  • Every Shell() entry names a command base, such as git, or a command:args glob such as curl:*.

We could not watch the agent obey these rules without an account, so the matching behaviour above comes from Cursor’s permissions reference. The token syntax is close to the one in the Gemini CLI cheat sheet and the OpenCode CLI cheat sheet, but the file names differ, so do not copy a settings file between tools.

Why does the Cursor CLI sandbox fail on Ubuntu 26.04?

The sandbox fails on a stock Ubuntu 26.04 install because Ubuntu blocks unprivileged user namespaces through AppArmor, and both of Cursor’s Linux sandbox backends need one. Nothing warns you at install time, so the first sign is a failed command the moment you turn the sandbox on. The kernel setting shows the restriction.

cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns

A value of 1 means the restriction is on, which is how our Ubuntu 26.04 cloud image shipped:

1

If yours prints 0, the restriction is off and the AppArmor fix below does not apply, so check this value before you change anything.

Error: “Sandbox policy ‘workspace_readwrite’ is not supported on this system”

Any sandboxed command shows it, including a harmless touch inside the workspace, so the test needs nothing more than an empty folder.

agent sandbox run touch notes.txt

The error is long, but the reason sits near the end. Landlock and Bubblewrap both fail on the same uid_map write.

Failed to execute command: SandboxUnsupportedError: Sandbox policy 'workspace_readwrite' is not supported on this system. Ensure the sandbox helper binary is available, or use 'insecure_none'. Reason: Linux preflight failed with exit code 2 (unsupported kernel features). stderr: Error: Failed to resolve Linux sandbox backend: Unsupported sandbox configuration: Linux auto backend selection failed. Landlock error: Unsupported sandbox configuration: IO error: Step 1-2/7 (user namespace) failed: IO error: Failed to write /proc/self/uid_map (mapping UID 0 -> 1001): Operation not permitted (os error 1) (errno 1). Bubblewrap error: Unsupported sandbox configuration: IO error: Bubblewrap namespace setup failed: IO error: Failed to write /proc/self/uid_map (mapping UID 0 -> 1001): Operation not permitted (os error 1) (errno 1)
Error: command failed unexpectedly.

agent sandbox enable fails the same way, with a shorter “Sandbox is not available on this system … possibly due to AppArmor configuration” message. The capture above comes from an Ubuntu 26.04 cloud image that ships the bubblewrap package. On an image without it, the Bubblewrap half of the error says instead that no root-owned bwrap was found on PATH. Installing bubblewrap changes that message but does not fix anything, because the namespace write is still denied.

What worked was an AppArmor profile that grants user namespaces to Cursor’s own helper, cursorsandbox, and nothing else. We tested it with and without bubblewrap installed, and the sandbox worked both times. On a laptop or a single-user runner this is a reasonable trade. On a shared host, think twice: the profile matches a path under each user’s home, so any local user who places a binary there gets user namespaces, which undoes much of Ubuntu’s restriction. Create the profile:

sudo vim /etc/apparmor.d/cursor-sandbox

The path glob covers installs under /home and every version folder (add a second line for /root or a runner home elsewhere), so the profile still matches after agent update moves the helper into a new folder.

abi <abi/4.0>,
include <tunables/global>

profile cursor-sandbox /home/*/.local/share/cursor-agent/versions/*/cursorsandbox flags=(unconfined) {
  userns,
}

Load it, then repeat the same test command:

sudo apparmor_parser -r /etc/apparmor.d/cursor-sandbox
agent sandbox run touch notes.txt

The policy block prints again, and this time it ends with a success line.

=== COMMAND SUCCESS ===
Exit code: 0

The fix and the retry on our VM, with the policy the sandbox applied:

Cursor CLI agent sandbox run succeeding on Ubuntu 26.04 after loading the cursor-sandbox AppArmor profile

A working sandbox should also say no to the things it exists to block. We ran three more checks after the fix, and each one behaved as the default workspace_readwrite policy promises:

  • agent sandbox run touch /etc/demo.conf fails with “Permission denied”, because writes outside the workspace are blocked.
  • agent sandbox run -- curl -sI -m 5 https://example.com fails with exit code 6, because the default network policy is deny and DNS does not resolve.
  • The same curl with --network returns HTTP/2 200.

The /etc write is the check worth keeping in the smoke test on a runner, because a denied write proves the policy is enforced and not just printed:

Cursor CLI sandbox denying touch /etc/demo.conf with Permission denied under the workspace_readwrite policy

Put -- before any command that has its own flags. Without it, agent sandbox run curl -sI -m 5 https://example.com stops with error: unknown option '-sI', because the CLI tries to parse curl’s flags as its own. Once the test passes, agent sandbox enable sets "mode": "enabled" in cli-config.json, and the agent’s shell commands run inside the sandbox from then on.

How do you uninstall Cursor CLI?

There is no uninstall subcommand. The installer writes the version folder and two symlinks, and the CLI creates ~/.cursor on first run, so removing those is enough. ~/.cursor holds cli-config.json and per-project data. The editor uses that folder too, so leave it out of the command if Cursor’s desktop app is installed on the same account:

rm -rf ~/.local/share/cursor-agent ~/.local/bin/agent ~/.local/bin/cursor-agent ~/.cursor

This is the removal on our VM, with the AppArmor profile unloaded first and the final lookup coming back empty:

Uninstall Cursor CLI by unloading the AppArmor profile and removing the agent files

Afterwards command -v agent returned nothing on our VM. If you added the AppArmor profile, unload it with sudo apparmor_parser -R /etc/apparmor.d/cursor-sandbox before deleting the file, and delete the PATH line from ~/.bashrc if nothing else lives in ~/.local/bin. If you are still choosing an editor rather than a CLI, our Cursor vs Windsurf vs Kiro comparison covers the desktop side.

Setup checklist for a new machine

Run these in order on a new laptop or CI runner. Each step has a check you can see, so you know it worked before you trust the agent with a real repo:

  1. Install with the curl script and confirm agent --version prints a build.
  2. Add ~/.local/bin to PATH and confirm a new shell finds agent.
  3. Sign in with agent login or export CURSOR_API_KEY, then confirm agent status no longer says “Not logged in”.
  4. Run agent models and note the exact ID you want for --model.
  5. Add .cursor/cli.json with allow and deny lists, and confirm it parses with python3 -m json.tool.
  6. Approve each MCP server with agent mcp enable and confirm agent mcp list shows “ready”.
  7. On Ubuntu, add the AppArmor profile and confirm agent sandbox run touch notes.txt ends with “COMMAND SUCCESS”.

The sandbox step is the one most people skip, and it is the one that makes print mode safe enough to leave running on a shared runner. Steps 3 and 4 need a Cursor account, and the full flag reference stays one command away in agent --help.

Keep reading

Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) AI Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) Open Source LLM Comparison Table (2026) AI Open Source LLM Comparison Table (2026) Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) AI Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) Dual GPU LLM Build: PCIe x8/x8 vs x16/x4, PSU and Cooling AI Dual GPU LLM Build: PCIe x8/x8 vs x16/x4, PSU and Cooling MCP vs RAG vs Agent Skills: When to Use Each AI MCP vs RAG vs Agent Skills: When to Use Each NVIDIA RTX PRO 6000 vs RTX 5090 for Local AI AI NVIDIA RTX PRO 6000 vs RTX 5090 for Local AI

Leave a Comment

Press ESC to close