Enabling sound for non-root Linux users

A few weeks ago I let my kids loose on a newly-setup computer running Kubuntu (a flavour of Linux). This is a shared computer between the two of them, and unlike any previous linux desktop I’ve configured, the primary users are not logging in with the account name entered into the nice Kubuntu setup program.

The problem was the silence. More specifically the silence of any of the programs running on either kid’s desktops. I knew that the sound hardware was working correctly, and could prove it, because when I logged from my machine via SSH, I could type (at the Bash prompt):

aplay /usr/share/firefox/res/samples/test.wav

And along with a reassuring “boink!” from the speakers, the terminal window showed:
Playing WAVE '/usr/share/firefox/res/samples/test.wav' : Unsigned 8 bit, Rate 22050 Hz, Mono

However from any of the applications the kids were using - be it TuxPaint, GCompris or SuperTux, there was no noise of any kind. Some even had error messages but nothing pinpointed the problem.

Even if I went to a terminal window - logged in as a child - and tried the same aplay I got a message which still didn’t really pinpoint the program:

ALSA lib confmisc.c:672:(snd_func_card_driver) cannot find card '0'
ALSA lib conf.c:3493:(_snd_config_evaluate) function snd_func_card_driver returned error: No such device
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:3493:(_snd_config_evaluate) function snd_func_concat returned error: No such device
ALSA lib confmisc.c:1072:(snd_func_refer) error evaluating name
ALSA lib conf.c:3493:(_snd_config_evaluate) function snd_func_refer returned error: No such device
ALSA lib conf.c:3962:(snd_config_expand) Evaluate error: No such device
ALSA lib pcm.c:2102:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:544: audio open error: No such device

Another application that worked when logged in remotely, but not locally, was alsamixer - which for me gave a pretty coloured display, except for the kids it crashed out with:
alsamixer: function snd_ctl_open failed for default: No such device

All this kind of message would lead towards hardware problems, except that I was already sure the hardware was working (not to mention I’d had no trouble with sound on any other Linux PC I’d set up).

However, by now I was fairly sure it was a permissions problem. The difference between logging in via SSH and running KConsole on the computer itself had nothing to do with being remote vs local - it was the user ID I was logging in with. If I used su to switch users, I could make it work or fail it on demand.

Fixing the problem was even easier, from the terminal window, logged in as root, simply type:
adduser childsname audio

This gave the child’s login account read&write rights to the sound devices /dev/snd/* and cured the silence instantly.

It sounds silly (pardon the untended pun) but completely understandable from a Linux standpoint. Linux, like it’s Unix heritage, tends to be secure by default. I’d simply never granted the kids’ logins the right to make noise.

I should be embarrassed at how long it took me to find this out. I’m just every so often reminded that my years of experience maintaining Unix and Linux computer systems as servers doesn’t necessarily translate into an instant understanding of the problems encountered by non-technical people using them as their personal computer. And being reminded of that is of course a good thing..

Actually for all I know there might have been a fancy GUI for adding user accounts that would take care of this kind of thing for me, but I didn’t use it. I’m so used to maintain Linux systems through an SSH terminal, I reach first for the command-line solution.

My reward of course was spending the rest of the afternoon listening to penguins kicking ice blocks and other game sound effects.

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.