How to Scan Documents with `sane` on Arch Linux
sane
on Arch LinuxCategories:
5 minute read
Arch Linux, known for its simplicity, control, and customization, is a powerful platform for a wide range of tasks—including document scanning. When it comes to handling scanners, the SANE (Scanner Access Now Easy) project offers a robust suite of tools and backends that provide support for a wide array of scanner devices. If you’re looking to scan documents from your scanner directly on Arch Linux using open-source tools, sane
is often the go-to solution.
In this guide, we’ll cover everything you need to know about setting up and using sane
on Arch Linux, from installing the required packages to scanning documents using the command line and graphical frontends. Whether you’re a beginner or an experienced Linux user, this guide aims to offer a straightforward, comprehensive walkthrough.
Table of Contents
- Introduction to SANE
- Installing SANE on Arch Linux
- Checking Scanner Compatibility
- Connecting and Detecting Your Scanner
- Configuring SANE Backends
- Testing Scanner Access
- Scanning from the Command Line
- Scanning with Graphical Frontends
- Troubleshooting Common Issues
- Security Considerations
- Final Thoughts
1. Introduction to SANE
SANE, which stands for Scanner Access Now Easy, is an open-source API used for accessing raster image scanner hardware. It separates the backend drivers (which handle the communication with hardware) from the frontend programs (which provide user interfaces).
SANE supports both local USB-connected scanners and networked scanning devices. It works with a wide range of flatbed and multifunction printers, provided the necessary backend is available.
2. Installing SANE on Arch Linux
Arch Linux provides SANE and its related utilities via the official repositories. To get started, install the following packages:
sudo pacman -S sane simple-scan xsane
Description of Packages
sane
: Core libraries and backends for scanner support.simple-scan
: A user-friendly GTK-based graphical frontend.xsane
: A more advanced graphical frontend for SANE.- (Optional)
gscan2pdf
: For advanced PDF scanning and OCR needs.
If you prefer command-line tools, make sure the sane
package includes scanimage
, a command-line interface to your scanner.
3. Checking Scanner Compatibility
Before investing too much time, it’s wise to check if your scanner is supported by SANE. Visit the official SANE project hardware compatibility list.
You can also install the sane-airscan
package if you have a modern scanner that supports the eSCL (AirScan) protocol:
sudo pacman -S sane-airscan
This is particularly useful for scanning over the network using protocols like WSD and Apple’s AirScan.
4. Connecting and Detecting Your Scanner
Most modern scanners are plug-and-play when using USB. Once connected, you can list the available devices with:
scanimage -L
Example output:
device `epson2:libusb:001:005' is a Epson flatbed scanner
If no devices are listed, try:
sudo sane-find-scanner
This will probe your system for connected scanners and help you identify if your device is at least recognized at the hardware level.
5. Configuring SANE Backends
The configuration files for SANE are located in /etc/sane.d/
. Here’s what to look at:
- Backends: The file
dll.conf
lists the backends enabled. Make sure the backend relevant to your scanner is listed (e.g.,epson2
,canon
,hp
,pixma
). - Backend configuration: Each backend has its own configuration file in
/etc/sane.d/
. For instance,epson2.conf
orpixma.conf
.
You might need to manually specify the USB path for older or less well-supported devices. For example:
# In /etc/sane.d/epson2.conf
usb 0x04b8 0x012d
You can find the vendor and product IDs using lsusb
.
6. Testing Scanner Access
After configuration, test access:
scanimage -T
If it returns scanimage: sane_start: Operation successful
, your setup is ready.
You can also try capturing a quick scan:
scanimage --format=png > test.png
This will produce a raw scan in PNG format, which you can open in any image viewer.
7. Scanning from the Command Line
SANE’s scanimage
tool is powerful for batch scripts and automation.
Example Commands
Scan a page to PNG:
scanimage --format=png --resolution 300 > output.png
Scan to PDF using ImageMagick or GhostScript:
scanimage --format=tiff > output.tiff
convert output.tiff output.pdf # Requires ImageMagick
Multiple Pages with ADF:
If your scanner has an Automatic Document Feeder (ADF):
scanimage --batch --batch-start=1 --format=png --source "ADF" --resolution 300
This will save multiple pages as out1.png
, out2.png
, etc.
8. Scanning with Graphical Frontends
If you prefer not to deal with the command line, there are several graphical interfaces available.
Simple Scan
A straightforward interface ideal for everyday use:
simple-scan
It supports scanning to PDF, image rotation, cropping, and more.
XSane
A more advanced tool that gives fine-grained control over scanner settings:
xsane
It supports saving to multiple file formats, color management, and preview scanning.
gscan2pdf (Optional)
Install via:
sudo pacman -S gscan2pdf
It is perfect for creating high-quality PDFs and supports OCR via Tesseract.
9. Troubleshooting Common Issues
Scanner Not Detected
- Make sure the device is supported.
- Ensure proper USB permissions. Adding yourself to the
scanner
group may help:
sudo usermod -aG scanner $USER
Then log out and back in.
- Check that
saned
is not interfering. You usually don’t need the saned daemon for local scanning.
Backend Not Loaded
- Edit
/etc/sane.d/dll.conf
and make sure the right backend is uncommented. - Use
SANE_DEBUG_<backend>=255 scanimage -L
for detailed backend debugging.
Network Scanner Not Found
- Install
sane-airscan
for modern network scanners. - For older models, configure
net.conf
and enable the relevant backend. - Make sure firewall or network discovery isn’t blocking mDNS or WSD.
10. Security Considerations
If you’re exposing a scanner over the network (e.g., via saned
), make sure to:
- Restrict access via TCP wrappers (
/etc/hosts.allow
and/etc/hosts.deny
). - Use firewalls to limit access to port 6566 (default for
saned
). - Avoid running the saned daemon unless needed.
Most users only need local scanning and don’t require saned
to be enabled or running as a service.
11. Final Thoughts
Scanning documents on Arch Linux using sane
is relatively straightforward once you understand how the backend/frontend model works. Thanks to the Arch community and active development of the SANE project, most modern scanners are supported either directly or via generic drivers like AirScan.
Whether you’re a home user scanning family photos or a developer integrating scanning into a workflow, the SANE ecosystem on Arch Linux provides flexible, scriptable, and graphical solutions for all your needs.
If your scanner is not working out of the box, don’t forget to check the Arch Wiki and the SANE backend logs—they’re often your best allies in debugging scanner issues.
Resources
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.