Using Abbreviations
In articles, I always try to provide the full version of the command because one should know what they are typing. However, in practice, it is advantageous to use abbreviations. You only need to enter the first few characters of the command to make it unique in the given context. Initially, you can try entering abbreviations and use the tab key (if the beginning is unique, it will complete the command) or the question mark (lists commands that start with these characters) to verify its uniqueness. Over time, you will know which abbreviations you can use.
Note: I read a discussion where someone argued that using abbreviations makes you forget the full commands. But, for example, I mentally say the full command and only type the abbreviation. In recent months, I have started using Microsoft's PowerShell a bit, which does not have such features as IOS, and its use is really cumbersome.
A few examples of how we can abbreviate commands:
SWITCH#sh ru = show running-configuration SWITCH(config-if)#sw a v 100 = switchport access vlan 100 SWITCH(config)#in r g1/0/1-5 , g1/0/10 = interface range gigabitEthernet1/0/1-5 , gigabitEthernet1/0/10
Another option is to create aliases, i.e., shortcuts for commands. In the alias, we must specify the mode in which the command is executed, the abbreviation, i.e., the alias itself, and the command for which the alias is created.
SWITCH(config)#alias mode abbreviation original-command SWITCH(config)#alias exec s show
Many aliases already exist in the system, e.g., s = show, w = where, lo = logout. These aliases are displayed when listing commands.
SWITCH#s? *s=show send session set setup show ssh systat
Saving Configuration
If we want to save the running configuration to the startup configuration, instead of the command
SWITCH#copy running-configuration startup-configuration
we can use the shorter
SWITCH#write // or the abbreviation wr
Resetting Interface Configuration
If we have a more complex configuration on a port and want to set something else, it may be faster to reset the interface to its default state rather than changing the configuration of several commands.
SWITCH(config)#default interface f0/1
Filtering Information
Part of working with switches involves viewing various information from them. If we are looking for a specific piece of data, it is more efficient to filter this data rather than going through a long list.
Some commands directly contain some filtering parameters, for example, displaying the configuration only for a given interface.
SWITCH#show running-config interface g1/5 SWITCH#show mac address-table vlan 100
The second option is to use the output modifier | (pipe), which is available for all show commands. After it, several commands can be used, and a regular expression can follow the command.
SWITCH#show running-config | begin access-list // starts the output from the first occurrence SWITCH#show mac address-table | include 001e.138c.73e7 // displays only lines that contain
One command after the pipe, which is not related to filtering, is redirecting the output of the show command to a file (locally or on the network).
SWITCH#show running-config | tee flash1:config.txt // copies SWITCH#show running-config | redirect flash1:config.txt // redirects SWITCH#show running-config | append tftp:config.txt // redirects and appends
Using Commands from EXEC Mode
Mainly show commands can normally only be invoked in EXEC mode (sometimes referred to as show mode). This is inconvenient when working, as we need to look at something and are in configuration mode. Therefore, there is the do command, which allows you to call commands from privileged mode (EXEC) in any mode. The only disadvantage is that command completion (tab key) and help (question mark) do not work after the do command.
SWITCH(config-if)#do show run int g1/5
Note: For a quick jump directly to EXEC mode, you do not need to use a series of exit commands, but press Ctrl+Z.
Displaying Interface Information
An interesting command for displaying interface capabilities.
SWITCH#show interfaces capabilities
Displaying Debug Information in the Window
If we are connected via console (serial cable), various messages (debug information, error messages) are displayed on the screen. This is because the default logging device is the console. The messages are also stored in the local buffer, and we can set them to be sent to a syslog server. The outputs directed to the console can delay us, so we can control which types should be displayed.
SWITCH(config)#logging console warnings // we enter level 1 - 7
or we can also completely disable the display
SWITCH(config)#no logging console
If we are connected via terminal connection (telnet or ssl), these messages are not received by default. If we wish, we can direct the output to our session.
SWITCH#terminal monitor
And here we can also control which messages will be displayed
SWITCH(config)#logging monitor errors // we enter level 1 - 7
Note: These settings only apply to the current session, so they are canceled after closing the connection.
Sending logs to a standard syslog server is set simply by entering the server's IP address.
SWITCH(config)#logging 192.168.50.15
However, there is a small trick. By default, information is sent to the syslog at the informational level and above, which does not include debugging. And if we set some logging with the debug command, this information will not reach the syslog. We need to change the setting to the lowest level.
SWITCH(config)#logging trap debugging
Pro rychlý skok rovnou do EXEC módu lze použít příkaz end. ;-)
Nebo CTRL+C
Ja pouzivam ctrl+Z
čau, tenhle článek jsem četl až dnes, tak si dovolím přidat jedno doporučení pro mladší kolegy:
- je dobré zapisovat show minimálně třemi písmenky.
Představ si, že jsi v (conf-if) interfacu pro management a chceš se podívat na konfiguraci, dáš sh a můžeš startovat k přepínači (vyp/zap). Místo show se provedl shutdown...
Samozřejmě správná volba v (conf-if) je do show; nebyl jsem sám, komu se to povedlo ;-)