# LinuxCNC M30

Instructions · `M30` · verification: source checked

M30 is a LinuxCNC G-code program-end command that also exchanges pallet shuttles. It ends the program, and pressing Cycle Start ("R" in the Axis GUI) restarts the program at the beginning of the file. M30 also returns the machine to a defined set of modal states, such as MDI mode, default origin offsets, XY plane, absolute distance mode and stopped spindle.

## Specification

| Property | Value |
|---|---|
| Language | gcode |
| Code | M30 |
| Group | Program End |
| Dialect | LinuxCNC |

## Connected

- Related: [LinuxCNC G1 Linear Move](https://machineschema.com/instruction/gcode-g01.md)

## Safety

- Using % to wrap the G-code does not do the same thing as a Program End.

## Study notes

- M2 ends the program; M30 additionally exchanges pallet shuttles before ending the program.
- After M30, pressing Cycle Start starts the program at the beginning of the file.
- Both M2 and M30 change from Auto mode to MDI mode.
- Origin offsets are set to the default (like G54) and the selected plane is set to XY (like G17).
- Distance mode is set to absolute (like G90) and feed rate mode to units per minute (like G94).
- Feed and speed overrides are set to ON (like M48).
- Cutter compensation is turned off (like G40), the spindle is stopped (like M5) and coolant is turned off (like M9).
- The current motion mode is set to feed (like G1).
- Lines of code after M2/M30 will not be executed.

## Sources

1. [M-Codes](https://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m2-m30) (accessed 2026-10-26)

---

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