The Tours of the Black Prompt series so far:
Today we’re exploring command history more as well as display settings and options for clustered Data ONTAP.
Working with the Command History
In Part 1 we talked about using the history
command to view the previously-entered commands. Note that this will only show the history of your current session – if you log out or get disconnected, the history from the previous session is not kept and therefor those older entries will not be displayed.
Besides navigating the CLI history using up and down arrows, or the Ctrl+n and Ctrl+p key combinations, you can also use the redo
command.
cdot_mba1::> history 1 storage aggregate show 2 volume show 3 network interface show 4 network port show cdot_mba1::> redo 1 Aggregate Size Available Used% State #Vols Nodes RAID Status --------- -------- --------- ----- ------- ------ ---------------- ------------ aggr0 900MB 43.54MB 95% online 1 cdot_mba1-01 raid_dp, normal
In this case, we told it to redo
the first command in the history buffer, so it re-ran storage aggregate show
. We could also tell it to run a prior command relative to the current using the format redo -2
.
cdot_mba1::> redo -2 1 storage aggregate show 2 volume show 3 network interface show 4 network port show 5 history 6 storage aggregate show
Why did it re-run the history
command? Because history
itself will be displayed in its own output (it is a command being run, after all) and it was the second command from the bottom of the list. Note also that redo 1
is not displayed but instead the storage aggregate show
is again listed: the redo
functionality is simply a shortcut and it is the effective commands that are displayed by history
and not the exact characters that are typed at the prompt.
Although:
cdot_mba1::> vol show (volume show) Vserver Volume Aggregate State Type Size Available Used% --------- ------------ ------------ ---------- ---- ---------- ---------- ----- cdot_mba1-01 vol0 aggr0 online RW 851.5MB 233.2MB 72% cdot_mba1::> history 1 storage aggregate show 2 volume show 3 network interface show 4 network port show 5 history 6 storage aggregate show 7 history 8 vol show
Notice that command 8 is different from command 2 (volume
shortened to vol
) even though they are the same effective command.
If you don't want to use a numeric ID or relative numeric value for a previously-entered command, you also use just use a string that uniquely matches the beginning of the prior command you want:
cdot_mba1::> redo vol (volume show) Vserver Volume Aggregate State Type Size Available Used% --------- ------------ ------------ ---------- ---- ---------- ---------- ----- cdot_mba1-01 vol0 aggr0 online RW 851.5MB 231.9MB 72%
What if you use a string that isn't unique to one command?
cdot_mba1::> redo network Auto-Negot Duplex Speed (Mbps) Node Port Role Link MTU Admin/Oper Admin/Oper Admin/Oper ------ ------ ------------ ---- ----- ----------- ---------- ------------ cdot_mba1-01 e0a data up 1500 true/true full/full auto/1000 e0b data up 1500 true/true full/full auto/1000 e0c data up 1500 true/true full/full auto/1000 e0d data up 1500 true/true full/full auto/1000 4 entries were displayed.
When multiple entries match the same string, the most recent match is used, which in this case was network port show
.
You can be very efficient when using this redo
method, as the string you type doesn't need to be long - it just needs to be unique:
cdot_mba1::> redo s Aggregate Size Available Used% State #Vols Nodes RAID Status --------- -------- --------- ----- ------- ------ ---------------- ------------ aggr0 900MB 43.52MB 95% online 1 cdot_mba1-01 raid_dp, normal
Since only one previously-entered command began with the letter "s", redo
knew that was the command that needed to be run. If you've been doing much in your session, of course, you're unlikely to be able to abbreviate it as much as in that example.
Would you believe there's an even more efficient way of re-running that command than redo s
? Try this instead:
cdot_mba1::> !1 Aggregate Size Available Used% State #Vols Nodes RAID Status --------- -------- --------- ----- ------- ------ ---------------- ------------ aggr0 900MB 43.54MB 95% online 1 cdot_mba1-01 raid_dp, normal
If you're used to Bash or other Unix/Linux shells, you may be used to using the "bang" (!) operator to re-run prior commands - and it works under clustered Data ONTAP as well! It operates just like the redo
command where you specify the numeric ID for the command from history
- but you don't even need a space between them.
One last efficiency trick: if you just want to rerun the last command you can simply type "!!".
cdot_mba1::> !! Aggregate Size Available Used% State #Vols Nodes RAID Status --------- -------- --------- ----- ------- ------ ---------------- ------------ aggr0 900MB 43.54MB 95% online 1 cdot_mba1-01 raid_dp, normal
Setting Display Preferences
In Part 1 we used the set
command to change between privilege levels, but it has several other uses as well.
cdot_mba1::> set -? [[-privilege] {admin|advanced|diagnostic}] Privilege Level [ -confirmations {on|off} ] Confirmation Messages [ -showallfields {true|false} ] Show All Fields [ -showseparator ] Show Separator [ -active-help {true|false} ] Active Help [ -units {auto|raw|B|KB|MB|GB|TB|PB} ] Data Units [ -rows ] Pagination Rows ('0' disables) [ -vserver ] Default Vserver [ -node ] Default Node [ -stop-on-error {true|false} ] Stop On Error
The "-confirmations" parameter specifies whether the system should require you to confirm ("Are you sure?") when issuing potentially disruptive commands. This, of course, on by default - please don't change it on a production system.
The "-showallfields" parameter tells the system to include all possible fields when displaying tabular output. This is off by default, and here's an example of why:
cdot_mba1::> set User Name: admin Profile Name: admin Privilege Level: admin Confirmation Messages: on Show All Fields: false Show Field Separator: Data Units: auto Pagination Rows: 54 Default Vserver: Default Node: Stop On Error: false cdot_mba1::> set -showallfields true cdot_mba1::> set privilege confirmations username profilename from app showallfields showseparator active-help units allow-proxy rows trace-threshold vserver node stop-on-error ----------- --------------- ---------- ------------- -------------- ----- --------------- --------------- ------------- ------- ------------- ------ ----------------- --------- ------ --------------- admin on admin admin 172.16.213.1 ssh true " " - auto false 54 0% "" "" false
If you do enable "-showallfields" you'll normally want to also set the "-showseparator" to a different character than a tab (like a comma to enable CSV output):
cdot_mba1::> set -showseparator "," cdot_mba1::> set privilege,confirmations,username,profilename,from,app,showallfields,showseparator,active-help,units,allow-proxy,rows,trace-threshold,vserver,node,stop-on-error, Privilege Level,Confirmation Messages,User Name,Profile Name,Connected From,Application,Show All Fields,Show Separator,Active Help,Data Units,Allow Offline Proxy,Pagination Rows ('0' disables),SMF Tracing Threshold,Default Vserver,Default Node,Stop On Error, admin,on,admin,admin,172.16.213.1,ssh,true,,,-,auto,false,54,0%,"","",false,
The "-active-help" parameter specifies that just typing "?" will activate help request. Setting this value to "true" will then require you to press [Enter] following the "?". You probably don't want to change this value.
The "-units" parameter specifies what unit of measurement for data storage should be used when reporting sizes. The default setting is "auto" which will auto-scale the size for human-readable output. You can override this to display everything consistently in bytes, kilobytes, etc.
cdot_mba1::> vol show (volume show) Vserver Volume Aggregate State Type Size Available Used% --------- ------------ ------------ ---------- ---- ---------- ---------- ----- cdot_mba1-01 vol0 aggr0 online RW 851MB 213MB 74% tours tours_root aggr0 online RW 20MB 18MB 5% 2 entries were displayed. cdot_mba1::> set -units B cdot_mba1::> vol show (volume show) Vserver Volume Aggregate State Type Size Available Used% --------- ------------ ------------ ---------- ---- ---------- ---------- ----- cdot_mba1-01 vol0 aggr0 online RW 892841984B 223346688B 74% tours tours_root aggr0 online RW 20971520B 19808256B 5% 2 entries were displayed. cdot_mba1::> set -units KB cdot_mba1::> vol show (volume show) Vserver Volume Aggregate State Type Size Available Used% --------- ------------ ------------ ---------- ---- ---------- ---------- ----- cdot_mba1-01 vol0 aggr0 online RW 871916KB 218632KB 74% tours tours_root aggr0 online RW 20480KB 19344KB 5% 2 entries were displayed. cdot_mba1::> set -units TB cdot_mba1::> vol show (volume show) Vserver Volume Aggregate State Type Size Available Used% --------- ------------ ------------ ---------- ---- ---------- ---------- ----- cdot_mba1-01 vol0 aggr0 online RW 0TB 0TB 74% tours tours_root aggr0 online RW 0TB 0TB 5% 2 entries were displayed.
My personal recommendation is to just leave it at the defaults, but there can be times that it's useful to change.
The "-rows" parameter specifies how many rows of output text before the pagination is required (in other words, before you have to hit [Space] to see the next page of output).
cdot_mba1::> vol show -ins (volume show) Vserver Name: cdot_mba1-01 Volume Name: vol0 Aggregate Name: aggr0 Volume Size: 851.5MB Volume Data Set ID: - Volume Master Data Set ID: - Volume State: online Volume Type: RW Volume Style: flex Is Cluster-Mode Volume: false Is Constituent Volume: false Export Policy: - User ID: - Group ID: - Security Style: - UNIX Permissions: ------------ Junction Path: - Junction Path Source: - Junction Active: - Junction Parent Volume: - Comment: - Available Size: 221.4MB Filesystem Size: 851.5MB Total User-Visible Size: 808.9MB Used Size: 587.5MB Used Percentage: 73% Volume Nearly Full Threshold Percent: 95% Volume Full Threshold Percent: 98% Maximum Autosize (for flexvols only): 1021MB Autosize Increment (for flexvols only): 42.57MB Minimum Autosize: 851.5MB Autosize Grow Threshold Percentage: 85% Autosize Shrink Threshold Percentage: 50% Autosize Mode: off Autosize Enabled (for flexvols only): false Total Files (for user-visible data): 25876 Files Used (for user-visible data): 7589 Space Guarantee Style: volume Space Guarantee in Effect: true Snapshot Directory Access Enabled: true Space Reserved for Snapshots: 5% Snapshot Reserve Used: 734% Snapshot Policy: - Creation Time: Fri Nov 07 20:45:01 2014 Language: - Clone Volume: - Node name: cdot_mba1-01 NVFAIL Option: on Is File System Size Fixed: false Extent Option: off Reserved Space for Overwrites: 0B Press to page down, for next line, or 'q' to quit...
Setting this value to 0 turns off pagination and all output is sent immediately to the screen.
cdot_mba1::> set -rows 0 cdot_mba1::> vol show -ins (volume show) Vserver Name: cdot_mba1-01 Volume Name: vol0 Aggregate Name: aggr0 Volume Size: 851.5MB Volume Data Set ID: - Volume Master Data Set ID: - Volume State: online Volume Type: RW Volume Style: flex Is Cluster-Mode Volume: false Is Constituent Volume: false Export Policy: - User ID: - Group ID: - Security Style: - UNIX Permissions: ------------ Junction Path: - Junction Path Source: - Junction Active: - Junction Parent Volume: - Comment: - Available Size: 221.6MB Filesystem Size: 851.5MB Total User-Visible Size: 808.9MB Used Size: 587.3MB Used Percentage: 73% Volume Nearly Full Threshold Percent: 95% Volume Full Threshold Percent: 98% Maximum Autosize (for flexvols only): 1021MB Autosize Increment (for flexvols only): 42.57MB Minimum Autosize: 851.5MB Autosize Grow Threshold Percentage: 85% Autosize Shrink Threshold Percentage: 50% Autosize Mode: off Autosize Enabled (for flexvols only): false Total Files (for user-visible data): 25876 Files Used (for user-visible data): 7589 Space Guarantee Style: volume Space Guarantee in Effect: true Snapshot Directory Access Enabled: true Space Reserved for Snapshots: 5% Snapshot Reserve Used: 734% Snapshot Policy: - Creation Time: Fri Nov 07 20:45:01 2014 Language: - Clone Volume: - Node name: cdot_mba1-01 NVFAIL Option: on Is File System Size Fixed: false Extent Option: off Reserved Space for Overwrites: 0B Fractional Reserve: 100% Snapshot Cloning Dependency: off Primary Space Management Strategy: volume_grow Read Reallocation Option: off Inconsistency in the File System: false Is Volume Quiesced (On-Disk): false Is Volume Quiesced (In-Memory): false Volume Contains Shared or Compressed Data: false Space Saved by Storage Efficiency: 0B Percentage Saved by Storage Efficiency: 0% Space Saved by Deduplication: 0B Percentage Saved by Deduplication: 0% Space Shared by Deduplication: 0B Space Saved by Compression: 0B Percentage Space Saved by Compression: 0% Block Type: 64-bit FlexCache Connection Status: - Is Volume Moving: - Flash Pool Caching Eligibility: read-write Flash Pool Write Caching Ineligibility Reason: - Managed By Storage Service: - Create Namespace Mirror Constituents For SnapDiff Use: - Constituent Volume Role: - QoS Policy Group Name: - Is Volume Move in Cutover Phase: - Number of Snapshot Copies in the Volume: 5
One final note: rather than typing set -rows 0
(or whatever value you want) you can simply use rows 0
instead.
cdot_mba1::> rows 0 cdot_mba1::> set -rows 54 cdot_mba1::> rows 54 cdot_mba1::> set -rows 0 cdot_mba1::> rows 0 cdot_mba1::> rows 54 cdot_mba1::> set User Name: admin Profile Name: admin Privilege Level: admin Confirmation Messages: on Show All Fields: false Show Field Separator: , Data Units: auto Pagination Rows: 54 Default Vserver: Default Node: Stop On Error: false
The "-vserver" parameter specifies a default vserver (the older engineering term for what are now called Storage Virtual Machines, or SVMs) to be used with any command which has an applicable "-vserver" parameter.
cdot_mba1::> vserver show Admin Root Name Name Vserver Type State Volume Aggregate Service Mapping ----------- ------- --------- ---------- ---------- ------- ------- cdot_mba1 admin - - - - - cdot_mba1-01 node - - - - - tours data running tours_root aggr0 file file 3 entries were displayed. cdot_mba1::> set -vserver tours cdot_mba1::> set User Name: admin Profile Name: admin Privilege Level: admin Confirmation Messages: on Show All Fields: false Show Field Separator: , Data Units: MB Pagination Rows: 0 Default Vserver: tours Default Node: Stop On Error: false cdot_mba1::> vserver show Admin Root Name Name Vserver Type State Volume Aggregate Service Mapping ----------- ------- --------- ---------- ---------- ------- ------- tours data running tours_root aggr0 file file
Likewise, the "-node" parameter specifies a default node (or storage controller) to be used with any command which has an applicable "-node" parameter.
For both "-vserver" and "-node" you can return to the unspecified values by using "" (with no space in between):
cdot_mba1::> set -vserver "" cdot_mba1::> vserver show Admin Root Name Name Vserver Type State Volume Aggregate Service Mapping ----------- ------- --------- ---------- ---------- ------- ------- cdot_mba1 admin - - - - - cdot_mba1-01 node - - - - - tours data running tours_root aggr0 file file 3 entries were displayed. cdot_mba1::> set User Name: admin Profile Name: admin Privilege Level: admin Confirmation Messages: on Show All Fields: false Show Field Separator: , Data Units: MB Pagination Rows: 0 Default Vserver: Default Node: Stop On Error: false
Finally, the "-stop-on-error" parameter specifies whether a continuing command will continue upon encountering an error or stop instead. The default is stop.
For all of these session settings, it's important to remember that they only affect the current session: upon logoff or disconnect any customizations you have made will be lost and the next session will use the default values instead.
Ok, that last section got pretty dry (display settings just aren't sexy, sorry), but in Part 3 we'll go over more advanced CLI uses with field options, queries, and extended queries. Trust me - it's more fun that sentence sounded!
5 thoughts on “Tours of the Black Prompt: Clustered NetApp Data ONTAP – Part 2”