Updated:

Quick reference

SelectorSelectsTypical use
@pThe nearest playerGive an item to whoever stands at a command block
@aAll playersMessages or effects for everyone
@rOne random playerDraws, choosing who is "it"
@eAll entities: mobs, items, arrows, armor stands and moreClearing mobs or dropped items in an area
@sWhoever runs the commandYourself in chat; the current target inside /execute
@nThe nearest entity (Java 1.21+)Acting on a single nearby mob

@e really means everything

/kill @e removes mobs, dropped items, item frames, armor stands, minecarts and you. Always add type when you mean mobs:

/kill @e[type=minecraft:zombie]
/kill @e[type=minecraft:item]
/kill @e[type=!minecraft:player]

type=!minecraft:player means "not players", which still includes armor stands and item frames. In worlds with builds, limit the area too.

@s depends on who runs it

In chat, /effect give @s speed affects you. In a command block, the runner is the block, which is not an entity, so @s selects nobody. Use @p there, or switch the runner with execute:

/execute as @a[distance=..5] run effect give @s minecraft:speed 10 1

as makes each selected player the runner in turn, so @s is that player. See execute as vs at.

Where @p measures from

From your position in chat and from the block in a command block. execute at moves that point. In chat, the nearest player is usually you.

Common arguments (Java)

Combine any number of arguments with commas. Bedrock uses other names, such as r for distance and c for limit.

When nothing is selected

If you see "No entity was found", remove the arguments one at a time to find the one that filters too much.

Common questions

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.