Sunday, October 18, 2015

VI



VI REFERENCE CHEAT SHEET

VI is your friend if you are working on Linux or Unix platforms.



visual (vi) editor
vi is a command line editor that is widely-used on Linux/Unix based platforms and is automatically loaded with virtually all versions of Linux/Unix.

Here are some of the most common
commands to assist you in getting started:

         INPUT MODE COMMANDS
         i        Inserts text before cursor
         I        Inserts text at the beginning of the current line
         a        Appends text after cursor position
         A       Appends text at the end of the current line
         o       Opens a line below
         O      Opens a line above

         DELETE COMMANDS
         dw     Deletes Word from current position
         dd     Deletes the entire line
         D      Deletes from current position to end of current line
         x       Deletes character at cursor position

         CHANGE TEXT
         cw     Changes word
         cc      Changes the line
         C       Changes to the end of the line
         r        Replaces the single character under the cursor
         J        Joins lines

         MOVE CURSOR
         e        Moves to the end of the word
         w       Moves to the next word
         $       Moves to the end of the line
         l        Moves one space right
         k       Moves one line up
         j        Moves one line down
         h       Moves one space left
         H      Moves cursor to the top line on the screen
         L       Moves cursor to the bottom line on the screen
         M      Moves cursor to the middle line on the screen
         ^       Moves cursor to the beginning of the line
         fx      Moves cursor to first occurance of x

         MARKING LOCATIONS
         mx    Marks current position with letter x
         `x      Moves cursor to mark x
         'x       Moves cursor to beginning of the line containing mark x
        
         SCREEN CONTROL
         CTRL-d               Scrolls forward one-half screen
         CTRL-u               Scrolls backwards one half screen
         CTRL-f               Scrolls forward one screen
         CTRL-b               Scrolls backward one screen
         CTRL-l                Refreshes screen
         z                 Redraws screen with current line on top
         z-                Redraws screen with current line on bottom
         [number]G Places cursor at line number

         MOVING TEXT
         yy               Yanks one line into buffer
         p                 Puts yanked lines below cursor position
         P                Puts yanked lines above current position
        
         ESCAPE OR LAST LINE MODE COMMANDS
         :w[file]       Writes current buffer as file
         :q                Quits file
         :q!              Quits file without saving changes
         :wq             Writes changes to file and quits
         :r[file]         Reads file  
         :e[file]        Edits file
         :!command Executes a command in the shell
         :n                Moves to line n
         :f                Prints out current line and file name

         INFO
         CTRL-G              Shows size of file, current filename, and current line

         OTHER FUNCTIONS
         u                 Undoes last command
         /string                  Searches forward for string
         ?string                 Searches backward for string
         n                 Finds next string
         .                  Repeats last command
         ESC           Moves from text input mode to command mode.
                            ** Note ** Use this to enter Last Line mode
         CTRL-V              Inserts any character including special characters
         ~                Changes character to opposite case
         ZZ              Saves file and exits


         TIPS
         5dd             Deletes five lines
         10yy           Yanks 10 lines
         10CTRL-d scrolls down ten lines

         QUICK BASIC TUTORIAL
         $vi new.file          - this command is used at the command line and tells the editor
                              to open and places you in full screen mode at which point you
                              can begin creating the file named new.file

         i                  - to insert text
         The quick brown fox jumped over the lazy dogs back - text
         ESCAPE             - to enter last line mode
         :wq             - to write and exit the file

            $                      - back to the command line

Saturday, October 3, 2015


JUNOS Built in Time Domain Reflectometer (TDR)

One handy feature that often goes overlooked and unused is the built-in TDR function in Juniper switches.

Here is a quick example on how to start the TDR test and then how to show the test results.

For comparison I have performed one on a cable that is jacked up against a known good cable between two EX2200-C's

##Set the cli timestamp so we get an idea of how long this takes
{master:0}
junspace@CDN1> set cli timestamp 

Oct 03 10:49:04


CLI timestamp set to: %b %d %T

##Initiate the test
junspace@CDN1> request diagnostics tdr start interface ge-0/0/4
Oct 03 10:49:22 

Interface TDR detail:
Test status                     : Test successfully executed  ge-0/0/4 

##Show the results
{master:0}
junspace@CDN1> show diagnostics tdr interface ge-0/0/4
Oct 03 10:49:43 

Interface TDR detail:
Interface name                  : ge-0/0/4
Test status                     : Started

{master:0}
junspace@CDN1> show diagnostics tdr interface ge-0/0/4    
Oct 03 10:49:50

Interface TDR detail:
Interface name                  : ge-0/0/4
Test status                     : Passed
Link status                     : Down
MDI pair                        : 1-2
  Cable status                  : Open
  Distance fault                : 0 Meters
  Polartiy swap                 : N/A
  Skew time                     : N/A
MDI pair                        : 3-6
  Cable status                  : Open
  Distance fault                : 0 Meters
  Polartiy swap                 : N/A
  Skew time                     : N/A
MDI pair                        : 4-5
  Cable status                  : Open
  Distance fault                : 0 Meters
  Polartiy swap                 : N/A
  Skew time                     : N/A
MDI pair                        : 7-8
  Cable status                  : Short on Pair-3
  Distance fault                : 0 Meters
  Polartiy swap                 : N/A
  Skew time                     : N/A
Channel pair                    : 1
  Pair swap                     : N/A
Channel pair                    : 2
  Pair swap                     : N/A
Downshift                       : N/A

##RESULTS: The test completed but we can see that there is a short on Pair3 and the other MDI Pairs are open.  Now for a good cable to compare against

{master:0}
junspace@CDN1> request diagnostics tdr start interface ge-0/0/11
Oct 03 10:50:48 

Interface TDR detail:
Test status                     : Test successfully executed  ge-0/0/11 

{master:0}
junspace@CDN1> show diagnostics tdr interface ge-0/0/11
Oct 03 10:51:00 

Interface TDR detail:
Interface name                  : ge-0/0/11
Test status                     : Started

{master:0}
junspace@CDN1> show diagnostics tdr interface ge-0/0/11    
Oct 03 10:51:09

Interface TDR detail:
Interface name                  : ge-0/0/11
Test status                     : Started

{master:0}
junspace@CDN1> show diagnostics tdr interface ge-0/0/11    
Oct 03 10:51:14

Interface TDR detail:
Interface name                  : ge-0/0/11
Test status                     : Started

{master:0}
junspace@CDN1> show diagnostics tdr interface ge-0/0/11    
Oct 03 10:51:19

Interface TDR detail:
Interface name                  : ge-0/0/11
Test status                     : Passed
Link status                     :  UP
MDI pair                        : 1-2
  Cable status                  : Normal
  Distance fault                : 0 Meters
  Polartiy swap                 : Normal
  Skew time                     : 0 ns
MDI pair                        : 3-6
  Cable status                  : Normal
  Distance fault                : 0 Meters
  Polartiy swap                 : Normal
  Skew time                     : 8 ns
MDI pair                        : 4-5
  Cable status                  : Normal
  Distance fault                : 0 Meters
  Polartiy swap                 : Normal
  Skew time                     : 0 ns
MDI pair                        : 7-8
  Cable status                  : Normal
  Distance fault                : 0 Meters
  Polartiy swap                 : Normal
  Skew time                     : 0 ns
Channel pair                    : 1
  Pair swap                     : MDI
Channel pair                    : 2
  Pair swap                     : MDI
Downshift                       : No Downshift


## There we go all normal. TDR diagnostics is a good tool when you don't have a fluke around and you have an access cable that is acting up. Just give it a test.