Controlling the Linux Backlight via the Command-Line

Let's say that you've just installed your laptop, and you've forgotten to install xbacklight to manage your backlight settings, or you do have it, and it's randomly stopped working.

Fortunately on Linux, sysfs allows you to interact with the backlight system, just by writing to "files" on disk, nothing else needed!

First, you'll need to check which devices are available. For instance:

ls -l /sys/class/backlight/
# on my laptop:
total 0
lrwxrwxrwx 1 root root 0 Nov 10 12:08 intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight

Next, we can check what it's currently set to:

cat /sys/class/backlight/intel_backlight/brightness

And to check the maximum available for the device:

cat /sys/class/backlight/intel_backlight/max_brightness

And then if we want to control the brightness, we can write to the brightness file with the brightness value we want to set it to:

echo 200 | sudo tee /sys/class/backlight/intel_backlight/brightness

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #command-line #linux.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.