G0 (rapid positioning) and G1 (linear feed) are the two most common
commands in any G-code file — usually 90%+ of all lines. Both move in a
straight line to the target; the difference is why and how fast:
G0— get there as fast as the machine allows. For moving around the work: up to safe height, over to the next feature, back to the tool change. The machine ignores your F word and uses its own maximum rates.G1— move at the programmed feed rate (F), because the tool is in (or entering) material and the cutting physics matter.
G90 G54 G17 G21 ; absolute, work offset 1, XY plane, mm
G0 Z5 ; rapid to safe height
G0 X20 Y10 ; rapid over the start point
G1 Z-3 F150 ; plunge into the stock at 150 mm/min
G1 X80 F600 ; cut a straight line at 600 mm/min
G0 Z5 ; retract — rapid again
Both are modal: after a G1, every following coordinate-only line is
another feed move until G0, G2, G3, or a cycle changes the mode. The
F word is modal too — set once, it persists until changed.
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Rapid positioning | G0 |
G0 |
G0 |
G0 |
G0 |
G0 |
Non-cutting traverse at the machine's max rate. |
| Linear feed move | G1 |
G1 |
G1 |
G1 |
G1 |
G1 |
Feed-controlled straight cut; requires an F word. |
— means the control has no equivalent code. Full cross-control tables: the complete G-code & M-code reference.
#The dogleg trap
The most misunderstood thing about G0: on many controls it is not
coordinated. Each axis runs at its own maximum speed, so a rapid from
X0 Y0 to X100 Y20 may run both axes at full speed until Y arrives, then
continue in X alone — an L-shaped path, not the diagonal you drew in your
head. LinuxCNC does coordinate rapids in a straight line; FANUC's default
(and many Mach setups) dogleg.
The safe pattern is the one every CAM post uses:
- Retract Z to clearance height.
- Rapid X/Y over the target.
- Rapid Z down to a small gap above the stock.
G1the rest of the way in.
Simulating the program first shows you exactly where the rapids run — a dogleg through a clamp is easy to spot in 3D and expensive to discover on the machine.
#Common mistakes
- Plunging on G0. Posting a rapid straight down into the stock ends tools. The last hop before material contact should always be a feed move.
- No feed rate on the first G1. Controls either error out (GRBL) or use
a stale/default feed — both bad. State
Fexplicitly. - Feed too low on rapid-height moves. The opposite waste: programs that
do every move as
G1 F100, turning a 30-second job into 10 minutes. Traverse moves between features belong onG0. - Forgetting G0/G1 are modal. A bare
X50line inherits the previous motion mode. After a canned-cycle cancel or tool change, restate the mode instead of trusting whatever came before.