• No results found

Template: 97 CLI Tips

In document Day One - Junos Tips, Techniques (Page 73-79)

One o the Junos developer gurus contributed 97 CLI tips. While some are covered elsewhere, they are duplicated here in their entirety

because they make such a handy reerence.

C

Use conguration groups to represent common pieces o conguration and to reduce the size o your conguration le.

Use the re0 and re1 conguration groups to restrict conguration to a particular routing engine.

Use conguration groups to group related conguration statements.

Use conguration groups to supply deault values.

Use thedisplay inheritanceCLI pipe to show where conguration groups are inherited.

In conguration mode, use thedisplay detailCLI pipe to show more inormation about the congured values.

In conguration mode, use thecomparepipe to display dierences between the candidate conguration and the committed conguration.

Use CTRL-R in the CLI to search the command line history or a matching command.

Use ESC-/ in the CLI to expand strings into matching words rom the command line history.

Use theannotatecommand to add comments to your conguration.

Use#in the beginning o a line in command scripts to cause the rest o 

the line to be ignored.

Usehelp syslog to show more inormation about syslog messages.

Usehelp aproposto show commands related to a topic.

Usehelp topicto display Junos documentation on a topic.

Usehelp referenceto display the Junos reerence documentation on a topic.

Use CLI pipes to display more inormation about commands, control the automore eature, save CLI output, and more.

Use thedisplay xmlCLI pipe to show the equivalent XML output or any CLI command.

Use theno-moreCLI pipe to disable the CLI’smorecapability and let the multiple pages o output scroll without stopping.

Use thematchCLI pipe to display lines matching a pattern.

Use theexceptCLI pipe to display lines that do not match a pattern.

Use thesaveCLI pipe to save output to a local or remote le.

Use thecountCLI pipe to count the number o lines in the output.

Use multiple CLI pipes to build complex commands. For example:

show interfaces | match Description | count.

When displaying a subset o lines using the matchorexceptCLI pipes, type'C'at the more prompt to display all lines.

Type'G'at the more prompt to jump to the bottom o the output.

Type'g'at the more prompt to jump to the top o the output.

Type'b'at the more prompt to go backwards one page.

72 DayOne:JunosTips,Techniques,andTemplates2011

Type '/' at the more prompt to search or a string in the rest o the output.

Type '?' at the more prompt to search backwards or a string.

Type's'at the more prompt to save the current display to a le or url.

Type'N'at the more prompt to turn the more o or the rest o the current command.

Type'h'at the more prompt to display help inormation.

Use theholdCLI pipe to hold the cli at the more prompt at the bottom o the output. This is useul when displaying less than one screen o 

data.

Type'm'at the more prompt to give additional regular expressions against which to match output.

Type'e'at the more prompt to give additional regular expressions against which to exclude output.

When hunting through large log les, use the'm'and'e'keys to iteratively rene your search by discarding irrelevant lines.

Use the TAB key to autocomplete interace names in operational mode.

Use the TAB key to autocomplete CLI commands.

Use therollbackcommand to restore previous congurations.

In conguration mode, typerollback ?to see when previous congu-rations were committed, and by whom.

Use therollbackcommand to discard uncommitted changes by reloading the most recently committed conguration.

In conguration mode, thestatuscommand displays who is editing the conguration and where in the hierarchy they are working.

Useconfigure privateto edit a private copy o the conguration, so your work will be unaected by others editing the conguration.

Useconfigure exclusiveto ensure you are the only one editing the conguration. Other users are blocked rom making changes.

In conguration mode, use thecopycommand to replicate congura-tion statements.

In conguration mode, use theinsertcommand to insert a new conguration into existing lists.

In conguration mode, use therenamecommand to give conguration a new identier. For example,rename interface 0/0/1 to fe-0/0/2.

In conguration mode, thedeletecommand with no arguments will delete the entire conguration hierarchy under the current location.

Use commit checkto check conguration or correctness without making it active.

In conguration mode, usequit configuration-modeto exit congura-tion mode rom any level o the hierarchy.

Use a URL to load conguration using tp. For example,load merge

ftp://user:password@host/filename.

Use a URL to load conguration using http. For example,load merge

http://user:password@host/filename.

Use a URL to save output using tp. For example,show route summary

| save ftp://user:password@host/filename.

Useuser@host: syntaxto save output using scp. For example,show

route summary | save user@host:filename.

Use a: to save output to the PCMCIA card. For example,show route

summary | save a:filename.

Use b: to save output to the second (conguration) partition on the PCMCIA card. For example,show configuration | save b:filename. Use re0: and re1: to save output to the other routing engine. For

example,show route summary | save re1:filename.

