Chapter 4. IOS Command Line Interface

Most IOS configuration is done through the Command Line Interface (CLI); therefore, to configure IOS-based routers, we need a good understanding of how the CLI works, and we need to feel comfortable with its capabilities. The CLI is very simple; however, just like any other command line interface (Remember DOS?), it is not the most intuitive interface for beginners.

In this chapter, we will cover the major features of the IOS CLI so you know how it works. We will then cover some configuration tasks that are independent of the network protocols that are covered in later chapters

So far we have done the basic configuration of two routers, but we have not yet typed a command. At the end of the System Configuration Dialog in Chapter 3, we saw the message "Press RETURN to get started!" That is point from which we are going to start learning about the IOS Command Line Interface (CLI).

  1. Logging In
  2. The most basic way of logging in to an IOS-based router is through a connection to the console port like the one we used for initial configuration. In Chapter 3 we saw that the System Configuration Dialog asked us for three passwords - enable secret, enable, and VTY. We were not asked for a console password; therefore, all we have to do to log in to a router which has a configuration created by the System Configuration Dialog is press <Enter>. As an example, we will log in to Dallas.

    Press RETURN to get started!

    <Enter>

    Dallas>

    When <Enter> is pressed, the command prompt ("Dallas>" in the example) appears. Once we get a prompt, we can start typing commands.

    Protecting the console port with a password is good practice; assigning a password to the console port is shown in Chapter 6. If there were a password on the console port, the log in sequence would look slightly different.

    Press RETURN to get started!

    <Enter>

    User Access Verification

    Password: noknok

    Dallas>

    When the console port is password protected and <Enter> is pressed, we get a password prompt. We are granted access to the router if we type the correct password. The example shows that the correct password, noknok, has been typed and we have been logged in and given the command prompt "Dallas>".

    Suppose that either the incorrect password is typed or no password is typed. The console output will look like this.

    Press RETURN to get started!

    <Enter>

    User Access Verification

    Password: knockknock

    Password:

    % Password: timeout expired!

    Password: niknak

    % Bad passwords

    Press RETURN to get started!

    <Enter>

    User Access Verification

    Password: noknok

    Dallas>

    We get three tries to type the correct password before we are kicked out and have to start over. On the console, this is not really a big deal, since we have to wait only a few seconds before we can press <Enter> and get another password prompt.

    If we type the incorrect password on the first or second try, we are simply given another password prompt. The password-prompt timeout period is about 30 seconds; if we do not type anything at a password prompt for the timeout period, the prompt timeout will expire. When the correct password is typed, we are given a user mode command prompt.

    We can also log in to IOS by establishing a telnet session to the router and typing the correct password. Once we get a password prompt, the behavior of the IOS command line interface is exactly the same it is on a console terminal. The password used to log in through a telnet session is the VTY password we entered during the System Configuration Dialog.

  3. Command Prompts and Modes

The command prompt changes based on the command mode that we are using or the mode in which the router is running. The major command modes are as follows:

    • User Mode
    • Privileged Mode
    • Global Configuration Mode
    • Sub-Configuration Modes
    • ROM Monitor Mode

User, privileged, global configuration, and sub-configuration modes are IOS command modes. These are the modes that we will be moving in and out of as we configure IOS. Figure 4-1 shows these command modes, their default prompts, and the commands or keystrokes that are used to move among them.

<<<J111 - Figure 4-1 IOS Command Modes>>>

