How to get root permission?

when i try to set a led.
morning2050@localhost:/sys/class/leds/fantem:led3_red:status$ sudo echo 1>brightness
-bash: brightness: Permission denied
morning2050@localhost:/sys/class/leds/fantem:led3_red:status$ Permission denied^C
morning2050@localhost:/sys/class/leds/fantem:led3_red:status$ ls
brightness device max_brightness power subsystem trigger uevent
morning2050@localhost:/sys/class/leds/fantem:led3_red:status$ su root
Password:
su: Authentication failure
morning2050@localhost:/sys/class/leds/fantem:led3_red:status$ su root
Password:
su: Authentication failure

i can not get root permission.

this is ubuntu … use sudo -s

thankyou for fast reply,it works

i assume this is on Ubuntu Core so I’ll move this post to the right category (feel free to change it again if I’m wrong)

Hi,

what is the default password of root?

colinliao@localhost:~$ su -s root
Password:
su: Authentication failure
colinliao@localhost:~$

there is no password, the root account is completely locked down (with a readonly passwd file) … the user you create in the first-boot wizard is a sudo user though … simply use sudo -s after ssh’ing into the device if you really think you require a root shell …

as a point of interest, the reason your command sudo echo 1>brightness fails is because it is executed as follows:

  • as the unprivileged user
  • take the output of the command sudo echo in the pipe named 1
    • because you wrote 1>brightness not 1 >brightness then it is naming the pipe, which you likely didn’t intend
    • you likely meant echo 1 >brightness which prints the number 1 into stdout and redirects that into brightness
  • write that output of pipe 1 from the sudo command into ./brightness as the original unprivileged user

To correctly use echo to write into a file that can only be written-to by root you need to use a different method such as:

echo 1 | sudo tee brightness

or

sudo -c "echo 1 > brightness"

or spawn a root shell like @ogra suggested with sudo -s or sudo -i.

1 Like