Skip to main content
Mechanics

Minecraft commands: how they work and how to use them

By July 13, 2026No Comments

What are commands in Minecraft?

Commands are text instructions you type into the chat box to change the game in ways the normal controls can’t. You can give yourself items, change the time of day, teleport across the map, set the weather, or summon a mob, all by typing a short line that starts with a slash.

Players also call them cheats, because the in-game toggle that enables them is literally labeled “Allow Cheats.” The name is misleading. Plenty of people use commands for building, testing redstone, running servers, or setting up custom maps, not for skipping the survival grind.

This guide covers what commands are, how to switch them on, the syntax that every command shares, and the ones you’ll reach for most often. The examples use the slash-command system that works in both editions, with notes where Java and Bedrock part ways.

How to enable commands

Before you can type a command, the world has to allow them. How you turn them on depends on where you’re playing.

Single-player and local worlds

When you create a new world, open the world options and turn on Allow Cheats. On an existing world you can flip it from the pause menu: open to LAN in Java (this enables cheats for the session), or change the setting under Game in Bedrock. Switching cheats on usually disables achievements for that world, so be aware of the trade-off before you do it on a world you care about.

Multiplayer servers

On a server, command access is controlled by operator status. A server admin grants it with /op <player> from the console, and removes it with /deop <player>. Operators get access to most commands; regular players don’t. Some commands are also gated behind permission levels set in the server configuration.

Command blocks

Command blocks run a single command when powered by redstone. You can’t craft one. You have to give it to yourself with /give @s command_block while cheats are on. They’re the backbone of custom maps and adventure-mode contraptions, because they let a command fire from a button, a pressure plate, or a clock instead of from the chat box.

Basic command syntax

Every command follows the same shape. It starts with a forward slash, then the command name, then any arguments the command needs, separated by spaces.

Take /time set day. The slash tells the game this is a command, time is the command, set is the action, and day is the value. Swap the value and you get a different result: /time set night jumps to night, and /time set 6000 sets it to midday using the raw tick number.

A few habits make commands easier to get right:

  • Open chat with T (Java) or the chat button (Bedrock), then type the slash. Pressing / on Java opens chat with the slash already entered.
  • Use the Tab key on Java to autocomplete command names, player names, and item IDs. It saves typing and prevents spelling mistakes.
  • Read the error text. If a command fails, the chat usually tells you which part it didn’t understand, often with a red caret pointing at the problem.

Item and block IDs use lowercase with underscores, like diamond_sword or oak_planks. Coordinates are three numbers for X, Y, and Z. A tilde (~) means “relative to where I am now,” so ~ ~5 ~ means five blocks straight up from your current position.

Target selectors

Many commands need to know who or what they apply to. Instead of typing a player’s name every time, you use a target selector, a short code that starts with @.

  • @p targets the nearest player.
  • @a targets all players.
  • @r targets a random player.
  • @s targets yourself, the entity running the command.
  • @e targets all entities, including mobs, items, and armor stands.

You can narrow a selector with arguments in square brackets. @e[type=zombie] picks only zombies. @a[distance=..10] picks players within ten blocks. @e[type=cow,limit=5] picks the five nearest cows. Selectors are where commands go from handy to powerful, because one line can act on dozens of targets at once.

The most useful commands

You don’t need to memorize the full list. A handful covers most of what people actually do.

Items and inventory

/give @s diamond_pickaxe 1 drops a diamond pickaxe into your inventory. The number at the end is the quantity. /clear empties your inventory, and /clear @s diamond removes only diamonds.

Movement and location

/tp @s 100 64 -200 teleports you to those coordinates. You can also teleport to a player by name, or use /spawnpoint to set where you respawn. On Java, /teleport is the full name and /tp is the short alias.

World and weather

/time set day and /weather clear are the two most common quality-of-life commands. /gamerule doDaylightCycle false freezes the sun in place, which is handy for building or screenshots. /gamerule keepInventory true stops you from dropping your items when you die.

Game mode

/gamemode creative switches you to creative, and /gamemode survival switches back. The shorthand numbers still work in some contexts: 0 is survival, 1 is creative, 2 is adventure, 3 is spectator.

Building and spawning

/setblock ~ ~ ~ stone places a single block at your position. /fill fills a whole region between two coordinates, which turns a tedious build into one line. /summon spawns an entity, so /summon lightning_bolt calls down a strike right where you’re looking.

Status and progress

/effect give @s night_vision 999 1 grants long-lasting night vision, which makes cave exploration and building in the dark far easier. /xp add @s 30 levels hands you experience levels for enchanting, and /enchant applies an enchantment directly to the item you’re holding. /locate points you toward the nearest structure, so /locate structure village returns the coordinates of the closest village.

Tips and common mistakes

Most failed commands come down to a few avoidable slips. The error message in chat almost always tells you which one you hit, so read it before retyping.

  • Spelling and case matter for IDs. Diamond_Sword won’t work; diamond_sword will. Lowercase with underscores, every time.
  • Coordinates are X, Y, Z in that order, and Y is height. Mixing them up sends you underground or into the sky.
  • Spaces separate arguments, so an extra or missing space breaks the parse. Lean on autocomplete to avoid it.
  • A selector with no matches isn’t an error, it just does nothing. If @e[type=zombie] affects nobody, there may be no zombies loaded nearby.
  • Large /fill regions have a block limit per command. If a giant fill silently fails, split it into smaller chunks.

One more habit worth building: test destructive commands on a copy of your world or a flat test world first. Commands run instantly and there’s no undo, so a single mistyped /fill can flatten something you spent hours on.

Java and Bedrock differences

The two editions share most commands, but the details diverge often enough to trip people up.

Java tends to support a wider range of arguments and more precise syntax. NBT data tags, which let you customize an item or entity in fine detail, are a Java feature. Bedrock uses a separate component system and doesn’t accept the same tags.

Some command names and options differ too. Bedrock has /gametest and a few platform-specific commands, while Java has features like /datapack for managing data packs. Target selectors work in both, though the available arguments aren’t identical. If a command works for a friend on one platform and not for you, the edition gap is the first thing to check.

Frequently asked questions

Do commands disable achievements?

Turning on cheats disables achievements (Bedrock) or advancements progress tracking for that world (Java) in most cases. If you care about earning them legitimately, keep cheats off on that world.

Why does my command say I don’t have permission?

You’re either on a world without cheats enabled, or on a server where you’re not an operator. On your own world, turn on Allow Cheats. On a server, ask an admin to run /op on your name.

Can other players use commands on my server?

Only if they’re operators or the command is allowed for their permission level. By default, regular players can’t run most commands, which keeps a public server from descending into chaos.

What does the tilde symbol mean in commands?

The tilde (~) means relative coordinates. ~ ~ ~ is your current position, and ~ ~10 ~ is ten blocks above you. It saves you from looking up exact numbers every time.

How do I undo a command?

There’s no undo button. If you used /fill or /setblock and want it back, you have to run another command to restore it, so test big changes in a throwaway world first.

Are commands the same as command blocks?

They run the same instructions, but a command block stores one command and fires it from redstone instead of the chat box. Use the chat box for one-off actions and command blocks for anything you want to repeat automatically.

Where to go from here

Start with the safe, reversible ones: /time, /weather, and /gamemode. Once those feel natural, try /fill on a spare world to see how much building time a single line can save. The autocomplete key does most of the heavy lifting, so you rarely have to memorize exact spelling.