# NSO Command Cheat Sheet

Start NSO from the Linux CLI

```
ncs_cli -C -u admin
```

Add a device to NSO

```
devices device <name>
address <ip address>
authgroup <authgroup>
device-type cli|generic|netconf|snmp ned-id <ned-id>

!If using CLI
device-type cli protocol ssh|telnet
ssh host-key-verification none

state admin-state unlocked
```

Create a device group and add devices

```
devices device-group <name>
device-name <device name>
```

Check whether devices are in-sync

```
devices check-sync
devices device <name> check-sync
devices device-group <name> check-sync
```

Sync the config of all devices to NSO

```
devices sync-from
devices device <name> sync-from
devices device-group <name> sync-from
```

Show a single device’s config (from the NSO database which could be out of sync)

```
show running-config devices device <name> config
```

Configure a single device from NSO

```
config
devices device <name>
config
<configuration>
commit
```

Perform a dry-run commit

```
commit dry-run [outformat cli|xml|native]
```

Rollback the config

```
rollback configuration [commit id]
```

* By default it will rollback to the latest. Use “?” to get a list of commit IDs and the time they were committed.

Create a template

```
devices template <name>
ned-id <ned-id>
config
<configuration>
exit
exit
<additional ned IDs and their configuration>
commit
```

Apply a template to a device or device group

```
devices device <name> apply-template template-name <name>
devices device-group <name> apply-template template-name <name>
```

Execute an arbitrary command on a device

```
devices device <name> live-status exec <command>

example:
devices device R1 live-status exec show ip route
```

Create a compliance report

```
compliance reports report <name>
compare-template <template name> <device group>
commit
end

compliance reports report <name> run [outformat text|html|xml]
! report is placed under <instance dir>/state/compliance-reports/report*.extension
```

Make a new service package template with no code

```
cd nso-instance/packages
ncs-make-package --service-skeleton template <name>
```

Compile a service and add it to NSO

```
cd <service-name>/src
make
ncs_cli -C -u admin
packages reload
```
