Results 1 to 6 of 6

Thread: trying to echo /sys/class/backlight/acpi_video0/brightness : Permission denied

  1. #1
    Join Date
    Nov 2012
    Beans
    3

    trying to echo /sys/class/backlight/acpi_video0/brightness : Permission denied

    Hi Community,

    i'm new to UBUNTU. I've recently installed ubuntu 12.10 and have several issues. One of them is that my brightness always sets itself to 100% at a new boot. I've a line in /etc/rc.local:

    Code:
    echo 7 > /sys/class/backlight/acpi_video0/brightness
    but it won't execute. Every boot the screen gets set to max.
    If i run the command logged in as root
    Code:
    sudo su
    it works.
    but
    Code:
    mo@x1-carbon:~$ sudo echo 6> /sys/class/backlight/acpi_video0/brightness
    bash: /sys/class/backlight/acpi_video0/brightness: Permission denied
    gives me no permission.

    What am I missing?

    Thanks for your help,
    m

  2. #2
    Join Date
    Apr 2012
    Beans
    7,256

    Re: trying to echo /sys/class/backlight/acpi_video0/brightness : Permission denied

    Your command gives elevated permissions to the echo command (which doesn't need them), but not to the part that redirects the output stream to the root-owned file (which does)

    In a terminal, you can either do

    Code:
    echo 7 | sudo tee /sys/class/backlight/acpi_video0/brightness
    which gives the elevated permission to the bit that really needs it, or

    Code:
    sudo sh -c "echo 7 > /sys/class/backlight/acpi_video0/brightness"
    which runs the whole command in a sudo shell

    HOWEVER you shouldn't use sudo at all in /etc/rc.local since it should be executed as root - something else must be going wrong there
    Last edited by steeldriver; November 25th, 2012 at 04:27 PM.

  3. #3
    Join Date
    Nov 2012
    Beans
    3

    Re: trying to echo /sys/class/backlight/acpi_video0/brightness : Permission denied

    Quote Originally Posted by steeldriver View Post
    In a terminal, you can either do

    Code:
    echo 7 | sudo tee /sys/class/backlight/acpi_video0/brightness
    which gives the elevated permission to the bit that really needs it, or

    Code:
    sudo sh -c "echo 7 > /sys/class/backlight/acpi_video0/brightness"
    which runs the whole command in a sudo shell
    Thanks for your quick response, steeldriver. Both solutions did it for me, which brings me to the question, why the line in rc.local doesn't get executed? I DO NOT run the line with a sudo command.
    I also tried the two commands you gave me without the sudo in it in rc.local, with no luck.

    I thought that it had something to do with permission. I've another line in rc.local which rfkills bluetooth, but you don't need to be root to do that... and this works fine.
    Any ideas?

  4. #4
    Join Date
    Apr 2012
    Beans
    7,256

    Re: trying to echo /sys/class/backlight/acpi_video0/brightness : Permission denied

    It should work - are you sure you put it ahead of the 'exit 0' line?

    The only other thing I can think of is that it's working, but something later in your startup process is overwriting it

  5. #5
    Join Date
    Nov 2012
    Beans
    3

    Re: trying to echo /sys/class/backlight/acpi_video0/brightness : Permission denied

    Quote Originally Posted by steeldriver View Post
    The only other thing I can think of is that it's working, but something later in your startup process is overwriting it
    Thanks. It was kind of this behavior. I've installed tlp for powermanagement and it has an own startup script. Putting the original "echo 7 > ..." line there solved the proplem. Strange thing is that commands without the need of sudo are still getting executed from rc.local.

  6. #6
    Join Date
    Sep 2010
    Location
    Germany
    Beans
    84
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: trying to echo /sys/class/backlight/acpi_video0/brightness : Permission denied

    Hi,

    Quote Originally Posted by mobody View Post
    I've installed tlp for powermanagement and it has an own startup script. Putting the original "echo 7 > ..." line there solved the proplem.
    You should not do it that way. Either the next TLP update will kill your local changes or you're excluding yoursef from further updates of the TLP startup script.

    Instead create the script file /etc/pm/power.d/backlight

    Code:
    #!/bin/sh
    # /etc/pm/power.d/backlight 
    # set backlight brightness depending on power source
    LEVEL_AC=15
    LEVEL_BAT=7  
    BRIGHT=/sys/class/backlight/acpi_video0/brightness
    case "$1" in     
        true)  level=$LEVEL_BAT ;;      
        false) level=$LEVEL_AC ;;
        *) exit 0 # invalid argument
    esac
    [ "$(cat $BRIGHT)" != "$level" ] && echo -n $level > $BRIGHT
    exit 0
    Make it executable:
    Code:
    sudo chmod 755 /etc/pm/power.d/backlight
    Last edited by linrunner; November 28th, 2012 at 10:01 PM. Reason: EDITH was here

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •