CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
  • Week 1
    • 1.Operating Systems and the Kernel: What Linux Does
    • 2.The Birth of Linux: From Unix to Linus
    • 3.Free Software and Open Source: What a License Decides
    • 4.Distributions: The Unit That Bundles the Kernel and Tools for Sale
    • 5.Week 1 Review: The Identity Behind the Name Linux
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
    • 1.Package Management (1): RPM and YUM
    • 2.Package Management (2): DEB, APT, and Source Installation
    • 3.Device Files and /dev
    • 4.Using Peripherals: Printers · Sound · Scanners
    • 5.Week 7 Comprehensive Review: Packages and Devices
  • Week 8
  • Week 9
  • Week 10
  • Week 11
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← Linux Master 2/Week 7/Day 4

Based on the Linux Master 2 exam syllabus·Report an error

Linux Master 2· AssociateWeek 7 · Day 4~20 min read

Day 4 - Using Peripherals: Printers · Sound · Scanners

📌 Key Takeaways

  • The full names of the three are asked directly — CUPS (printer) · ALSA (sound) · SANE (scanner).
  • CUPS is the Common Unix Printing System. It uses the IPP protocol and its web admin page is on port 631.
  • Printer commands come in two families — BSD (lpr lpq lprm) and System V (lp lpstat cancel).
  • Sound moved from OSS to ALSA. The standard on Linux today is ALSA.
  • The scanner system is SANE, the command is scanimage, and the graphical tool is xsane.

Printers — CUPS

SystemMeaning
LPD / LPRngThe old Unix printing systems
CUPSCommon Unix Printing System — the current standard
  • Apple took part in its development, and it is also the printing system of macOS.
  • It uses IPP (Internet Printing Protocol) as its default protocol, in order to handle network printers in a standard way.
ItemValue
Web admin pagehttp://localhost:631
Config file/etc/cups/cupsd.conf
Printer list/etc/cups/printers.conf
Daemoncupsd
Spool directory/var/spool/cups

Port 631 and /etc/cups/cupsd.conf are tested as exact values.

The Path One Print Job Takes

   lpr report.txt
        │  print request
        ▼
   cupsd (scheduler)  ──►  stores the job in /var/spool/cups, assigns a number
        │
        ▼
   filter             ──►  converts the document into a format the printer understands (see PPD)
        │
        ▼
   backend            ──►  sends it along the matching path among usb · ipp · lpd · socket
        │
        ▼
   printer
  • lpr hands off the job and finishes right away. The actual printing is processed in order by the cupsd daemon. That is why the command succeeds even when the printer is off, and the job stays in the queue.
  • A PPD (PostScript Printer Description) is a file that describes the printer's paper, resolution, and features, and sits in /etc/cups/ppd/. Choosing the model when you register a printer is the same as choosing the PPD.
  • Logs go to access_log and error_log under /var/log/cups/.
FileWhat it holdsWho edits it
cupsd.confDaemon behavior — which address and port to listen on, who can accessThe administrator, directly
printers.confThe list of registered printers and each printer's device addressWritten for you by the web page and lpadmin
/etc/printcapThe old LPD-style printer list. CUPS generates it only for compatibility with old programs—
  • In the default settings, cupsd.conf opens only localhost:631. So the web admin page is reached on that computer at http://localhost:631.
  • Printers can also be registered by command rather than the web page.
lpadmin -p printer1 -E -v ipp://192.168.0.50/ipp/print -m everywhere   # register
lpadmin -d printer1                                                    # set as default printer
lpadmin -x printer1                                                    # delete
lpadmin optionMeaning
-pThe printer name to work on
-ERegister and make it ready for use right away
-vWhere the printer is — the device address (URI)
-mModel (driver, PPD)
-dSet the default printer
-xDelete the printer

The Two Families of Print Commands

TaskBSD familySystem V family
Printlprlp
Check the queuelpqlpstat
Cancellprmcancel
Controllpc—
lpr -P printer1 report.txt     # print to the specified printer
lpr -# 3 report.txt            # print 3 copies
lpq                            # check the queue
lpq -P printer1
lprm 12                        # cancel job 12
lprm -                         # cancel all my jobs
lpstat -p                      # printer status (System V)
cancel 12                      # cancel (System V)
  • lpr prints, lpq queries the queue, and lprm cancels — the three form a group.
  • Questions ask about the correspondence between the two families: lpr↔lp, lpq↔lpstat, lprm↔cancel.
  • Print jobs waiting are called the spool and pile up in /var/spool/cups.

Viewing the Queue and Canceling

