In Juniper's networking devices, you cancel uncommitted changes by leaving configuration mode without committing: type exit to return to operational mode and answer no when the CLI asks whether to discard the candidate configuration. That covers a shared candidate configuration on Junos. If your "uncommitted changes" live in a private configuration database, a Named Configuration, or a commit script/index file, the exact command differs. Clearing an uncommitted edit is easy; doing it without wiping someone else's work or a committed config is the part that needs care.

The phrase "uncommitted changes" gets used loosely, and that ambiguity is where most accidents start. On a Junos device, configuration edits sit in a candidate configuration until a commit activates them. Multiple users can share that candidate, so your uncommitted edits may share space with edits from other sessions. Separately, a device might be running a private configuration mode, or a file-based workflow where you're editing configuration text outside the live database entirely. Cancelling means different things in each case, and the steps below work from the least destructive check outward.

Know which kind of "uncommitted" you're dealing with

Junos configuration follows a candidate-model workflow: you change a copy, review it with show | compare, then commit to make it active. Until then, the running configuration is unchanged except where someone else committed during your session. That creates three realistic scenarios:

Shared candidate config. You typed set or delete statements in configuration mode and haven't committed. Others may also have pending edits. This is the default on most Junos platforms unless private mode is enabled. Private candidate config. The session is in private mode (configure private), so only your edits are visible in your candidate. Discarding them affects nobody else. External file. You're editing a configuration file you loaded or saved (often with save and load), and your "uncommitted changes" live in that file or in an index/commit-script context rather than the candidate config.

Confirm which one you're in before issuing any rollback. In configuration mode, show system commit lists commit history—useful later—but it won't tell you whether the candidate is private. The prompt gives a hint on many devices: a private-mode session typically shows a [edit] context with % in the prompt (for example, user@host%), while standard config mode shows # (user@host#). Treat that as a visual cue, not proof; behavior differences below are the reliable check.

The core procedure: discard and exit

If you simply want to abandon what you typed in an ordinary shared or private configuration session, this is the whole job.

Prerequisites: You're at a # or % configuration prompt, you have the access privileges to enter configuration mode, and no commit is in progress. If a commit is running, wait for it to finish before doing anything else.

1: Optional but smart: run show | compare. This shows the difference between the candidate and the running configuration. If it shows edits you don't recognize, they may belong to another user's session, and you should not discard them. 2: Type exit. 3: If the CLI responds The configuration has been changed but not committed. Exit? [yes,no] (no), type no.

Expected result: You return to operational mode and the candidate configuration reverts to the running configuration—your pending edits are gone. If nothing was uncommitted, exit leaves configuration mode silently with no prompt.

Success check: Re-enter configuration mode with configure and run show | compare. An empty comparison (or a message that the configurations are identical) means nothing is pending. You can also run show system commit and confirm no new commit appeared from your session.

That Exit? [yes,no] (no) prompt is the actual cancel mechanism. Answering no tells the CLI to abandon the change set rather than save it. Answering yes or pressing Enter (which takes the default no) is a common source of confusion: the default is "no, don't exit," so a bare Enter keeps you in configuration mode with your edits intact. Read the prompt rather than typing from muscle memory.

What happens if you answer "yes" or your session drops

Answering yes at the exit prompt—or confirming exit some other way—also discards the uncommitted candidate on a standard Junos device; the prompt exists to stop you from losing work by accident, not to save it. So both answers end your session, and the difference is only whether you were warned and chose to proceed. The changes still never reach the running configuration.

A dropped session (SSH timeout, terminal closed) behaves similarly: uncommitted candidate changes are not activated, and the candidate generally resets. The important caveat is the shared candidate. If another user has pending edits in the same shared candidate, your departure doesn't selectively remove only your lines—the candidate as a whole may be reset when the last editing session ends, or left holding theirs, depending on platform and session behavior. This is precisely why show | compare before exiting matters on multi-user devices.

If you're on a platform or software version where the exit prompt wording or candidate-reset behavior differs, don't guess. Check the configuration-mode help (exit ?) and, if the device is production, confirm with the change-management owner before discarding anything you didn't personally type.

Rollback and the "discard" misconception

A frequent mistake is reaching for rollback 0 to cancel uncommitted edits. Rollback is a different tool. rollback 0 loads the currently committed (active) configuration into the candidate, replacing whatever is in the candidate—including your uncommitted edits and anyone else's pending edits in a shared candidate. That's why it works as a reset but is riskier than exit.

Use rollback 0 when you're the only editor or you've confirmed the candidate contains only your changes and you want to overwrite it in place without leaving configuration mode. Steps:

1: In configuration mode, run show | compare to see what you'd be discarding. 2: Run rollback 0. 3: Run show | compare again; it should now show no differences against the running config.

Note the distinction: rollback 0 does not commit and does not change the running configuration—it only resets the candidate. A plain rollback with no argument is equivalent to rollback 0 on Junos. Rolling back to a numbered prior commit (rollback 1, rollback 2) changes the candidate to an older committed state, which is a recovery operation, not a cancel, and still requires a commit to take effect. Don't use it to "undo typing"; use exit for that.