The following sections describe each of the modes and their command prompts. All of the modes can be recognized by the default format of their command prompts.

      1. User Mode
      2. When you log in to a router, you are put into user mode. You can tell that you are in user mode because the user mode prompt consists of the router's host name followed by the greater-than sign (>). The log in examples in Section 4.1 show that after a successful log in to Dallas, the prompt looks like this:

        Dallas>

        User mode can be referred to as the "look but don't touch" mode. In user mode, we can do nothing that would normally affect IOS operation on the router. All we can do is look. We can look at just about anything on the router except the IOS running configuration and startup configuration.

      3. Privileged Mode
      4. When we want to do something that could potentially affect IOS operation or we want to view either of the configurations, we must move from user mode to privileged mode. In privileged mode, we can do just about anything we want to do. For example, we can examine the configuration files, and we can reboot the router.

        The user mode enable command tells IOS that we wish to enter privileged mode. The terminal output for this exchange is shown below.

        Dallas>enable

        Password: itsasecret

        Dallas#

        When we type the enable command, we are asked for a password before we are granted access to privileged mode. If we type the correct password, we are placed in privileged mode, and our command prompt changes. The command prompt now has the name of the router followed by a number or pound sign (#). At this point, the number sign in the prompt means that we have complete control over the router, and we can do whatever we wish. Spending a lot of time in privileged mode can be dangerous for the inexperienced router configuration person; however, sometimes it is necessary.

        Let us return to the password that we typed for access to privileged mode. The password we entered was itsasecret. This password is the enable secret password that we entered in the System Configuration Dialog on Dallas in Section 3.5.1.2. "Enable secret" is an unusual name for a password used to get into privileged mode. Privileged mode was formerly called enabled mode thus the command enable to get there and the "enable" in enable secret. The word "secret" comes from the way that the password is displayed in the configuration files; it is encrypted with a one-way, cryptographic algorithm.

        During the initial configuration of our two routers in Chapter 3, we also entered an enable password. As long as there is an enable secret password, the enable password actually does nothing in our routers as they are currently running. If we were to remove the enable secret password, then the enable password enableme would be used to enter privileged mode. The enable password also exists just in case we use the router's configuration file with an old version of IOS that does not support the enable secret password. The regular enable password is sort of the legacy password.

        If we want to leave privileged mode and return to user mode, the command is disable.

        Dallas#disable

        Dallas>

        Notice that the last character in the prompt changes from the number sign back to the greater-than sign. To summarize, enable gets us into privileged mode, and disable get us out.

        Privileged mode commands are a superset of the user mode commands. In other words, all user mode commands are still available to us while we are in privileged mode.

      5. Configuration Modes
      6. The IOS configuration modes are used for entering IOS configuration commands that affect the way IOS runs on a router. The main configuration mode is global configuration mode, or global config mode; it is the one we enter first. From global configuration mode, we can enter the sub-configuration modes. The configuration mode required for a command depends on what is being configured and what command is being entered. All commands that are entered in a configuration mode affect the running configuration, and configuration commands take effect immediately after they are entered.

        Since being in a configuration mode implies that we are changing the operation of IOS, we can enter global configuration mode only from privileged mode. User mode and privileged mode commands are not accepted in the configuration modes.

        1. Global Configuration Mode
        2. The first configuration mode is global configuration mode. In global configuration mode, we can make changes that affect the overall, or global, operation of IOS. For example, we can enter commands that change a router's host name, start processes or services, and set some of the passwords.

          The configure terminal command is a privileged mode command used to enter global configuration mode if a terminal is being used to enter configuration commands. IOS will accept the command only in privileged mode. We will cover the configure terminal command in more detail later. Terminal output is shown below.

          Dallas#configure terminal

          Enter configuration commands, one per line. End with CNTL/Z.

          Dallas(config)#

          The global configuration mode prompt has the word config in parentheses while still maintaining the router's host name and the number sign.

          According to the message immediately after the configure terminal command, if we want to leave global configuration mode and return to privileged mode, we type <Ctrl-Z>.

          Dallas(config)#<Ctrl-Z>

          Dallas#

          We could also have typed end or exit to return to privileged mode. From global configuration, we can move to the other configuration modes. We can enter global configuration commands in any of the configuration modes.

        3. Sub-Configuration Modes

The sub-configuration modes are used to configure individual components like interfaces and processes. The command to enter a sub-configuration mode varies based on the component that is being configured.

For example, if we want to configure an interface, we must be in interface configuration mode. To get into interface configuration mode, we use the interface command in global configuration mode. The interface command requires the full interface name (Section 3.1.3), with type and number, immediately after it.

Dallas(config)#interface serial1

Dallas(config-if)#

All sub-configuration mode prompts have, within parentheses, the word config and a word or abbreviation specifying the sub-configuration mode separated by a hyphen (-). The interface configuration mode prompt has config-if in parentheses along with the router's host name and the number sign. The if indicates interface configuration mode. Commands to configure interface Serial1 can be typed at this prompt; we could also type any global configuration command here since global configuration commands are accepted in any of the configuration modes.

We can use the exit command to return to global configuration mode.

Dallas(config-if)#exit

Dallas(config)#

If we type a global configuration command that does not cause us to enter another sub-configuration mode, then we will be returned to global configuration mode. For example, suppose we are in interface configuration mode and we decide to change the name of the router.

Router(config-if)#hostname Dallas

Dallas(config)#

This example reinforces several things that have already been mentioned.

    • Global configuration commands can be typed in any configuration mode.
    • Entering a global configuration command that does not lead to another sub-configuration mode, takes us to global configuration mode.
    • Configuration commands take effect immediately. (Notice the name change in the prompt after the global configuration hostname command was used to set the router's host name.)

To exit a sub-configuration mode and go all the way to privileged mode, we could type <Ctrl-Z> or end at the sub-configuration mode prompt.

Dallas(config-if)#end

Dallas#

There are about 20 sub-configuration modes. Some others that we will use in this book are line configuration, router configuration, IPX-router configuration, and access-list configuration. They will be covered as we get to their configuration commands.

      1. ROM Monitor Mode

ROM monitor mode is not really an IOS mode; it is more of a mode that a router can be in if IOS is not running. If a router attempts to boot and cannot find a good IOS image to run, then the router will enter ROM monitor mode. We can also purposely cause the router to enter ROM monitor mode by sending a Break signal from the console terminal within 60 seconds of the start of the router's boot sequence. Purposely entering ROM monitor mode is usually done only as one of the steps for recovering a lost password.

ROM monitor mode has commands that allow us to manually boot a router by loading a valid IOS image. The exact commands and prompt vary by router model; however the command prompt is usually just a greater-than sign (>).

    1. Talking to IOS
    2. Now that we have seen the different modes in which we can enter commands, we can cover the format of those commands and the way that they should be typed. Talking to IOS really is as simple as typing a command and pressing <Enter>. The <Enter> key, or Return, must be pressed after each command.

      Most of the time IOS talks back after a command has been issued. When we type a command asking for information, we usually get information back if it is available. When we type a command that is formatted incorrectly, the IOS command line interpreter tells us that where it thinks we made a mistake.

      When we type a word at a user mode or privileged mode prompt, IOS checks its command table for the word to see if the word is a valid command. If the single word issued on the command line is not a valid command, the default behavior of IOS is to interpret the word as the name of a host to which a telnet session should be established. The resulting message can be annoying.

      Dallas>whoops

      Translating "whoops"...domain server (255.255.255.255)

      % Unknown command or computer name, or unable to find computer address

      Dallas>

      The message is annoying because it indicates that the router is attempting to resolve the host name to an IP address by broadcasting a request to an unknown domain (DNS) server. This translation, which is normally destined for failure, takes about 10 seconds to time out. We will cover several ways to change this behavior in Chapter 7.

      We can control the way that IOS displays information on our terminal and change other terminal parameters with the user mode command terminal. Any terminal parameters we change are effective only for the duration of our current terminal session. If we log out, the terminal parameters return to their original values.

      The real skill in talking to IOS comes in knowing which command, or commands, to use. Some IOS tasks require more than one command. Specific commands used to execute IOS tasks will be covered in the coming chapters; for now, we will concentrate on how to use the command line interface. Without knowledge of how to effectively use the features of the command line interface, IOS configuration can be a daunting task.

      1. Command Line Editing
      2. IOS allows us to edit a command while we are typing it. We can move the cursor around on the command line, add characters, delete characters, and insert characters. The keystrokes for editing the IOS command line are generally like a subset of those in the Emacs text editor used mostly on Unix hosts. With that in mind, picture the command line as a 10-line text file, or buffer, that we can edit; each line is a command, and each command can have 253 characters.

        IOS keeps the last 10 commands we typed in a command history buffer. There are two command history buffers. One buffer is for user mode and privileged mode commands; the other is for configuration mode commands.

        1. Moving the Cursor Around
        2. The command keystrokes used to move the cursor around on the command line and within the command history buffer are shown in Figure 4-2.

          Cursor Motion Desired

          Left (Backward)

          Right (Forward)

          Character

          <Ctrl-B>

          or Left-Arrow Key

          <Ctrl-F>

          or Right-Arrow Key

          Word

          <Esc><B>

          <Esc><F>

          Line (to Beginning or End)

          <Ctrl-A>

          <Ctrl-E>

          Command in History Buffer

          <Ctrl-P>

          or Up-Arrow Key

          <Ctrl-N>

          or Down-Arrow Key

          <<<Figure 4-2 Cursor Motion Keystrokes>>>

          The arrow keys are probably the easiest and most straight-forward way to move the cursor around; they can be used on ANSI-compliant terminals like the VT100, the VT220, and the VT320. If your PC's terminal emulation software is emulating a VT-type terminal the arrow keys can be used for cursor movement.

          Pressing the left-arrow key (or <Ctrl-B>) moves the cursor left one character, and pressing the right-arrow key (or <Ctrl-F>) moves the cursor right one character.

          Typing <Esc><B> (Press and release the <Esc> key, and then press and release the <B> key.) moves the cursor left to the first character of a word, and typing <Esc><F> moves the cursor right to the end of a word. The command line editor considers words to be bounded by spaces or by hyphens.

          Pressing <Ctrl-A> moves the cursor to the beginning of the command line, and pressing <Ctrl-E> moves the cursor to the end of the command line.

          If you want, you can turn off some of the <Ctrl> key and <Esc> key command line editing features with the terminal no editing command. To turn the command line editing feature back on, use the terminal editing command. The editing features are on by default.

          Pressing the up-arrow key (or <Ctrl-P>) moves the cursor backward (up) in the command history buffer; in other words, the preceding command entered will be recalled and placed on the command line. Pressing the down-arrow key (or <Ctrl-N>) moves the cursor forward (down) in the command history buffer.

          IOS, by default, saves our last 10 commands in the appropriate command history buffer. There are two customizations to command history buffer processing. We can turn off command history, and we can change the size of the history buffer. Use the command terminal no history to turn off the command history feature, and use the command terminal history to turn it back on. It is on by default.

          To change the number of lines kept in the command history buffers (both of them), use the terminal history size command.

          Dallas>terminal history size 25

          Dallas>

          The above command tells IOS to save our last 25 commands in the command history buffer. We can use the user mode command show history to see the user mode and privileged mode commands we have typed during the current terminal session.

          Dallas>show history

          terminal no editing

          terminal editing

          terminal no history

          terminal history

          terminal history size 25

          show history

          Dallas>

          The show history command issued in this example shows that the commands covered in this section have been typed on the command line.

        3. Deleting Text
        4. Figure 4-3 shows the command keystrokes used to delete or kill while editing an IOS command line.

          What to Delete

          Left (Backward)

          Right (Forward)

          Character

          <Backspace>

          or <Delete> or <Ctrl-H>

          <Ctrl-D>

          Word

          <Ctrl-W>

          or <Esc><Delete>

          <Esc><D>

          Line (to Beginning or End)

          <Ctrl-U>

          or <Ctrl-X>

          <Ctrl-K>

          <<<Figure 4-3 Deletion Keystrokes>>>

          To delete the character immediately left of the cursor, press the <Backspace> key (or <Delete> or <Ctrl-H>). Pressing <Ctrl-D> deletes the character at the cursor.

          Pressing <Ctrl-W> (or <Esc><Delete>) deletes the characters from the one left of the cursor to the beginning of a word to the left. Typing <Esc><D> deletes the characters to the right from the cursor to the end of a word.

          Pressing <Ctrl-U> (or <Ctrl-X>) deletes the characters from the cursor to the beginning of the command line. If the cursor is at the end of the command line, pressing <Ctrl-U> erases the entire line. Pressing <Ctrl-K> deletes the characters from the cursor to the end of the command line.

          The characters removed by word and line deletion keystrokes are copied into a deletion buffer. The deletion buffer can contain 10 deleted objects. These objects can be pasted into the command line using keystrokes defined in Section 4.3.2.3.

        5. Adding Text
        6. To add characters to the command line, just type them. The characters appear on the command line at the current cursor position.

          Pressing <Ctrl-Y> pastes the last entry from the deletion buffer into the command line at the cursor position. Typing <Esc><Y> without moving the cursor will replace the last object pasted with the next object from the deletion buffer.

        7. Other Text Editing Features

        Just a few other keystroke commands are useful to us. Figure 4-4 shows these.

        Action

        Keystroke

        Redisplay current command line.

        <Ctrl-R>

        or <Ctrl-L>

        Transpose characters.

        <Ctrl-T>

        Make word uppercase.

        <Esc><U>

        Make word lowercase.

        <Esc><L>

        Capitalize a word.

        <Esc><C>

        <<<Figure 4-4 Other Editing Keystrokes>>>

        Pressing <Ctrl-R> (or <Ctrl-L>) will bring up a fresh command line with all the characters that appear on our current command line. Why would we want that? Every once in a while (especially if we are working on a console terminal), IOS sends a message to our screen that appears right in the middle of our command line that we worked so hard on. Even though the message has no effect on the command itself, the message may cause us to lose our place. Rather than just pressing <Enter> to see what happens, the safest thing to do is tell IOS to redisplay the current command line so we can make sure that we typed the line correctly and so we can finish typing the command if needed.

        Pressing <Ctrl-T> will transpose the character to the immediate left of the cursor with the character at the cursor. This comes in handy if you like to type fast and you occasionally get a couple of characters out of order. Just move the cursor to the rightmost character and press <Ctrl-T>; the characters will switch places.

        IOS does not usually care if commands are typed in uppercase, lowercase, or a combination; however, there are a few parameters that are case sensitive. Case-sensitive parameters include passwords, host names, and SNMP community strings.

        Typing <Esc><U> will convert to uppercase all the characters from the cursor to the end of a word. The cursor will be moved right to the end of a word.

        Typing <Esc><L> will convert to lowercase all the characters from the cursor to the end of a word. The cursor will be moved right to the end of a word.

        Typing <Esc><C> will capitalize the character located at the cursor and move the cursor to the end of a word. For example, if the cursor is located at the first character of a word and <Esc><C> is typed, the first character of the word will be made uppercase, and the cursor will be moved to the end of the word.

      3. Abbreviations
      4. All interface types, commands, and command arguments can be abbreviated to the number of letters that make them unique on the router. Being able to abbreviate what we type on a command line saves time and reduces mistakes. Once we get used to abbreviating commands, the real power and efficiency of the IOS command line interface becomes evident. Figure 4-4 shows some examples of common abbreviations.

        Full Name

        Abbreviation

        Show

        sh

        Show protocols

        sh prot

        Terminal length 0

        term len 0

        Enable

        en

        Configure terminal

        conf t

        Ethernet

        e

        Serial

        s

        Tokenring

        to

        Interface ethernet0

        int e0

        Quit

        q

        <<<Figure 4-4 Abbreviation Examples>>>

        Throughout this book, full commands will be shown in the example configurations to help ensure understanding of the commands. The command summary in Appendix A list the common abbreviations for all of the commands used in this book. The only way to become comfortable with the abbreviations is to use them; once you have used them for a while, you figure out what command abbreviations work best for you. IOS never displays command abbreviations in its configuration files.

      5. Getting Help

Several features or the IOS command line interface assist in typing correct commands. Context-sensitive help can be obtained by typing a question mark (?). IOS determines the context by the command mode and then displays appropriate help text. Meaningful (once you get used to them) error messages help us determine and correct mistakes in typed commands.

If a question mark is typed at the end of a command line, there is no need to press <Enter>. The question mark is interpreted as the end of the command line, and help is immediately displayed if it is available.

For very high-level help, typing a question mark by itself on a command line tells IOS to display a list of all of the commands allowed on the current mode's command line. Here are two examples. The first one is for user mode; the second one is for global configuration mode. Only the first page of the help text is shown.

Dallas>?

Exec commands:

access-enable Create a temporary Access-List entry

access-profile Apply user-profile to interface

clear Reset functions

connect Open a terminal connection

disable Turn off privileged commands

disconnect Disconnect an existing network connection

enable Turn on privileged commands

exit Exit from the EXEC

help Description of the interactive help system

lat Open a lat connection

lock Lock the terminal

login Log in as a particular user

logout Exit from the EXEC

mrinfo Request neighbor and version information from a multicast

router

mstat Show statistics after multiple multicast traceroutes

mtrace Trace reverse multicast path from destination to source

name-connection Name an existing network connection

pad Open a X.29 PAD connection

ping Send echo messages

ppp Start IETF Point-to-Point Protocol (PPP)

--More-

Dallas>enable

Dallas#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#?

Configure commands:

aaa Authentication, Authorization and Accounting.

access-list Add an access list entry

alias Create command alias

apollo Apollo global configuration commands

appletalk Appletalk global configuration commands

arap Appletalk Remote Access Protocol

arp Set a static ARP entry

async-bootp Modify system bootp parameters

autonomous-system Specify local AS number to which we belong

banner Define a login banner

boot Modify system boot parameters

bridge Bridge Group.

bstun BSTUN global configuration commands

buffers Adjust system buffer pool parameters

busy-message Display message when connection to host fails

call-history-mib Define call history mib parameters

cdp Global CDP configuration subcommands

chat-script Define a modem chat script

clns Global CLNS configuration subcommands

clock Configure time-of-day clock

config-register Define the configuration register

--More--

If an abbreviation of a command is typed and then followed immediately by a question mark (no separating space), the IOS help facility displays all of the commands or command arguments that begin with the letters typed. That is IOS shows the possible ways of completing the word that ends with the question mark.

Dallas#se?

send setup

Dallas#se

% Ambiguous command: "se"

Dallas#

We typed the letters se? in privileged mode because we wanted IOS to tell us all of the commands allowed here that begin with the letters se. There are two: send and setup. After the help text is displayed we are placed on a command line with the letters se. The cursor is left in the former position of the question mark. If we press <Enter> there, IOS tells us that se is ambiguous. An ambiguous command is an abbreviation that matches more than one command; since IOS does not know which one we want to execute, it executes nothing. We want to execute the send command. The send command is used to send a message to one or more of a router's terminal line devices.

Since our cursor was left immediately after se, we could have just typed nd to finish send. We can get more help for the send command. If a question mark is typed after a command and separated by a space, we are shown the possible arguments for the place in the command held by the question mark.

Dallas#send ?

* All tty lines

<0-9> Send a message to a specific line

aux Auxiliary line

console Primary terminal line

tty Terminal controller

vty Virtual terminal

Dallas#send

The second argument for the send command can be several things including an asterisk (*), a number from 0 to 9, and the word console. Notice that the word console is shown in all lowercase letters. When the first word of a help text line is shown in all lowercase letters, this means that the word itself (or a unique abbreviation of it) can be entered at the question mark's place. Once again after the help, the command line is left as we originally typed it with the cursor in the former position of the question mark.

Help is given for the current argument only, not following arguments. If we want help for an argument further into the command, we repeat the process of typing the question mark.

Dallas#send console ?

<0-0> Send a message to a specific line

Dallas#send console

% Incomplete command.

Dallas#

Putting a space and a question mark after the command send console gives us help text that indicates we need a number between 0 and 0 (that's 0) as the third word of the command. If we just press <Enter> on the resulting command line, IOS tells us that the command is incomplete; this means that the command requires more arguments than we have typed. In this case, the missing argument is the number 0.

However, just to illustrate another IOS command line error message, we will put a 1 as the argument in question.

Dallas#send console 1

^

% Invalid input detected at '^' marker.

Dallas#

The IOS now tells us that our command has a syntax error. IOS also tells us where it thinks the syntax error is in the command. The caret (^) directly under the 1 indicates that IOS found something invalid there. The 1 is incorrect; according to the help text in the preceding example, the argument must be a 0.

When the first word of a help text line is shown in all uppercase letters, IOS wants us to type an alphanumeric value in the question mark's place of the command.

Dallas#telnet ?

WORD IP address or hostname of a remote system

<CR>

Dallas#telnet

The help text WORD, since it is all uppercase letters, means that the first argument for the telnet command is an alphanumeric value that we type. The help text <CR> means that we could also just press <Enter> at this point in the telnet command.

Value types that can appear in the first column of help text are as follows:

    • All lowercase text indicates that the text itself can be typed.
    • All uppercase text indicates that alphanumeric text (not a number) can be typed.
    • Combination uppercase and lowercase text is usually accompanied by a text pattern in parentheses. The text pattern indicates the format of the text that can be typed.
    • A range of numbers in angle brackets (<>) indicates that a numeric value within the range can be typed.
    • The text <CR> indicates that no further arguments are required.

Learning to use the context-sensitive help and to interpret the various CLI error messages takes just a little practice. We can be thankful, however; in the old days (IOS version 8.3), there was no online help, only offline help (the IOS documentation). And we used to have to walk to school barefooted:in the snow:uphill:both ways.

      1. Command Completion
      2. When an abbreviation of a command is typed and then the <Tab> key is pressed, the IOS command line interpreter will complete as much of the command as possible on the command line. The example below illustrates this feature.

        Dallas#con<Tab>

        Dallas#conf<Tab>

        Dallas#configure t<Tab>

        Dallas#configure terminal

        The letters con were typed and then immediately followed by a <Tab>. The abbreviation "con" is not unique; therefore, IOS simply repeats the letters indicating the no more can be automatically added. If we were to use the question mark, we would see that there are two commands that begin with the letters "con": configure and connect.

        If we type f and then <Tab>, IOS uniquely identifies the abbreviation with the configure command and gives us a new command line with the word "configure" followed by a space. The cursor is placed at the end of the space so we can just start typing the next word of the command line.

        Typing t and a <Tab> at the cursor allows the IOS to complete the second word and give us the "configure terminal" command line. Pressing <Enter> here would put us into global configuration mode.

        Figure 4-4 listed conf t as a common abbreviation for the configure terminal command. Pressing the <Tab> key after an abbreviated command or command argument is a good way of verifying the abbreviation before pressing <Enter> and possibly receiving an error message for an incorrect or ambiguous command.

      3. Just Say No
      4. We can very easily reverse the effect of IOS configuration commands. To remove a process or to set an IOS parameter to its default value, we can use the word "no" in front of the configuration command we typed to start the process or set the parameter. As a general rule, any IOS configuration command can be undone just by retyping the command with a "no" in front of it. Here are two examples.

        Example #1

        The command to tell IOS to route IPX traffic is the global configuration command ipx routing. Putting the word "no" at the beginning of that command has just the opposite effect.

        Dallas(config)#no ipx routing

        The global configuration command no ipx routing tells IOS to stop routing IPX packets.

        Example #2

        The command to turn off an interface is the interface configuration command shutdown. Putting the word "no" in front of the command tells the router to bring up the interface (or at least attempt to bring up the interface).

        Dallas(config)#interface ethernet0

        Dallas(config-if)#no shutdown

        The first command tells IOS that we want to type commands for configuring interface ethernet0. The second command, no shutdown, tells the router to bring up the interface.

      5. Screen Overload

One of the most used IOS commands is user mode and privileged mode command show. The show command is used when we want IOS to tell us information about its configuration or operation. Sometimes the information IOS give us will not fit on one page, and sometimes the IOS separates the information it displays to us by forcing us to intervene to get more information. In either case, IOS uses its More function to stop the display of information and allow us to read it before it scrolls off our the screen. Here is an example of the latter case with the show protocols command, which shows us the routed protocols that are running on the router and the interfaces on which the routed protocols have been configured.

Dallas>show protocols

Global values:

Internet Protocol routing is enabled

Appletalk routing is enabled

IPX routing is enabled

--More--

When the display of information is incomplete and IOS wants to stop the display for emphasis or readability, the More function is used as in the above example. The More prompt (--More--) on the last line of the display indicates that there is more information to follow.

We have three options for displaying the remaining information:

    • Press <Enter> to see the another line of information.
    • Press <Space> to see the next page or section of information.
    • Press any other printable-character key to stop the information display.

To see the remaining information one line at a time, we can press <Enter> repeatedly since we get one more line for each <Enter>.

The number of lines we get when we press <Space> depends on the number of lines of information left to display and the number of lines IOS is configured to display on our terminal. The default number of lines is 24, which is normal for a terminal screen. The user mode command terminal is used to set terminal parameters. Use the length argument to set the number of lines displayed on the screen before the More prompt.

Dallas>terminal length 2

Dallas>show protocols

Global values:

Internet Protocol routing is enabled

--More--

Changing the number of lines to be displayed to two is not a normal thing to do; however, sometimes we want to disable the More function so that IOS sends all the lines of information to the terminal without stopping. This is useful when we are using a PC terminal emulator and we want to log IOS output to a file for later reference. Set the terminal length to zero to disable the More function.

Dallas>terminal length 0

Dallas>show protocols

Global values:

Internet Protocol routing is enabled

Appletalk routing is enabled

IPX routing is enabled

BRI0 is administratively down, line protocol is down

BRI0:1 is administratively down, line protocol is down

BRI0:2 is administratively down, line protocol is down

Ethernet0 is up, line protocol is up

Internet address is 172.16.10.1/24

AppleTalk address is 100.10, zone Headquarters

IPX address is AC100A00.0010.7b3a.d4bf

Serial0 is administratively down, line protocol is down

Serial1 is up, line protocol is up

Internet address is 172.16.11.1/24

AppleTalk address is 1001.100, zone WAN

IPX address is AC100B00.0010.7b3a.d4bf

Serial2 is administratively down, line protocol is down

Serial3 is administratively down, line protocol is down

Dallas>

IOS displays all of the requested information without us having to type any extra keystrokes when the More function is turned off. This can be annoying when we ask for information that takes more than about 10 screens to display (depending on your pain threshold). For example, suppose our IP routing table contains 1000 routes; at 24 lines per page, 1000 routes will take over 40 pages to display. If you really want to see the whole table, you can leave More on and press <Space> over 40 times, or you can turn More off and capture the output to a file for better viewing. However, if you want to just see a portion of the table and you have More turned off, you will have to wait for the entire table to display because IOS is not going to pause your screen with the More prompt to allow you to stop the display.

There are two ways to set the terminal length back to its default value of 24; both require the terminal length command.

Dallas>terminal length 24

Dallas>terminal no length

Dallas>

Both of the above commands do the same thing.

Sometimes we have to type a command that is longer than our terminal screen can handle. For example, suppose our terminal screen is 80 characters wide and the command prompt is seven characters; our command can then be 73 characters before we run out of space on the right side of our terminal display. The current version of IOS has a maximum command length of 253 characters. If we are out of space on the screen, how can we type the long command?

IOS has a special horizontal-scroll feature that allows those long commands to be entered. When we are typing a command and the command exceeds our terminal width, IOS scrolls the command to the left and allows us to continue typing at the end of the command.

When the line is scrolled to the left, IOS puts a dollar sign ($) at the beginning of the command to show us that the command has been scrolled and only some of the command is being displayed. If we move the cursor to the beginning of the long command, IOS scrolls the command to the right and displays a dollar sign ($) at the right side of our screen to inform us that only part of the command line is being displayed. Section 4.3.2.1 shows commands for moving around on a command line.

The default width of a terminal device is 80 characters. The width can be changed for the current session with the user mode command terminal width. The terminal width command has one argument - the number of characters wide the terminal is.

    1. Logging Out

We have seen plenty about how things look and what to do after we get logged in to an IOS-based router, so we might as well see how to log out. There are three user mode commands that can be used to log out of an IOS terminal session.

    • Exit
    • Logout
    • Quit

Any one of these three commands can be typed in either user mode or privileged mode to stop and exit a terminal session.

By default, all terminal sessions will time out after 10 minutes of inactivity. The terminal session inactivity timeout can be changed with the line configuration command exec-timeout, which will be covered in Chapter 6.

    1. Conclusion
    • Log in to a router from a console terminal by pressing <Enter> and possibly typing a correct password.
    • Complete all commands by pressing <Enter> at the end of them.
    • You can check IOS status for most things from user mode.
    • If you want to make configuration changes, type enable and a correct password to go to privileged mode, and then type configure terminal to go to global configuration mode.
    • Type the necessary configuration commands to accomplish your objective.
    • Remember that if you are configuring an entity such as a process or a device, you must be in the sub-configuration appropriate for the entity. For example, you must be in interface configuration mode to configure an interface, and you must be in line configuration mode to configure a line.
    • Press <Ctrl-Z> (or end)to exit configuration mode.
    • Abbreviate commands and their arguments whenever possible; abbreviations will save time and reduce typographical errors (typos).
    • While in any of the command modes, remember your two little friends: the question mark and the up-arrow. Use the question mark to get context-sensitive help, and use the up-arrow (or <Ctrl-P>) to recall commands from the command history buffer.
    • When you are finished with the terminal session, type exit (or logout or quit) to log out.

Previous | Content | Next