Cisco Command Christmas Calendar #5: show users / clear line

Today's post ties together with the previous one. The show users command displays information about the active lines on the device. This command displays the line number, connection name, idle time, hosts (including virtual access interfaces), and terminal location. An asterisk (*) indicates the current terminal session.

Router# show users
      Line          User         Host(s)        Idle Location
      0 con 0                       idle
*    2 vty 0        user1          idle            0   SERVICE1.CISCO.COM

The show users all command specifies that all lines are displayed, regardless of whether anyone is using them.

Router# show users all
Line      User          Host(s)      Idle  Location
0 vty 0         user1        idle            0    SERVICE1.CISCO.COM
    1 vty 1
   2 con 0
   3 aux 0
   4 vty 2

The clear line command is simply used to close a specified virtual terminal (VTY) session. This is especially useful if you have open idle sessions due to the no exec-timeout command from the previous post. Example:

SW1#show users
    Line       User       Host(s)              Idle       Location
*  0 con 0                idle                 00:00:00
   2 vty 0                idle                 00:05:50 10.1.1.2
   3 vty 1                idle                 00:01:57 10.1.1.3
   4 vty 2                idle                 00:01:54 10.1.1.4

  Interface    User               Mode         Idle     Peer Address

Let's clear the connection originating from 10.1.1.3. This can be done either using the line number or the vty number.

SW1#clear line ?
  <0-6>        Line number
  async-queue  Clear queued rotary async lines
  aux          Auxiliary line
  console      Primary terminal line
  vty          Virtual terminal

Option 1:

SW1#clear line 3
[confirm]
 [OK]
SW1#
SW1#show users
    Line       User       Host(s)              Idle       Location
*  0 con 0                idle                 00:00:00
   2 vty 0                idle                 00:07:01 10.1.1.2
   4 vty 2                idle                 00:02:56 10.1.1.4

  Interface    User               Mode         Idle     Peer Address

Option 2:

SW1#clear line vty 1
[confirm]
 [OK]
SW1#show users
    Line       User       Host(s)              Idle       Location
*  0 con 0                idle                 00:00:00
   2 vty 0                idle                 00:09:18 10.1.1.2
   4 vty 2                idle                 00:05:13 10.1.1.4

  Interface    User               Mode         Idle     Peer Address

The host originating the session will receive a message that the connection was closed.

SW3#telnet 10.1.1.1
Trying 10.1.1.1 ... Open


SW1#
[Connection to 10.1.1.1 closed by foreign host]


Cisco documentation: show users and clear line

Comments