Accessing devices through command line - Permission Denied.

1,860 views
Skip to first unread message

arvr

unread,
Nov 14, 2011, 8:47:06 AM11/14/11
to Android Linux Kernel Development, navee...@asmaitha.com
Hi,

I am trying to access leds from command line (through the terminal),
but I am getting "Permission Denied" error and am struck on similar
issues.Can you please help me to understand what's wrong.

Environment:
a. OMAP 4430 Panda board
b. Linux 2.6.36 and Android GB 2.3.3
c. I have integrated the leds and it is visible to me as "/sys/class/
leds/green/" & "/sys/class/leds/keyboard-backlight".

When I perform,
echo 1 > /sys/class/leds/green/brightness
or
echo 1 > /sys/class/leds/keyboard-backlight/brightness

kernel tells me "Permission Denied". I use the regular init.rc file as
given in the OMAPPedia website, with the changes done by commenting
the line "#mount rootfs rootfs / rw remount" etc.

Similar to this, I am executing the "yavta" tool (https://
www.gitorious.org/omap4-v4l2-camera/yavta) and that too is not
executing the command, kernel reports me that no such file or folder
is present. The tool is copied in the same folder and I run it as
yavta -h

What could be reasons? Please help me out.
Thanks,
ARVR.

Earlence

unread,
Nov 14, 2011, 4:09:47 PM11/14/11
to Android Linux Kernel Development
are you executing this as root?

-earlence

On Nov 14, 2:47 pm, arvr <venkat.raghav...@gmail.com> wrote:
> Hi,
>
> I am trying to access leds from command line (through the terminal),
> but I am getting "Permission Denied" error and am struck on similar
> issues.Can you please help me to understand what's wrong.
>
> Environment:
> a. OMAP 4430 Panda board
> b. Linux 2.6.36 and Android GB 2.3.3
> c. I have integrated the leds and it is visible to me as "/sys/class/
> leds/green/" & "/sys/class/leds/keyboard-backlight".
>
> When I perform,
> echo 1 > /sys/class/leds/green/brightness
> or
> echo 1 > /sys/class/leds/keyboard-backlight/brightness
>
> kernel tells me "Permission Denied". I use the regular init.rc file as
> given in the OMAPPedia website, with the changes done by commenting
> the line "#mount rootfs rootfs / rw remount" etc.
>
> Similar to this, I am executing the "yavta" tool (https://www.gitorious.org/omap4-v4l2-camera/yavta) and that too is not

arvr

unread,
Nov 15, 2011, 1:59:35 AM11/15/11
to Android Linux Kernel Development
Yes am executing as root. This is what I do (& the results) after the
device boots up at the command line(through the terminal)

$ ls /sys/class/leds
green
battery-led
lcd-backlight
keyboard-backlight
$
$
$
$ echo 1 > /sys/class/leds/keyboard-backlight/brightness
cannot create /sys/class/leds/keyboard-backlight/brightness:
permission denied
$
$ echo 1 > /sys/class/leds/green/brightness
cannot create /sys/class/leds/green/brightness: permission denied

I understand that by default device will boot up in root permission.
In the init.rc I see that the devices are "chown"ed to system system
>>>>chown system system /sys/class/leds/keyboard-backlight/brightness

So I am trying to understand this part of the world and how to get
things done.
Any information or links will be highly appreicated.
Thanks and Regards,
ARVR.

arvr

unread,
Nov 15, 2011, 5:48:27 AM11/15/11
to Android Linux Kernel Development
Kind of resolved - I tried it over adb and it was working
successfully.
But I am not still satisfied, want to understand how stuff works.

Firstly:
I connected the device using ADB and executed
echo 1 > /sys/class/leds/keyboard-backlight/brightness

I was abel to see the Leds glow and doing the needful. Is it that that
ADB runs as system due to which it is able to do it???

Is there any documentation available which specifies about how
permission are set by Android Linux. Please let me know details and
links.

Thanks,
ARVR.

colex.john

unread,
Nov 15, 2011, 12:28:38 AM11/15/11
to android...@googlegroups.com
chown system system /sys/class/leds/green/brightness
and
chmod 0664 /sys/class/leds/green/brightness

in your init.rc

colex.john

unread,
Nov 15, 2011, 2:23:08 AM11/15/11
to android...@googlegroups.com
this kind of tips may represent three issue:

1. your system is compiled as user-tag.
to change the security flag , you can modify your ramdisk/default.prop
ro.security to 0 , you will have the authority as root,
this is the shortest way to hack compared to compile the system as eng-tag.
2. your console(ttyUSB or ttySx) is configured as shell . this is set
from your init.rc file. (grep "console" in your init.rc :? )
3. if you use adb shell , please use adb remount first.

good luck~

Si Dao

unread,
Nov 30, 2011, 10:08:24 AM11/30/11
to Android Linux Kernel Development
To gain the root permission in Android OS, in the "/init" file, please
search and add such as comment like:
[Before:]
service console /system/bin/sh
console
disable
user....

[After:]
service console /system/bin/sh
console
disable
#user....
Reboot -> then you can be root now, the command prompt will be "#"
instead of "$"


On 15 Tháng Mười Một, 14:23, "colex.john" <colex.j...@gmail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages