← All guides
Fundamentals8 min read · Updated 2026-06-29

Minecraft Commands for Beginners: Selectors, /execute & More

Commands are the language datapacks are written in. Learn target selectors, the all-powerful /execute, and the handful of commands that do 90% of the work.

Commands are how you talk to Minecraft directly. Type one into chat (after enabling cheats) and the game does exactly what you asked — give an item, teleport a player, change a block. Datapacks are really just commands packaged to run automatically, so learning a few commands well is the fastest route to understanding everything Minecraft creators do.

This guide covers the concepts that unlock the rest: target selectors, coordinates, and the /execute command that ties them together. Everything here is Java Edition syntax; Bedrock is similar but not identical.

Target selectors: @p, @a, @e, @s

Most commands act on entities, and selectors are how you choose which ones. @p targets the nearest player, @a targets all players, @r a random player, @e every entity (players, mobs, items, armour stands), and @s the entity running the command. Selectors take arguments in square brackets to filter further — by distance, tag, score, team, type and more.

  • @a[team=red] — every player on the red team.
  • @e[type=zombie,distance=..10] — all zombies within 10 blocks.
  • @p[tag=seeker] — the nearest player carrying the 'seeker' tag.
  • @s — whoever (or whatever) is currently executing the command.

Coordinates: absolute, relative, and local

Many commands need a position. Absolute coordinates are plain numbers (100 64 -200). Relative coordinates start with a tilde and are offsets from the command's position: ~ ~1 ~ means 'here, but one block up'. Local coordinates start with a caret (^ ^ ^2) and are relative to the direction the entity is facing — perfect for 'two blocks in front of the player'.

/execute: the command that runs commands

If you learn one command, make it /execute. It lets you change who runs a command, where they run it, and whether they run it at all, by chaining subcommands. 'as' changes the executing entity, 'at' moves to their position, 'positioned' sets an explicit position, 'if'/'unless' add conditions, and 'run' finishes with the command to perform. Reading it left to right tells you a little story.

For example: execute as @a[team=red] at @s run tp @s 0 100 0 reads 'for each red player, at their position, teleport them to the centre platform'. Almost every advanced datapack behaviour — region detection, generators, timers — is an /execute chain.

The everyday command toolbox

  • /give, /clear — hand out or remove items.
  • /tp (teleport), /spreadplayers — move entities around.
  • /setblock, /fill, /clone — place and copy blocks.
  • /scoreboard — track numbers (covered in its own guide).
  • /tag — attach invisible labels to entities for selectors.
  • /title, /tellraw — show text on screen and in chat.
  • /gamemode, /effect, /time, /weather — change the world's state.

You don't have to memorise all of this to make something — Mine Mod AI writes correct command logic for you. But understanding selectors and /execute makes it far easier to read a generated datapack and tweak it into exactly what you want.

Build it without the busywork

Mine Mod AI turns a plain-English description into a ready-to-install Minecraft datapack or Bedrock add-on — version-correct and free to try.

Try the generator →