How to configure your SCSI or USB scanner to work with SANE/XSANE from your regular user account

Version 1.0
Author: VirtualEntity <lafeyette_management [at] comast [dot] net>

When I try to run XSANE, the program reports "No devices found" and doesn't see my scanner. When I run sane-find-scanner, the same thing happens and the program reports that no scanners were found.

In the words of Linux Format Magazine, "Unix is traditionally rather restrictive about users accessing physical devices, so everything is split up into multipe groups in order for granular access to be provided."

In other words, this is one of those "permissions things".

Since root has access to everything, it should be no surprise that root has no problem getting to the scanner.

Normal users, however, have very limited access to devices, so it will be necessary to grant your particular user account access to the scanner (or any other device that it otherwise would not have access to.)

For the purposes of this howto, we will consider my scanner, an HP C2520A 3644 SCSI scanner that I found in the trash a few years ago and put aside (and, boy, am I glad I did!).

First of all, I needed to "find" my scanner, that is, to find out what device it is using.

Obviously, if you have read the problem description, using sane-find-scanner from my regular account does me no good at all. But, running this command as root should work:

[root@berlin dev]# sane-find-scanner
found SCSI processor "HP C2520A 3644" at /dev/sg0
# Your SCSI scanner was detected. It may or may not be supported by SANE. Try
# scanimage -L and read the backend's manpage.
# No USB scanners found. If you expected something different, make sure that
# you have loaded a driver for your USB host controller and have installed a
# kernel scanner module.

Okay, now we know that the scanner is identified by the system as /dev/sg0.

Now, we need to know the user and group that owns /dev/sg0:

[root@berlin dev]# ls -al sg0
crw-rw---- 1 root disk 21, 0 Apr 16 07:02 sg0
^ ^

user -------| |--------group

Okay, now we know that the group to which /dev/sg0 belongs is disk.

In the case of a USB scanner, this will probably be different, e.g. it might be /dev/usb, /dev/scanner or even something else. The point is, you can use the above technique to find your scanner whereever it lurks.

Now, the next step is simply to add your user account to the disk group.

Either edit /etc/group and add your username (vmorgo in my case) to the line of /etc/group beginning with disk like so:

root:x:0:root
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon
tty:x:5:
disk:x:6:root,vmorgo

or simply use usermod to do the trick. When using groupadd, the command would be:

usermod -G samba,disk vmorgo

assuming that you are already (and wish to remain) a member of the group samba.

Remember that omitting the groups you are ALREADY a member of when using the usermod command will result in DELETING your account from those groups!

When you are done and have saved your changes, you will need to log out and log back in again for the new permissions to take effect. (How very Windows....)

NOTE:
Manually changing the permissions on /dev/sg0 (or any other item in /dev is not recommended. In any event, the changes will not "stay" between reboots; that is, they will be erased and undone at the end of the session.

Share this page:

2 Comment(s)