In a single player world where they weren't, you can enable cheats by opening the game to LAN and selecting 'Allow Cheats' (even if you are not on a LAN), and this choice will be remembered until you quit your world.
For most of these Minecraft cheats to work, you need to be in a game where cheats were enabled when the world was created. You can use the up and down arrow keys to scroll through previously entered commands, and pressing the Tab key while entering commands will cycle through possible options. To get started with these Minecraft commands, simply hit the forward slash key (/) to open the chat window then continue typing the command.