The fastest way for the codes to click is to see them work together in one short, complete program. Here is about the most basic one there is, walked through line by line. It is a teaching example to show structure, not a file to run on your machine, which would need its own offsets and safety setup.

The program

G21 G90        (millimeters, absolute positioning)
G0 X0 Y0       (rapid to the start point)
M3 S1000       (spindle on, clockwise, 1000 rpm)
G1 Z-1 F100    (feed down to Z-1 at 100 mm/min)
G1 X20 F150    (feed across to X20 at 150 mm/min)
M5             (spindle stop)
G0 Z5          (rapid retract to a safe height)
M30            (end and rewind)

Line by line

LineCodeWhat it does
1G21 G90Sets millimeters and absolute mode (both modal)
2G0 X0 Y0Rapids to the start, not cutting
3M3 S1000Starts the spindle clockwise at 1000 rpm
4G1 Z-1 F100Feeds down into the work at a controlled rate
5G1 X20 F150Feeds a straight cut to X20
6M5Stops the spindle
7G0 Z5Rapids up to a safe height
8M30Ends the program and rewinds

Notice how the modal codes carry: G90 set in line 1 governs every coordinate after it, and G1 in line 4 is still active in line 5. That carry-forward is the modal behavior beginners often miss.

How to learn from it

Read the program and recall what each line does without the comments, the way you would in beginner CNC code practice. Every code here is in the common G-codes and common M-codes, and the difference between line 2 and line 4 is exactly G00 vs G01. Reading programs this way is also why G-code for mechanical engineers is worth a crash course. A free tool like G-Code Sprint drills those codes so the example reads instantly.

Bottom line

The most basic program is a short skeleton: setup, rapid, spindle on, feed, spindle off, retract, end. Learn to read it line by line and the codes become a language rather than a list. Treat it as a teaching example, not a file to run.

Sources

Frequently asked questions

What is the simplest G-code program?

One that sets units and mode, rapids to a start, turns the spindle on, makes one feed move, turns the spindle off, retracts, and ends. That skeleton, G21/G90, G0, M3, G1, M5, G0, M30, contains the common codes every program is built from.

Can I run a basic G-code example on my machine?

Not as-is. A teaching example leaves out the work offsets, tool length offsets, and safety setup your specific machine needs. Use it to understand the structure, then follow your machine manual and instructor for a real, safe program.

What is the best way to go from reading an example to writing one?

Recall what each line does without looking, then try changing one value at a time. A free tool like G-Code Sprint drills the codes so that when you read an example, every line already means something.

G-Code Sprint is a study and practice tool only. It is not a CNC simulator, machine controller, or safety authority. Always follow your instructor, employer, machine manual, and shop safety procedures.