FortiOS CLI basics: config, edit, set, end
This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.
Key points
- FortiOS configuration is a tree:
configenters a section,editopens a table entry,setassigns a value. nextsaves the entry and stays in the table,endsaves and leaves the section,abortleaves without saving.showprints only changed settings,show full-configurationprints everything including defaults;getlists settings and values.executeperforms an action (ping, reboot, backup) anddiagnoseis for troubleshooting. Neither changes the configuration.- In the default mode (
cfg-save automatic) a change takes effect and is saved as soon as you typeend. There is no separate "write memory".
The key difference if you come from Cisco
Cisco IOS has modes: enable, configure terminal, interface g0/0. A command takes effect at once, but you need a separate copy running-config startup-config to keep it.
FortiOS works differently. It has a configuration tree, and every setting has its own address. The device name lives in the system global section; the IP of port2 lives in the port2 entry of the system interface table.
| Cisco IOS | FortiOS | |
|---|---|---|
| Entering configuration | enable → configure terminal | Not needed, type config ... directly |
| Assigning a value | hostname R1 | set hostname FGT-HQ |
| Removing a value | no ... | unset ... |
| When it takes effect | As soon as it is typed | On next or end |
| Saving | copy run start | Automatic (on end) |
| Viewing | show running-config | show, get |
Five core words
config <path>: enters a section, for exampleconfig system global.edit <name>: opens a table entry. If the entry does not exist, it creates a new one.set <option> <value>: assigns a value.unset <option>returns it to the default.next: saves the entry and stays in the table (so you can move to another entry).end: saves and leaves the section.
There are two kinds of sections. A single section (such as system global) has no edit; you type set directly. In a table (such as system interface or firewall policy) you first select an entry with edit.
Example: renaming the device
FortiGate-100F # config system global FortiGate-100F (global) # set hostname FGT-HQ FortiGate-100F (global) # end FGT-HQ #
Notice that the prompt shows where you are in brackets, and the name changed only after end. Without end, nothing would have changed.
Example: giving an interface an IP
FGT-HQ # config system interface FGT-HQ (interface) # edit port2 FGT-HQ (port2) # set mode static FGT-HQ (port2) # set ip 10.10.10.1 255.255.255.0 FGT-HQ (port2) # set allowaccess ping https ssh FGT-HQ (port2) # set alias LAN FGT-HQ (port2) # next FGT-HQ (interface) # end FGT-HQ #
The mask can be written two ways: 10.10.10.1 255.255.255.0 or 10.10.10.1/24. FortiOS accepts both and stores the first form in the configuration.
Watch out on a real device: edit does not complain about a name that does not exist, it creates a new entry. If you type edit port22 (meaning port2) and the device has no such port, FortiOS will try to create a new interface. If you are in the wrong place, type abort: you leave and nothing is saved.
Viewing: show and get
show: prints the configuration of the current section the way it is written, only settings that differ from the default.show full-configuration: everything, including defaults.get: lists all settings with their values. It is also used for status:get system status.
FGT-HQ # show system interface port2 config system interface edit "port2" set vdom "root" set ip 10.10.10.1 255.255.255.0 set allowaccess ping https ssh set type physical set alias "LAN" next end
Use grep to filter long output: show system interface | grep -f port2. The -f switch prints the matching line together with its whole block.
execute and diagnose
These two words do not change the configuration.
execute: do something.execute ping 10.10.10.20,execute reboot,execute backup config ....diagnose: troubleshooting.diagnose sniffer packet port2 "icmp" 4,diagnose sys session list.
Helpers
?: shows the commands or values available at that point.set allowaccess ?lists every option.- Tab: completes the command; press again to cycle through options.
- Abbreviations work:
conf sys int,sh sys int port2,exec ping 10.10.10.20. - Anything typed without
endornextis lost. If the session drops, a half-finishededitis not saved.
About saving
The default mode is cfg-save automatic: as soon as you type end, the change both takes effect and is written to disk. There is also a safer option for remote work: under config system global, set cfg-save revert and set cfg-revert-timeout 300. In this mode, if you do not confirm the change with execute cfg save, the device reboots when the timer expires and returns to the previous configuration. This is very useful when a change could cut off your own connection.
🧪 Hands-on lab · Device: FortiGate-VM
config, set, end: the device name
Name the device FGT-HQ and set the idle admin timeout to 10 minutes. Both live in config system global. Notice that the name changes only after you type end.
Checked:
- hostname FGT-HQ
- admintimeout 10
Check yourself
5 questions · answers are shown instantly · 3 correct answers complete the lesson
1In FortiOS, which command saves a table entry and stays in the same table?
2You typed set hostname FGT-HQ under config system global but the prompt did not change. Why?
3You typed edit port22 but meant port2. What do you type to leave without saving anything?
4Which command shows the whole configuration including default values?
5Which of these does not change the configuration but just performs an action?
Comments
Sign in to comment.