G54.APP

G-code deep dive

G0 vs G1: Rapid Positioning and Linear Feed Moves

G0G1G00G01

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:

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.

OperationLinuxCNCGRBLCentroidFANUCMach3Mach4Notes
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:

  1. Retract Z to clearance height.
  2. Rapid X/Y over the target.
  3. Rapid Z down to a small gap above the stock.
  4. G1 the 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

Frequently asked questions

Is G0 the same as G00?

Yes. Leading zeros are ignored, so G0 and G00 are the same command (as are G1 and G01). Older FANUC-style posts write G00/G01; most modern controls accept both.

Does G0 move in a straight line?

Not necessarily. Many controls move each axis at its own maximum rate, so the toolpath can be a dogleg: the shorter axis finishes first and the rest of the move is single-axis. Never rely on a G0 to clear an obstacle diagonally — position above the part first, then drop.

Why am I getting an error on my first G1?

A G1 needs an active feed rate. If no F word has been set yet, most controls stop with an error (GRBL: error 22, 'Undefined feed rate'). Put an F on the first G1 of every program — don't assume a stale feed from a previous run.

Can I cut material with G0?

Never intentionally. G0 runs at the machine's maximum traverse rate with no regard for cutting load. Cutting on a rapid breaks tools and can stall or damage the machine. If the tool must touch material, it's a G1/G2/G3 with a proper feed.

See it, don't guess it

Paste a program into the free G54.APP viewer and watch these codes execute — toolpaths, stock removal, and machine state, live in your browser. Nothing is uploaded.

Open the G-code viewer