Command codes are personal passwords Starfleet officers use to access ship functions.
Command codes generally take the form of several words and numbers spoken by the officer: the words are frequently some combination of numbers and Greek letters. Routine and critical ship functions can be accessed with command codes. The computer recognizes the command code as an order to execute one or more actions in rapid succession, such as initiating a security lockdown and disabling all command functions until another coded command is issued. If spoken by the Captain, command codes allow complete control of the vessel.
In Star Trek III: The Search for Spock, Captain Kirk used a code to initiate self-destruct. It is not clear whether this was a command code. However, Kirk has never accessed vital ship systems such as shields or weapons with that code, so it is likely the code was specific to the auto-destruct system.
In TNG "Gambit", Riker uses his command code in a ruse. Troi remarks that as soon as personnel are missing or captured, their command codes are invalidated. However, command codes can apparently be remotely utilized much in the same fashion as prefix codes.
In TNG "Hero Worship" Data, Picard and Troi tell Timothy it was impossible for him to cause the ship's destruction when he slammed into a console, suggesting that Starfleet officers require command codes to use consoles. However, in TNG "The Neutral Zone" a civilian used a communications panel without a command code, and in TNG "The Hunted", intruder Roga Danar was able to use consoles in Engineering and a cargo bay without command codes.
If a Starfleet officer is captured, his command codes may be used to remotely control a Starfleet vessel, assuming the code is not changed. The officer's voice can be simulated to fool the computer. Most codes are weak and prone to dictionary attack.
The most likely method of attack is to lure the Captain on an away mission, obtain the command codes to his vessel, and commandeer it. Countermeasures depend highly on the competence of the bridge crew in either overriding the Captain's command codes, if this is possible as with the prefix code, or the Captain himself in not allowing himself to be placed in extreme danger.