---
title: "Common M-Codes Every CNC Beginner Should Know"
description: "A short reference of the M-codes you will meet first: spindle, coolant, tool change, and program control, each with a plain-language meaning."
url: https://gcodepractice.com/journal/common-m-codes-for-cnc-beginners/
canonical: https://gcodepractice.com/journal/common-m-codes-for-cnc-beginners/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-05-28
updated: 2026-05-28
category: "Code reference"
tags: ["m-code", "reference", "cheat sheet", "beginner"]
lang: en
---

# Common M-Codes Every CNC Beginner Should Know

> **TL;DR** The core beginner M-codes are M00 and M01 (program and optional stop), M03, M04, M05 (spindle clockwise, counterclockwise, stop), M06 (tool change), M08 and M09 (coolant on and off), and M30 (program end and rewind). Learn this set and you can read most beginner programs.

G-codes command motion. M-codes handle the "miscellaneous" machine functions: turning the spindle and coolant on or off, changing tools, and ending the program. A beginner only needs a small set to start.

## Spindle

- **M03**: spindle on, clockwise (forward).
- **M04**: spindle on, counterclockwise (reverse).
- **M05**: spindle stop.

These three are worth drilling together. See [M03 vs M04 vs M05](/journal/m03-m04-m05/) for the full breakdown.

## Coolant

- **M08**: coolant on.
- **M09**: coolant off.

## The core M-codes at a glance

| Code | Function | Group |
| --- | --- | --- |
| `M03` / `M04` / `M05` | Spindle on CW / on CCW / stop | Spindle |
| `M08` / `M09` | Coolant on / off | Coolant |
| `M06` | Tool change (with a `T` word) | Tool |
| `M00` / `M01` | Program stop / optional stop | Program |
| `M30` | Program end and rewind | Program |

## Tool change and program control

- **M06**: tool change (usually with a `T` word, like `T02 M06`).
- **M00**: program stop (always pauses).
- **M01**: optional stop (pauses only if the switch is on).
- **M30**: program end and rewind. This is how most programs finish.

```
T02 M06     (change to tool 2)
M03 S1500   (spindle on, clockwise, 1500 rpm)
M08         (coolant on)
...
M05         (spindle stop)
M09         (coolant off)
M30         (end and rewind)
```

## How to remember them

As with any reference, reading the list is not the same as recalling it. Drill these as quick code-to-meaning questions and review the ones you miss, the same [practice-first way you learn the common G-codes](/journal/common-g-codes-for-cnc-beginners/). The whole approach is laid out in [beginner CNC code practice](/journal/beginner-cnc-code-practice/).

## Bottom line

Learn spindle (M03, M04, M05), coolant (M08, M09), tool change (M06), the stops (M00, M01), and the end (M30). That set covers most beginner programs.

## Sources

- [LinuxCNC M-code reference](https://linuxcnc.org/docs/html/gcode/m-code.html)
- [Wikipedia: G-code (M-code functions)](https://en.wikipedia.org/wiki/G-code)
- [CNCCookbook: G-code and M-code cheat sheet](https://www.cnccookbook.com/g-code-m-code-cnc-list-cheat-sheet/)

## Frequently asked questions

### What is the difference between M00 and M01?
`M00` is a mandatory program stop: the machine always pauses there until you resume. `M01` is an optional stop that only triggers when the optional-stop switch on the control is turned on.

### What is the difference between M30 and M02?
Both end the program. `M30` also rewinds it back to the start, which is the common modern choice, while `M02` ends without the rewind. Most programs end with `M30`.

### What is the best app to practice CNC M-codes?
For pure recall of what each M-code does, a free drill app like G-Code Sprint works well: it has a dedicated M-code mode that quizzes spindle, coolant, tool-change, and program codes and repeats the ones you miss. It is a study tool, not a controller, so always confirm against your machine's manual.

*G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.*

---

Source: https://gcodepractice.com/journal/common-m-codes-for-cnc-beginners/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
