CLI basics
This section describes the basic features and characteristics of the CLI environment.
Getting help
Press the question mark (?) key to display command help and complete commands.
- Press the question mark (?) key at the command prompt to display a list of the commands available and a description of each command.
- Enter a command followed by a space and press the question mark (?) key to display a list of the options available for that command and a description of each option.
- Enter a command followed by an option and press the question mark (?) key to display a list of additional options available for that command option combination and a description of each option.
- Enter a question mark after entering a portion of a command to see a list of valid complete commands and their descriptions. If there is only one valid command, it will be automatically filled in.
Shortcuts and key commands
| Shortcut key | Action |
|---|---|
|
? |
List valid complete or subsequent commands. If multiple commands can complete the command, they are listed with their descriptions. |
|
Tab |
Complete the word with the next available match. Press multiple times to cycle through available matches. |
|
Up arrow or Ctrl + P |
Recall the previous command. Command memory is limited to the current session. |
|
Down arrow, or Ctrl + N |
Recall the next command. |
|
Left or Right arrow |
Move the cursor left or right within the command line. |
|
Ctrl + A |
Move the cursor to the beginning of the command line. |
|
Ctrl + E |
Move the cursor to the end of the command line. |
|
Ctrl + B |
Move the cursor backwards one word. |
|
Ctrl + F |
Move the cursor forwards one word. |
|
Ctrl + D |
Delete the current character. |
|
Ctrl + C |
Abort current interactive commands, such as when entering multiple lines. If you are not currently within an interactive command such as |
|
\ then Enter |
Continue typing a command on the next line for a multiline command. For each line that you want to continue, terminate it with a backslash ( \ ). To complete the command, enter a space instead of a backslash, and then press Enter. |
Command abbreviation
You can abbreviate words in the command line to their smallest number of non-ambiguous characters.
For example, the command diagnose system status could be abbreviated to d sy s.
Adding and removing options from lists
When configuring a list, the set command will remove the previous configuration.
For example, if a user group currently includes members A, B, and C, the command set member D will remove members A, B, and C. To avoid removing the existing members from the group, the command set members A B C D must be used.
To avoid this issue, the following commands are available:
|
append |
Add an option to an existing list. For example, |
|
select |
Clear all of the options except for those specified. For example, |
|
unselect |
Remove an option from an existing list. For example, |
Environment variables
The following environment variables are support by the CLI. Variable names are case-sensitive.
|
$USERFROM |
The management access type ( |
|
$USERNAME |
The account name of the administrator that configured the item. |
|
$SerialNum |
The Container FortiOS serial number. |
For example, to set the Container FortiOS host name to its serial number, use the following CLI command:
config system global
set hostname $SerialNum
end
Special characters
The following characters cannot be used in most CLI commands: <, >, (, ), #, ', and "
If one of those characters, or a space, needs to be entered as part of a string, it can be entered by using a special command, enclosing the entire string in quotes, or preceding it with an escape character (backslash, \).
To enter a question mark (?) or a tab, Ctrl + V or Ctrl + Shift + - (depending on the method being used to access the CLI) must be entered first.
|
|
Question marks and tabs cannot be copied into the CLI Console or some SSH clients. They must be typed in. |
| Character | Keys |
|---|---|
|
? |
Ctrl + V or Ctrl + Shift + - then ? |
|
Tab |
Ctrl + V then Tab |
|
Space (as part of a string value, not to end the string) |
Enclose the string in single or double quotation marks: Precede the space with a backslash: |
|
' (as part of a string value, not to begin or end the string) |
\' |
|
" (as part of a string value, not to begin or end the string) |
\" |
|
\ |
\\ |