M2 is a G-code program end command in LinuxCNC. It terminates the program and returns the machine to a defined modal state: Auto mode changes to MDI, offsets and plane reset to defaults, distance mode becomes absolute, feed mode becomes units per minute, overrides are enabled, cutter compensation is cancelled, the spindle stops, motion mode becomes feed, and coolant turns off. Pressing Cycle Start restarts the program from the beginning of the file.
| Language | gcode |
|---|---|
| Code | M2 |
| Group | Program End |
| Syntax | M2 |
| Dialect | LinuxCNC |