Check for the Legacy /proc/apm Interface
On a modern kernel, cat /proc/apm usually just tells you the file is not there, and that absence is a fact worth understanding rather than a dead end. This guide checks whether your Linux kernel exposes /proc/apm, explains what a missing file does and does not prove, and records a result without touching any power setting. It follows the installed proc_apm(5) page from Linux man-pages 6.7, packaged as manpages 6.7-2. Budget ten minutes; you need a shell and read access to /proc, and normally no elevated privileges at all.
The route
Jump straight to the step you need, or tick off Done means at the end.
1. Check for the interface
Start with a read-only existence and readability test. Nothing below creates, alters or removes anything:
if test -r /proc/apm; then
printf '%s\n' '/proc/apm is present and readable'
else
status=$?
printf '%s\n' '/proc/apm is absent or not readable'
exit 1
fi
The first branch is the one you want. The status variable is not actually used here, because test only tells you the read check failed; it does not tell you which kind of filesystem problem you hit. For a quick interactive look, this is enough:
$ test -r /proc/apm && echo present || echo absent
absent
Checkpoint
Got present? Carry on to the next step. Got absent? Skip straight to step 4 rather than trying to conjure the path into existence.
2. Read the interface when it exists
When the file is there, read it as ordinary procfs data:
$ cat /proc/apm
The manual describes this path as carrying advanced power management version and battery information, but the installed page does not pin down a stable field-by-field format. Do not build a parser from an example lifted off another machine; capture the exact output from the kernel you are actually supporting and test any consumer against that.
Reading the file is not the same thing as enabling APM. There is no option to pass to cat, and writing to /proc/apm is not part of the interface proc_apm(5) describes. Keep the whole operation read-only.
3. Record the kernel and documentation versions
The procfs view depends on the running kernel; the wording and scope of the local manual depends on the installed man-pages package. Note both whenever you are chasing an old system or a script that behaves differently across hosts:
$ uname -r
6.8.0-139-generic
$ man --version | head -n 1
man 2.12.0
Your version strings will differ from these. The first line identifies the running kernel; the second identifies the local manual viewer, not the kernel feature itself. To confirm which page it is actually showing you, ask for its header file:
$ man -aw 5 proc_apm
/usr/share/man/man5/proc_apm.5.gz
No page found? Install or fetch the Linux man-pages documentation through your normal package source. Do not guess the procfs format just because the manual is missing.
4. Read an absent file correctly
The installed manual gives one clear boundary: /proc/apm only appears when the kernel was built with CONFIG_APM. So an absent path means this particular interface is not exposed through procfs right now. It does not prove the machine has no battery, that ACPI is broken, or that every power-management facility is switched off.
On this host the check comes back absent:
$ test -e /proc/apm && echo present || echo absent
absent
Do not respond by creating a plain file at that path. A file you make yourself carries no kernel APM data, because /proc is a kernel-managed virtual filesystem, not somewhere you can fake an entry. If some program insists on this legacy interface, report the missing capability plainly and only reach for a documented alternative after checking what that program actually needs.
5. Keep any script narrow and safe
A script that only needs to detect the interface should test the path and make its fallback explicit rather than guessing:
if test -r /proc/apm; then
printf '%s\n' 'legacy APM data is available'
cat /proc/apm
else
printf '%s\n' 'legacy APM data is unavailable' >&2
exit 1
fi
This is a capability check, deliberately not a battery monitor. Do not parse undocumented columns, assume a fixed number of batteries, or treat a successful read as proof the current charging policy is safe. If a read fails after the existence test passed, preserve the error and look at the host's procfs mount and permissions without changing either.
Warning
No command in this guide needs sudo, and running one with it will not compile CONFIG_APM into a running kernel or conjure a missing procfs entry. Swapping the kernel or changing boot configuration is a separate, service-affecting job: take a backup and schedule maintenance before you go anywhere near that.
Done means
- Tested /proc/apm with a read-only command.
- Read the file only when it was present and readable.
- Treated absence as unavailable legacy APM, not proof the machine has no power-management facilities at all.
- Recorded the running kernel version where it matters for troubleshooting.
- Avoided inventing a field format or trying to create the procfs entry yourself.