Account privileges

Hi,
I’ve got Ubuntu installed on the BBB and have compiled a C++ Hellow World on Eclipse and a Ubuntu PC. I can SSH the program to my account on the BBB, and it runs ok. I then SSH a program to flash the LED (from Derek Molloy’s tutorial) and although the terminal messages appear the LED doesn’t flash. I understand that my BBB account doesn’t have ‘write’ privileges for the LED, only Root has, but don’t know how to make the program work or change these privileges. I’ve tried SUDO but that doesn’t work either. Can anyone help me please.
Thanks
Alastair

This is perhaps a more long-winded reply than you might want but in the general case I’m wondering why
the BBB is shipped with the device nodes in /dev for LEDs, and any other i/o stuff, set to be owned and
writable only by root. It seems to me that it would be nicer if there was a unix group that had write permission
to the device nodes and a udev rule that set up the devices to have write permission by that group. Different
devices could have different groups if you want to keep things narrowed down.

http://www.linux.com/news/hardware/peripherals/180950-udev

Then just add your account and any others to that group that need write access. (And read access as
well for the devices that are readable.)

Are you using the stock user account ‘ubuntu’ or did you create your own? If you are using the ‘ubuntu’ account, sudo ./helloWorld should work as long as you are in the directory helloWorld is in. If it doesn’t, you may have typed something wrong in your code and we would need to look at it. If you created your own account, can you sudo anything? Make sure the account is a part of the group ‘sudo’ by typing ‘groups’ in the terminal. If not, add it with the command (run from root or sudoer account) 'usermod -a -G sudo ’

visudo should be used to edit the sudoers file.

visudo should be used to edit the sudoers file.

Correct, it can be used, but I thought usermod (existing user) or adduser (new user) was also an acceptable method to add a user to the ‘sudo’ group. Source, Source2. Is it not?

Many thanks to those who replied. I have downloaded and installed Ubuntu. The standard account is debian and I am using this. I have my program in a folder ‘workspace’ in ‘home’ , and I execute the program from within the workspace folder with sudo ./HelloFirst. All of the lines using cout work i.e. messages are printed to terminal and the sleep function allows 1 second between 10 on and of periods for the LED. Its just the LED does not change. I’ll have a read of your document link tonight Rusty and see if it can help. I’m new to Linux and the BBB, but I agree with the comment that the LEDS should be available to all users on an embedded system. I’m away at present, but will post the code tomorrow.
Thanks again
Alastair

If the device nodes in /dev for the LEDs don’t control anything else other than the LEDs it’s likely safe to make them world writable and readable, mode 0666. You can test that by doing a “chmod 0666 /dev/” and then running your program. Those permissions will go away on the next reboot and you can use
udev to make them permanent.

Yes to edit the file directly visudo should be used.

Thanks Rusty,
I used chmod and was able to set the led brightness to rw- rw- rw-. This along with a small correction in my program worked. I should have specified led 4 brightness directory as /sys/class/leds/beaglebone:green:usr3: , but had left out the word green from the address. The Derek Molloy tutorial I was looking at was for the original beaglebone, so there must be some changes with the BBB. My program does now run without sudo, but as you indicated when the BBB is reset I loose the ‘w’ priviledges and I have to use sudo. Code is below for reference. I’ll need to read up on udev, it looks complicated.

int main() {
cout << “Flash start” << endl;

FILE *LEDHandle = NULL;
char *LEDBrightness = “/sys/class/leds/beaglebone:green:usr3/brightness”;

for (int i=0;i<10;i++)
{
if((LEDHandle =fopen(LEDBrightness, “r+”))!=NULL){
fwrite(“1”, sizeof(char),1,LEDHandle);
fclose(LEDHandle);
}
sleep(1);

if((LEDHandle =fopen(LEDBrightness, “r+”))!=NULL){
fwrite(“0”, sizeof(char),1,LEDHandle);
fclose(LEDHandle);
}
sleep(1);
}
cout << “Flash stop” << endl;
return 0;
}

Glad to have helped.

Correct, it can be used, but I thought usermod (existing user) or adduser (new user) was also an acceptable method to add a user to the ‘sudo’ group. Source, Source2. Is it not?

usermod, no idea no experience with it but adduser is no. Think about it. Why would you want every user you add to the system to have sudo permissions ? Hint: You wouldnt.

So, you add a new user then if you want to give that user sudo access, you use visudo. Which originally did use vi, but now uses nano as the default editor.