$ lpr -P printer1 report.txt
$ lpq -P printer1
printer1 is ready and printing
Rank    Owner   Job     File(s)                         Total Size
active  alice   12      report.txt                      2048 bytes
1st     bob     13      memo.txt                        1024 bytes
$ lprm 12
$ lpq -P printer1
printer1 is ready and printing
Rank    Owner   Job     File(s)                         Total Size
active  bob     13      memo.txt                        1024 bytes
ColumnMeaning
RankOrder. active is printing now, and 1st, 2nd are next in line
OwnerThe user who submitted the job
JobJob number — the value you give to lprm and cancel
  • The number you give lprm is the job number (Job). It is not a file name or a printer name.
  • A regular user can cancel only their own jobs. Above, alice can delete job 12 but not bob's job 13. root can do everything.

The Same Task, Different Option Letters

TaskBSDSystem V
Specify printerlpr -P printer1lp -d printer1
Print multiple copieslpr -# 3lp -n 3
Cancel one joblprm 12cancel 12 or cancel printer1-12
Cancel all my jobslprm -cancel -a
lpstat optionWhat it shows
-pThe printer status (whether it is available, whether it is printing)
-oThe list of jobs waiting
-dThe default printer
-aWhether the queue is accepting jobs
-tAll of the above
  • The P in lpr -P is uppercase. In System V, -d (destination) does the same job. Choices that mix the options of the two families, such as lpr -d or lp -P, are wrong.
  • The System V side calls a job by printername-number (printer1-12).
  • lpc is a BSD command that controls printers and queues. In CUPS it is used only for things like checking status with lpc status.
When printing failsWhere to look
Whether the job entered the queuelpq · lpstat -o
Whether the printer is in a stopped statelpstat -p
Whether the daemon is runningsystemctl status cups
What the error was/var/log/cups/error_log
ItemLPD · LPRngCUPS
Daemonlpdcupsd
Protocol · portLPD · 515IPP · 631
Printer list file/etc/printcap/etc/cups/printers.conf
Management methodEdit config files directlyWeb page, lpadmin
  • LPRng is LPR Next Generation, that is, a reworked version of the old LPD. CUPS imitates the commands of both (lpr, lpq, lprm) so that they can be used as they are, so even though the system changed, the commands stay the same.

Sound — ALSA

SystemMeaning
OSSOpen Sound System — the old method
ALSAAdvanced Linux Sound Architecture — the current standard
  • From kernel 2.6, ALSA became the default and OSS remained as a compatibility layer.
  • ALSA supports multiple programs making sound at the same time and handling multiple sound cards.
Command · fileWhat it does
alsamixerText-screen volume control
amixerCommand-line volume control
aplay / arecordPlay / record
alsactlSave and restore settings
/proc/asound/Info on detected sound cards
/dev/dsp, /dev/mixerDevice files from the OSS era
alsamixer            # volume control (unmute with the M key)
aplay test.wav       # play
cat /proc/asound/cards   # detected sound cards
lspci | grep -i audio    # check the sound card hardware
  • When there is no sound, check mute first. In alsamixer, a MM indicator means muted, and the M key unmutes it.
  • On top of that, PulseAudio (and more recently PipeWire) sits and manages per-program volume.

The Layers Until Sound Comes Out

   application (music player · browser)
        │
   sound server    PulseAudio · PipeWire     mixes the sound of multiple programs and adjusts per program
        │
   ALSA            kernel sound drivers + libraries + tools (alsamixer · aplay)
        │
   sound card
  • ALSA is the driver layer inside the kernel. There is no separate daemon like CUPS's cupsd. So there is no port number either.
  • PulseAudio is not a replacement for ALSA but sits on top of it. If asked about "the standard sound system on Linux today", the answer is still ALSA.
ItemOSSALSA
Full nameOpen Sound SystemAdvanced Linux Sound Architecture
TargetSeveral Unix familiesLinux only
Device files/dev/dsp, /dev/mixer, /dev/audioUnder /dev/snd/
Config files—/etc/asound.conf (global), ~/.asoundrc (personal)
Support for old programs—Provides an OSS compatibility layer so old programs still run

The Four ALSA Tools

ToolNatureExample
alsamixerShows a screen and adjusts with the arrow keysalsamixer
amixerAdjusts with a single command line — good for scriptsamixer set Master 80%, amixer set Master unmute
aplay · arecordPlay · recordaplay -l (list playback devices), arecord -d 5 test.wav (record 5 seconds)
alsactlSaves and restores the current volume settingsalsactl store, alsactl restore
alsamixer keyWhat it does
← →Choose the channel to adjust (Master, PCM, Mic …)
↑ ↓Raise · lower the volume
MToggle mute — if the indicator below is MM it is muted, and OO means on
EscQuit
  • alsamixer and amixer do the same job and differ only in whether there is a screen. aplay plays uncompressed sound files such as WAV.
  • If you do not run alsactl store, the adjusted volume may not persist after a reboot.
