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 reerence.
C
Use conguration groups to represent common pieces o conguration and to reduce the size o your conguration le.Use the re0 and re1 conguration groups to restrict conguration to a particular routing engine.
Use conguration groups to group related conguration statements.
Use conguration groups to supply deault values.
Use thedisplay inheritanceCLI pipe to show where conguration groups are inherited.
In conguration mode, use thedisplay detailCLI pipe to show more inormation about the congured values.
In conguration mode, use thecomparepipe to display dierences between the candidate conguration and the committed conguration.
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 conguration.
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 inormation about syslog messages.
Usehelp aproposto show commands related to a topic.
Usehelp topicto display Junos documentation on a topic.
Usehelp referenceto display the Junos reerence documentation on a topic.
Use CLI pipes to display more inormation 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 DayOne:JunosTips,Techniques,andTemplates2011
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 inormation.
Use theholdCLI pipe to hold the cli at the more prompt at the bottom o the output. This is useul 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 rene your search by discarding irrelevant lines.
Use the TAB key to autocomplete interace names in operational mode.
Use the TAB key to autocomplete CLI commands.
Use therollbackcommand to restore previous congurations.
In conguration mode, typerollback ?to see when previous congu-rations were committed, and by whom.
Use therollbackcommand to discard uncommitted changes by reloading the most recently committed conguration.
In conguration mode, thestatuscommand displays who is editing the conguration and where in the hierarchy they are working.
Useconfigure privateto edit a private copy o the conguration, so your work will be unaected by others editing the conguration.
Useconfigure exclusiveto ensure you are the only one editing the conguration. Other users are blocked rom making changes.
In conguration mode, use thecopycommand to replicate congura-tion statements.
In conguration mode, use theinsertcommand to insert a new conguration into existing lists.
In conguration mode, use therenamecommand to give conguration a new identier. For example,rename interface 0/0/1 to fe-0/0/2.
In conguration mode, thedeletecommand with no arguments will delete the entire conguration hierarchy under the current location.
Use commit checkto check conguration or correctness without making it active.
In conguration mode, usequit configuration-modeto exit congura-tion mode rom any level o the hierarchy.
Use a URL to load conguration using tp. For example,load merge
ftp://user:password@host/filename.
Use a URL to load conguration 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 (conguration) 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 platorms in a Virtual Chassis conguration, you can use
pc0:, pc1:, pc2:, etc. to save les to the appropriate member switch.
In conguration mode, the[edit]banner displays the current location in the conguration hierarchy.
Usecommit confirmedto ensure that conguration 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 interace statistics.
Use therequest system logoutcommand to orcibly log a user out o
the router.
74 DayOne:JunosTips,Techniques,andTemplates2011
Userequest system snapshotto make a snapshot o the running system on the hard disk drive (or other alternate media).
Use thedeactivatecommand to mark conguration statements inactive. The statements stay in the conguration, but are eectively commented out.
Use theactivatecommand to clear the inactive marker rom congu-ration statements. This is the opposite o thedeactivatecommand.
Usetopto get to the top o the conguration 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 conguration hierarchy without moving the current edit point. You can useup <n>
<cmd>also.
Usetop edit <path>to move to a conguration statement relative to the top o the hierarchy.
Useup <n> edit <path>to move to a conguration relative to the statement<n>levels above the current edit point.
Usecommit at <time>to perorm a commit automatically at a desig-nated time. You can useclear committo cancel a scheduled commit.
Usecommit syncto keep conguration les synchronized between master and slave routing engines.
Usecommit and-quitto exit conguration mode ater the commit has succeeded. I the commit ails you are let in conguration 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 unied patch style;show | comparegenerates this style.
Useshow configuration | match { to see a quick overview o your conguration hierarchy. Use 'C' at the more prompt to clear the match.
Userequest system software validate to validate the incoming sotware against the current conguration 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 congu-ration mode.
In conguration mode, userun show cli historyto view previously executed commands.
Useshow configuration | except SECRET-DATA to exclude congura-tion statements tagged with the line comment marking them as
sensitive.
Use theapply-groupsstatement at any level o the conguration hierarchy to inherit conguration statements rom a conguration group.
Use theapply-groups-exceptstatement at any level except the top level o the conguration hierarchy to turn o inheritance o congu-ration statements rom congucongu-ration groups.
Use theapply-pathstatement to dene a prex list containing prexes extracted rom any conguration path.
Use thehelp tip clito see more CLI tips.
Use the conguration statement[system login class <name> login-tip] to turn on CLI tips or a login class.
Use wildcarded identiers in conguration 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 dicult.
Use thewildcard deletecommand in conguration mode to delete a number o interaces using a regular expression. The regular expres-sion is used to match the interace names.
Useload merge <filename>withrelativeoption to avoid having to type the complete conguration hierarchy.
76 DayOne:JunosTips,Techniques,andTemplates2011
Include theconfigurationstatement at the [system archival] hierar-chy level to have the router automatically copy conguration 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 platorms, well, you can submit your own tip or the next edition o this book. ; )
Use thereplacecommand in conguration 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 identier and not surrounding keywords. (So,^10\.210\.38\.12$
would match the neighbor IP address 10.210.38.12.)