You can install this command line tool from github.com/nriley/brightness. The install is pretty easy if you have homebrew:
brew install brightness
And usage is straightforward:
- Set 100% brightness:
brightness 1
- Set 50% brightness:
brightness 0.5
Unfortunately it doesn't work for external monitors. See Does Apple support DDC/CI for 3rd party displays via Apple's Thunderbolt to DVI adapterDoes Apple support DDC/CI for 3rd party displays via Apple's Thunderbolt to DVI adapter for background on why.