Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I want to use an SDL-based program to display graphics on the console, without having to log on from the console, and without running the program as root. For example, I want to be able to run it via ssh. The target OS is raspbian.

Here is a short example in python to illustrate the problem:

import os, pygame
os.environ['SDL_VIDEODRIVER'] = 'fbcon'
s = pygame.display.set_mode()
print "Success"

This works (runs to completion, does not throw exceptions) if I run it from the console, and it works via ssh if I run it as root.

I have checked that my user is in the audio and video groups.

I have used strace to see what is different between running it from the console (which works), running it as root via ssh (also works), and running it as a regular user via ssh (doesn't work).

The first difference was that my user did not have permission to access /dev/tty0. I created a new group (tty0), put my user in that group, and added a udev rule to give that group access to /dev/tty0.

The strace output diverges at this ioctl call - the failure is show here; ioctl returns 0 when the program is run from the console or run from ssh as root:

open("/dev/tty", O_RDWR)                = 4
ioctl(4, VT_GETSTATE, 0xbeaa01f8)       = -1 EINVAL (Invalid argument)

(The addresses also differ, but that isn't important.)

Given that my program works when it runs as root, I think this means I have a permissions problem. How do I give the necessary permissions to my user to be able to run this program without logging on at the console (and without running as root)?

share|improve this question
What are the ownership/permissions on your framebuffer device? – Bandrami Oct 6 at 6:53
Also /dev/tty generally requires membership in the console group to write to. – Bandrami Oct 6 at 6:53 looks like a solution. – Arthur2e5 Oct 23 at 23:35

1 Answer 1

Although you question is slightly ambiguous (what is meant by console), I will attempt to answer for the most common cases: /dev/console, /dev/tty, /dev/fb0 ...adapt this to the devices you need. We assume the username is "myuser."

Look at the permissions of the device (this is ubuntu 15.04)

odroid@mbrxu3:~/projects/sc$ ls -l /dev/console
crw------- 1 root root 5, 1 Oct  23  17:49 /dev/console

odroid@mbrxu3:~/projects/sc$ ls -l /dev/tty
crw-rw-rw- 1 root tty 5, 0 Oct 24 17:50 /dev/tty

odroid@mbrxu3:~/projects/sc$ ls -l /dev/fb0 
crw-rw---- 1 root video 29, 0 Jan  1  2000 /dev/fb0

Take action


the group is "root" but no group access is allowed. I don't like just adding permissions to the root group, so instead I create a group and chgrp the file and change the permissions

$ sudo addgroup --system console
$ sudo chgrp console /dev/console
$ sudo chmod g+rw /dev/console
$ sudo usermod -a -G console <myuser>     <==== replace <myuser>


$ sudo usermod -a -G tty <myuser>


$ sudo usermod -a -G video <myuser> 

You can use the usermod command to add your user to all the above groups, too, if that is your need.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.