Tuesday, July 28, 2015

Linux, not chmod, groups!

In english

I was reviewing my logs, and I was surprised to see that every week, hundreds of people were going to this page (even though it was posted well over 2 years ago):
http://raspberry-python.blogspot.com/2012/09/pas-chmod-groupes.html

This is great if you can read french, but if not... here's a translation.

Groups

The use of chmod to resolve permission issues appear on a regular basis on forums and in tutorials for Linux.

This is quite a risky proposition, particularly if you are very permissive (chmod 777 !!)

Or another option I've seen is to simply use sudo.

By simply mastering one thing, most of the time you can make this problem go away: using groups.

For example, if we have something like this:

fdion@raspberrypi ~ $ ls -al /dev/fb0
crw-rw---- 1 root video 29, 0 Dec 31 1969 /dev/fb0

Permissions on this file are defined as:
c, owner (root): read write, no exec, group (video): read write, no exec, and for everybody else, no access.

If I would like for my python script under my fdion account, or really any program that I run, to read and write the framebuffer (any program using the SDL would be a candidate), I only need to do:

usermod -a -G video fdion  and in this way I added fdion to the video group.

That is it. While on the topic of SDL, I would recommend doing at a minimum:

sudo usermod -a -G video fdion
sudo usermod -a -G audio fdion
sudo usermod -a -G input fdion

This way you'll be able to use the video, audio, mouse etc.

Francois Dion
@f_dion

No comments: