How to Become a NetApp ONTAP CLI Ninja

April 3rd, 2018
How to Become a NetApp ONTAP CLI Ninja

Over the past decade or so I’ve spent quite a few hours of my life staring at the NetApp ONTAP command line interface. 3840 hours, to be exact.  I did the math…8 hours per week, 48 weeks per year, over the last 10 years comes to 3840 hours (OK, not exact, but I’d argue a very conservative estimate).  I’ve worked on countless different versions of ONTAP containing multiple revisions of various commands.  As with anything you put 3840 hours into, I picked up a few shortcuts and tricks along the way.  My goal with this post is to share some of this knowledge to help you become more efficient in your role.  The tips below will only be relevant to those of you running Clustered Data ONTAP (aka CDOT, or just “ONTAP" now).  If you’re still running a NetApp system with a 7-mode (7m) version of ONTAP, it’s time to upgrade (*cough* we can help *cough*). 

Almost to the fun stuff -  but first a few disclaimers.  Depending on your skill level, some of these may seem basic, but they get more advanced as you go through, I promise.  Nomenclature:

  • CLI commands will be italicized (volume would represent typing the word volume at the CLI)
  • Specific key presses will be bold (enter would represent pressing the enter key)
  • Variables will be indicated with <> brackets (<volume-name> would be a placeholder for an actual volume name)
  • Some commands require the use of special characters (! and { } and * for example).  Type these exactly as you see them displayed here.
  • All commands are always capitalization sensitive so pay close attention to upper/lower-case letters.

Important caution: Any commands shown in the following post are for demonstration purposes only and should always be modified accordingly and used carefully.  Do not run any of the procedures below without thorough testing and if you do not fully understand the consequences.  Please contact a representative at H.A. Inc. if you need assistance with components of your infrastructure as it relates to this posting.

Tip 1 – Use the tab key to autocomplete commands

It’s somewhat difficult for me to show this via static screenshots and text but I think this feature is somewhat self-explanatory.  Not only will autocomplete fill commands in, it will (in most cases) fill in variables for you too.  For example, if you type the following:

ne tab in tab sh tab -vs tab Cl tab enter

you get the following command and associated output:


Tip 2 – Consolidate output with rows 0

You will find that some commands have a large output with some line wrapping that will require you to hit space or enter to continue.  This is inconvenient and makes a mess of the log if you’re trying to capture the output.  The default number of rows displayed can be set to infinite by entering the following command.  This will be reset back to default every time you login.

rows 0

                Output of a command with rows set to 10:

Output of the same command with rows set to 0:

Tip 3 – Use the -fields operator to show precisely what you need

As shown by the network interface show outputs above, you can get a lot of good basic info about the LIFs using the basic show command.  But what if I wanted to show just the IP addresses and also add the allowed data protocol for each LIF? Add -fields then a comma separated list of fields you’d like to show to the command as shown below to customize the output:

network interface show -fields address,data-protocol

Tip 4 – Make your output CSV friendly with set -showseperator ","

The ouput of tip 3 above is nice but not very friendly for copying out for use elsewhere (a script, a report, etc) due to inconsistent spacing and line wrapping.  Formatting the output with commas as separators is a huge help with this.  The default separator character can be set to a comma by entering the following command.  This will be reset back to default every time you login.

set -showseperator ","

Tip 5 – Use the wildcard * operator

Use the asterisk as a wild card character at the beginning, end, or anywhere in the middle of the item you’re searching for (results will differ depending on location).  Let’s say I have a bunch of volumes but I’d like to get a report of volumes with “nfs” in the name:

Or, I only want to see the volumes that are located on all aggregates that have “SSD” in the name:

Or, how about I want to search the event log for all entries with “Dump” in the event column that occurred on “3/21/2018”

Tip 6 – Use the NOT ! operator

Use the exclamation point as a NOT operator for searches.  Let’s say I want to show all volumes that are not currently online:

We can also combine ! with * to show all volumes that do not have “root” anywhere in the name of the volumes:

Tip 7 – Use the greater/less than operators

Use the greater than and less than operators during searches that involve sizes.  Let’s say I want to show all volumes with a size of more than 1GB:

Tip 8 – Use curly brackets for extended queries

Use curly brackets to perform a query in order to determine items to perform further action on.  For example, let’s say I want to modify only LIFs that meet the following specific criteria:

  • auto-revert set to false
  • not iscsi or fcp data-protocol

Tip 9 – Use set -confirmations off to auto-confirm all end-user prompts

Certain commands require the user to confirm for each occurrence.  When running a handful of commands in a row (as is often the case for repetitive/scriptable tasks), it is cumbersome to have to acknowledge after every single line.  Using set -confirmations off disables these confirmations.  This is potentially risky as the confirmations are often provided as a safety mechanism to ensure the action you are about to take is really what you intend so use this one carefully.

Deleting a volume with set -confirmations on:

Deleting a volume with set -confirmations off you can see the user is not prompted to confirm this action:

Tip 10 – Naming naming naming

As shown with tips 1-10, the powerful capabilities of the CLI really reinforces the importance of good, consistent naming conventions.  Develop good naming conventions, document them well, share them with your team, and stick to them.

Join the High Availability, Inc. Mailing List