How can I dim the screen from Terminal?

You can do it via an Applescript and run it as such:

dimmer:

tell application "System Events"
    key code 107
end tell

brighter:

tell application "System Events"
    key code 113
end tell

You can save these as .script file and then run them from the CLI like this:

osascript ~/Path/to/File
Like what you read? Give Nattaphon Saelim a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.