When there is no soundCheck
Whether the card was detectedcat /proc/asound/cards, aplay -l, look for audio in lspci
Whether it is mutedThe MM indicator in alsamixer
Whether the volume is 0The Master and PCM bars in alsamixer
Whether the driver module is loadedModules starting with snd in lsmod

Scanners — SANE

ItemValue
SANEScanner Access Now Easy
NatureA standard API and toolset for handling scanners
Commandscanimage
Graphical toolxsane
Device searchsane-find-scanner, scanimage -L
Network sharingsaned (daemon)
sane-find-scanner        # find connected scanners
scanimage -L             # list detected scanners
scanimage > out.pnm      # scan to a file
xsane                    # graphical scan program
  • SANE is for scanners, CUPS is for printers — choices that swap the names are easily used as wrong answers.
  • The default format of scan results is the PNM family, and you convert to another format if needed.

Frontend and Backend

   frontend    scanimage (command line) · xsane (graphical)     the programs the user works with
        │
      SANE API
        │
   backend     per-vendor, per-model scanner drivers            talks directly to the device
        │
   scanner
  • SANE has a structure that separates the screen (frontend) from the driver (backend). So one frontend can handle scanners from multiple companies, and via the saned daemon you can also use a scanner attached to another computer.
  • Backend settings are gathered in /etc/sane.d/. The dll.conf inside it decides which backends to load.
CommandWhat it looks for
sane-find-scannerWhether a device that looks like a scanner is connected on USB or SCSI — it finds it regardless of whether it is supported
scanimage -LThe list of scanners the SANE backends can actually use
$ scanimage -L
device `epson2:libusb:001:004' is a Epson GT-1500 flatbed scanner
$ scanimage -d epson2:libusb:001:004 --resolution 300 > page1.pnm
  • If it shows up with the first command but not the second, it means it is connected but there is no matching backend.
  • scanimage sends its result to the screen (standard output). So you capture it into a file with >. You pick the device with -d, and detailed options like resolution differ by scanner.
  • xsane is a graphical frontend where you set the area while viewing a preview, and it can also be called from within the image editor GIMP.

The Three at a Glance

DeviceSystemFull nameRepresentative commands
PrinterCUPSCommon Unix Printing Systemlpr lpq lprm
SoundALSAAdvanced Linux Sound Architecturealsamixer aplay
ScannerSANEScanner Access Now Easyscanimage xsane
OldNew
LPD / LPRngCUPS
OSSALSA
ItemCUPSALSASANE
What it isA print server (daemon)A kernel driver layerA scanner API and tools
DaemoncupsdNonesaned (only for network sharing)
Config location/etc/cups//etc/asound.conf/etc/sane.d/
Graphical/screen toolWeb page (631)alsamixerxsane
Command-line toolslpr lpq lprmamixer aplay arecordscanimage
Check detectionlpstat -p/proc/asound/cardsscanimage -L
  • The initials tell you the target — the P in CUPS is Printing, the S in ALSA is Sound, and the S in SANE is Scanner. If ALSA and SANE both having an S confuses you, read it out in full: ALSA contains Linux Sound in full, and SANE contains Scanner in full.

Tomorrow we tie this week's packages and devices together on a single sheet.

📖 Glossary

  • CUPS: Common Unix Printing System. The standard printing system on Linux today.
  • IPP: Internet Printing Protocol. The network printing protocol CUPS uses.
  • Spool: Jobs piled up in the print queue. Stored in /var/spool/cups.
  • lpr / lpq / lprm: The BSD-family print / check-queue / cancel commands.
  • OSS: Open Sound System. The sound system used before ALSA.
  • ALSA: Advanced Linux Sound Architecture. The standard sound system on Linux today.
  • alsamixer: The ALSA tool for adjusting volume on a text screen.
  • SANE: Scanner Access Now Easy. The standard scanner interface on Linux.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

Which port number is used to access CUPS's web-based admin page?

Question 2

Which of the following is the full name of ALSA?

Question 3

Which of the following is the standard interface for handling scanners on Linux?

Question 4

Which command checks the list of the print queue in the BSD family?

Question 5

Which of the following is the main configuration file of CUPS?

PreviousDevice Files and /devWeek 7 · Day 3Next Week 7 Comprehensive Review: Packages and DevicesWeek 7 · Day 5

Official references

  • Linux Master 2 official exam syllabus(opens in a new tab)

On this page

  • Key Takeaways
  • Printers — CUPS
  • The Path One Print Job Takes
  • The Two Families of Print Commands
  • Viewing the Queue and Canceling
  • The Same Task, Different Option Letters
  • Sound — ALSA
  • The Layers Until Sound Comes Out
  • The Four ALSA Tools
  • Scanners — SANE
  • Frontend and Backend
  • The Three at a Glance
  • Glossary
  • Practice Questions