EdgeRouter - Add Commands to EdgeOS


Overview


Readers will learn how to add custom commands to the EdgeOS command line interface.

NOTES & REQUIREMENTS:
Applicable to the latest EdgeOS firmware on all EdgeRouter models. Please see the Related Articles below for more information.
 
Device used in this article:

Adding Custom Commands


Back to Top

In this example, an Operational Mode command is added to the command line that resets the console session (clear screen).

CLI: Access the Command Line Interface. You can do this using the CLI button in the GUI or by using a program such as PuTTY.

When first running the reset command, a single option exists:

ubnt@edgerouter:~$ reset ?
Possible completions:
openvpn Reset OpenVPN

1. Log in as the root user.

sudo su

2. Navigate to the /opt/vyatta/share/vyatta-op/templates/reset directory.

cd /opt/vyatta/share/vyatta-op/templates/reset
NOTE: Commands added to the reset sub-directory will add them to the reset ? command tree.

3. Create a new directory named console.

mkdir console

4. Navigate to the newly created console directory.

cd console

5. Create a new file named node.def in the console directory and add the following contents (note the empty line at the bottom).

cat > node.def
help: Reset the Console
run: /usr/bin/reset

6. Use CTRL+D to exit out and save the script.

7. Exit back to the EdgeOS command line.

exit

Verify the configuration by trying out the new command:

ubnt@edgerouter:~$ reset ?
Possible completions:
console Reset the Console
openvpn Reset OpenVPN

ubnt@edgerouter:~$ reset console

Related Articles


Back to Top

EdgeRouter - Configuration and Operational Mode

EdgeRouter - Run Operational Mode Command from Scripts

Intro to Networking - How to Establish a Connection Using SSH


We're sorry to hear that!