Minecraft 1.21.9 and newer
The setting moved from server.properties to a game rule. On 1.21.11 and newer, including 26.x, run gamerule minecraft:command_blocks_work true. On 1.21.9 and 1.21.10, use tab completion after typing gamerule to find the command block rule, as the name changed again in 1.21.11.
Minecraft 1.21.8 and older
Set enable-command-block=true in server.properties with the server stopped, then start it again.
Getting and using a command block
Command blocks cannot be found in survival or the creative inventory. As an operator in creative mode, run /give @s command_block. Placing and editing them requires creative mode and operator level 2 or higher, which the default op-permission-level of 4 includes.
- Impulse: runs once when powered
- Chain: runs after the block pointing into it
- Repeat: runs every tick while powered, so use sparingly
Performance and safety
Repeating command blocks run every tick, and heavy commands such as broad entity selectors in many repeating blocks can cost real TPS. Functions in a datapack are usually cleaner and easier to manage than walls of command blocks. Only operators can edit command blocks, so they are not a griefing risk on their own, but be careful who you make an operator.