ER-X CLI and Tab completion

The CLI in ER-X (and other Edgerouters) separates into two modes: configuration and operation. In configuration mode, we change router's settings. In operation mode, only view system status and settings. By default immediately after login, we are in operation mode. Set up SSH auto authentication if you have not.

To get in configuration mode, need to enter explicitly. Before exit the mode, we want changes to take immediate effect. Also want them to survive reboots and firmware upgrade. Hence, the idiom of config change in ER-X is a five-step lifecycle:

Step 1: Enter configuration mode:

[email protected]:~ $ configure

Step 2: Make a thousand changes for the tinker.


Step 3: Commit the changes to take immediate effect.

[email protected]:~ $ commit

Step 4: Save the changes to persistent store:

[email protected]:~ $ save

Step 5: Leave the configuration mode (and back to operation mode):

[email protected]:~ $ exit

The five-step cycle initially appears cumbersome. I tend to agree it is a well thought process after a few days' use with maybe hundreds of config changes.

Save the changes to persistent store is essential. The changes actually get written to a file, /config/config.boot. Once save there the changes will survive reboots and firmware upgrades. A thousand changes mean tens of thousands command lines. A tinker surely does not want to re-type all even if only cut and paste from a text file stored on PC - one trick I picked up naturally and seems practiced by many other owners.

Tab Completion

ER-X or Edgerouters run EdgeOS which is based on Debian plus a thin layer called Vyatta. The verbosity of the Vyatta CLI requires little time to get used to it because I did not grow up with such a CLI in routers. Compare to the CLI of DOS and Windows Powershell, EdgeOS/Vyatta CLI is very pleasant to use - friendly and much less error prone.

The joy in CLI thanks to the built-in tab completion constructed on a well structured config tree. As users, we probably worry less about how a config tree is built. EdgeOS developers essentially spend part of dedicated time on getting it right and convenient to use.

*Operation mode right after login. Press `?` to get a list of commands in current mode*

In both configuration and operation modes, press tab (and tab... or space then ?) completes next sub-command. Or displays a list of candidates if next sub-command is ambiguous.

This is very good visual hint - lack of a better metaphor in CLI. As a user, I go with the essence of a configuration change rather than need memorising command syntax and typing it accurately or going through iterations of trial and error until frustration.


There is a catch that frustrates seasonal Linux warriors. Tab completion only work for EdgeOS/Vyatta commands i.e. those defined in config trees.

Unlike MikroTik's locked-down approach in its CLI, EdgeOS/Vyatta CLI does not want to jail its users. The CLI adds on top of standard Bash. Users can run Linux commands and operate on files.

But for non-root users in EdgeOS, tab completion does not go beyond built-in commands in current mode. Linux commands, files and paths will not auto complete. Ubiquiti mentions a way to offer non-root users tab completion on everything. That does not work for me or I did not get it to work correctly. The other way is always sudo to root:

[email protected]:~ $ sudo -i

Then in the root shell, I get tab completion to both EdgeOS commands and Linux files, paths and commands.

I seldom sudo -i unless absolutely necessary.

comments powered by Disqus