On EX-series platorms in a Virtual Chassis conguration, you can use

pc0:, pc1:, pc2:, etc. to save les to the appropriate member switch.

In conguration mode, the[edit]banner displays the current location in the conguration hierarchy.

Usecommit confirmedto ensure that conguration changes do not disconnect the router rom the network.

Use themonitorcommand to monitor system log les or changes.

Use themonitor interfacecommand to display real-time interace statistics.

Use therequest system logoutcommand to orcibly log a user out o 

the router.

74 DayOne:JunosTips,Techniques,andTemplates2011

Userequest system snapshotto make a snapshot o the running system on the hard disk drive (or other alternate media).

Use thedeactivatecommand to mark conguration statements inactive. The statements stay in the conguration, but are eectively commented out.

Use theactivatecommand to clear the inactive marker rom congu-ration statements. This is the opposite o thedeactivatecommand.

Usetopto get to the top o the conguration hierarchy. Useupto move up one level, andup <count>to move up a number o levels.

Usetop <cmd>to issue a command at the top o the conguration hierarchy without moving the current edit point. You can useup <n>

<cmd>also.

Usetop edit <path>to move to a conguration statement relative to the top o the hierarchy.

Useup <n> edit <path>to move to a conguration relative to the statement<n>levels above the current edit point.

Usecommit at <time>to perorm a commit automatically at a desig-nated time. You can useclear committo cancel a scheduled commit.

Usecommit syncto keep conguration les synchronized between master and slave routing engines.

Usecommit and-quitto exit conguration mode ater the commit has succeeded. I the commit ails you are let in conguration mode.

Usecommit comment <text>to add a log message to this commit.

Useload <style> terminalto load statements rom the terminal using cut-n-paste. Use Control-D to mark the end o data.

Useload patchto load structured patch les that ollow the unied patch style;show | comparegenerates this style.

Useshow configuration | match { to see a quick overview o your conguration hierarchy. Use 'C' at the more prompt to clear the match.

Userequest system software validate to validate the incoming sotware against the current conguration without impacting the running system.

Userequest message user <foo>to send a text message to one user.

Userequest message allto send to all current users.

Userequest messageCLI pipe to replicate output o show commands to other users.

Use theresolveCLI pipe to resolve IP addresses into hostnames.

In operational mode, use show cli historyto view previously execut-ed commands.

Userun <command>to run operational mode commands rom congu-ration mode.

In conguration mode, userun show cli historyto view previously executed commands.

Useshow configuration | except SECRET-DATA to exclude congura-tion statements tagged with the line comment marking them as

sensitive.

Use theapply-groupsstatement at any level o the conguration hierarchy to inherit conguration statements rom a conguration group.

Use theapply-groups-exceptstatement at any level except the top level o the conguration hierarchy to turn o inheritance o congu-ration statements rom congucongu-ration groups.

Use theapply-pathstatement to dene a prex list containing prexes extracted rom any conguration path.

Use thehelp tip clito see more CLI tips.

Use the conguration statement[system login class <name> login-tip] to turn on CLI tips or a login class.

Use wildcarded identiers in conguration groups to allow one statement to be applied in multiple locations.

Use thematchandexceptCLI pipelines with themonitor start

command to automatically lter logging output.

Use Escape-Q to toggle log output on the current terminal. Excessive log output can make typing dicult.

Use thewildcard deletecommand in conguration mode to delete a number o interaces using a regular expression. The regular expres-sion is used to match the interace names.

Useload merge <filename>withrelativeoption to avoid having to type the complete conguration hierarchy.

76 DayOne:JunosTips,Techniques,andTemplates2011

Include theconfigurationstatement at the [system archival] hierar-chy level to have the router automatically copy conguration les to a FTP or SCP server.

UseM-.to insert last word o the previous command. RepeatM-.to scroll through last word o each command in the history. To do the same or Nth word, precedeM-.withM-n.

One quick note: In this tip, the submitter uses the notationM-x.This notation is telling you to hold down your meta key and press t he x key.

What is your meta key? I you are an Emacs power-user, you already know how to handle this. For most people with Windows PCs, you can press and release the Escape key, and then press the x key. On some (or most?) Sun keyboards, you may use the diamond key as the meta key. For other platorms, well, you can submit your own tip or the next edition o this book. ; )

Use thereplacecommand in conguration mode to globally replace a pattern with a new character string. The pattern can be a regular expression.

As noted elsewhere, the regular expression matches just the user-sup-plied identier and not surrounding keywords. (So,^10\.210\.38\.12$

would match the neighbor IP address 10.210.38.12.)

In document Day One - Junos Tips, Techniques (Page 73-79)