On devices configured with commit confirmed, there's one more trap. commit confirmed activates the config temporarily and auto-rolls back unless you confirm with a second commit within the timer. That's the opposite direction: it exists to protect you from losing access, not to cancel edits. If you accidentally ran commit confirmed instead of discarding, the safe move is to let the timer expire (the device returns to the prior committed config) or explicitly run rollback followed by commit—but only if you're confident about the prior state. On a remote production device, wait for the timer rather than improvising.

Private vs shared candidate: the difference that bites

Private configuration mode (configure private) gives each session its own candidate view built on the last commit. In that mode, discarding your changes is clean and affects only you: exit and answer no, and the private candidate vanishes. No show | compare worry about other users, because you can't see or affect their pending edits.

Shared mode is the default, and it's where cleanup discipline pays off. Two people editing the same candidate can produce a show | compare that blends both sets of edits. If you exit and the CLI resets the candidate, a colleague's unsaved work can disappear without their knowledge—so a good practice on shared devices is to commit or discard promptly, tell teammates when you're actively editing, and avoid leaving long-idle sessions open in configuration mode.

One more edge: configure exclusive locks the candidate so no one else can enter configuration mode until you exit. If you're in exclusive mode and walk away, you block everyone. Clean up by exiting; if the session hangs, you cannot simply hop back in—the lock has to clear via session timeout or the original session exiting. That's a stop condition worth escalating to whoever manages device access rather than trying to force it.

Named configurations and file-based edits

If you've been working with save, load, and replace against named files, "uncommitted changes" may mean a file on the device that you haven't loaded yet. Those are not in the candidate configuration until you load them, so they can't be "cancelled" in the CLI sense at all—they're just files. Options:

If you created a temporary file (for example with save /var/tmp/candidate.conf), delete it from the shell (rm) if you have shell access, or leave it; an unloaded file has no effect on the running config. If you already loaded it into the candidate, the candidate now contains those edits. Use the standard exit/no procedure, or rollback 0 if appropriate. Named configurations created with commit and a description (sometimes called commit scripts or commit confirmations depending on platform) are not simple edits; removing a pending one depends on the feature. Check vendor documentation for that specific feature rather than assuming a discard command exists.

For configuration management tools (out-of-band systems that push config), "uncommitted" usually means the tool's own diff state; cancelling means discarding the tool's pending change set, and the device-side procedure is unchanged—don't commit from the device if you want the tool's next push to own the config.

Troubleshooting: symptoms, causes, and reversible checks

Work from symptoms to likely causes and start with the least invasive check.

Symptom: The exit prompt never appears. Likely cause: Nothing is uncommitted, so exit just leaves config mode; or the session is stuck inputting a command. Check: Re-enter config mode and run show | compare. If empty, you're done.

Symptom: show | compare shows edits you didn't make. Likely cause: Shared candidate with another user's pending edits. Check: Ask teammates before discarding. If you're certain the edits are unwanted, rollback 0 resets the candidate, but it removes all pending edits, not just yours. If unsure, exit with no and leave; don't reset someone else's work.

Symptom: The device rejects rollback 0 or the command isn't recognized. Likely cause: You're not in configuration mode, or you're on a shell/operational prompt. Check: Run configure first; confirm the prompt changes to config mode before retrying.

Symptom: You're locked out of configuration mode. Likely cause: Another user holds configure exclusive. Check: show configuration sessions (where supported) lists sessions and owners. Don't force-clear; get the owner to exit or wait for the lock to time out.

Symptom: You committed something by mistake and are now trying to "cancel." Cause: Commit already changed the running config. Check: Use show system commit to see the commit, then recover deliberately—rollback in the candidate followed by a reviewed commit, or a platform-supported rollback. This is a change-management action, not a discard, and on production gear should be done under whatever change policy your team uses. If the device is remote and a rollback could break your access, that's the stop condition: involve network operations or remote-hands support rather than guessing.

A worked scenario

Suppose you're logged into an SRX or EX switch in shared configuration mode and have typed three set statements for a test VLAN. A colleague is also logged in with a pending interface description change. You decide the VLAN test isn't needed.

Run show | compare. You'll see both your VLAN lines and the colleague's description change. That's the signal to stop and coordinate: exiting and answering no discards the candidate, which could include the colleague's pending work depending on how the platform resets shared sessions. The professional move is to tell the colleague, confirm they've committed or saved, and then exit cleanly. If you were the only editor—say a private-mode session or a lab device—show | compare, then exit, then no finishes it in seconds, and a follow-up show | compare should show no differences.

The arithmetic here isn't numeric but procedural: one person's cancel is another person's data loss on a shared candidate. The only reliable way to tell them apart is the comparison check.

Judgment over command recall

The commands are simple, but the correct action depends on a few facts: shared or private candidate, who else is editing, and whether anything was already committed. The routine path is show | compare, then exit, then no, then verify with a second comparison. Use rollback 0 when you deliberately want to reset the candidate in place and you know it contains only what you intend to discard. Never reach for rollback or commit recovery to "cancel typing"—that's a different operation with different blast radius. On production Juniper gear, the safe habit is to verify before you discard and to coordinate whenever more than one session can touch the candidate. If a rollback or recovery decision could affect remote access or shared infrastructure, that's the point to pause and get the device owner involved rather than testing commands live.