Description

This article provides a simple way of cancelling the uncommitted configuration while in the edit prompt on a Juniper device.

Solution

There are occasions when we make edits to the configuration and then realize something is wrong with the configuration, and we need to make a change.

Being in the edit private prompt makes this easy as we can exit out of the edit prompt:

user@test-re0> edit private 
Apr 30 16:40:11
warning: uncommitted changes will be discarded on exit
Entering configuration mode

But if the changes were made in the edit exclusive prompt, we would continue to see the note below: 

user@test-re0> edit 
Apr 30 16:36:00
Entering configuration mode
The configuration has been changed but not committed

Below is an example of a configuration change that was made but not committed. One way of getting rid of it before the next commit is to delete these lines one by one. This would be very time consuming if the uncommitted configuration is big. 

user@test-re0# show | compare | no-more

Apr 30 16:36:06
[edit firewall]
+   family inet {
+       filter test {
+           term 1 {
+               from {
+                   source-address {
+                       192.168.1.2/32;
+                   }
+                   protocol udp;
+                   source-port 67;
+               }
+               then {
+                   count count_dhcp;
+                   discard;
+               }
+           }
+       }
+   }

{MASTER}[edit]

An easier way is to rollback to the active configuration on the device using the 'rollback 0' command:

user@test-re0# rollback 0

Apr 30 16:36:18
load complete

{MASTER}[edit]
user@test-re0# show | compare | no-more   
Apr 30 16:36:20

{MASTER}[edit]


With this, any uncommitted changes will be deleted.

For more details, refer to the technical documentation on the rollback command.