# LinuxCNC G98

Instructions · `G98` · verification: source checked

G98 is a G-code that selects the retract level used at the end of canned cycles such as drilling and boring. In this mode the tool returns to the Z position it held just before the series of contiguous canned cycles began, if that position is higher than the R value; otherwise the R value is used. It is the alternative to G99, which always retracts to the R position.

## Specification

| Property | Value |
|---|---|
| Language | gcode |
| Code | G98 |
| Group | Canned Cycle Return Level |
| Dialect | LinuxCNC |

## Study notes

- G98 retracts to the position the axis was in just before the series of one or more contiguous canned cycles was started, provided it is higher than the R value; if lower, the R value is used.
- G99 instead retracts to the position specified by the R word of the canned cycle.
- G98 is also referred to in the document as OLD_Z retract mode.
- The initial (G98) plane is reset any time cycle motion mode is abandoned, whether explicitly with G80 or implicitly with any motion code that is not a cycle.
- Switching among cycle modes (for example G81 to G83) does not reset the initial plane.
- It is possible to switch between G98 and G99 during a series of cycles.
- Documented example: G0 X1 Y2 Z3 followed by G90 G98 G81 X4 Y5 Z-0.6 R1.8 F10 returns to Z3 because it is higher than the R value of 1.8.

## Sources

1. [G-Codes](https://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g98-g99) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/gcode-g98  
JSON: https://machineschema.com/instruction/gcode-g98.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
