Check Whether Linux Exposes the Legacy /proc/apm Interface
You will check whether this Linux kernel exposes /proc/apm, understand what a missing file does and does not tell you, and record a result without changing power settings. The interface is documented by the installed proc_apm(5) page from Linux man-pages 6.7, packaged here as manpages 6.7-2. Allow about ten minutes. You need a shell and read access to /proc; no elevated privileges are normally required.
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. The command below does not create, alter or remove 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 useful result. The value in status is not used here because test only tells you that the requested read test failed; it does not distinguish every possible filesystem problem. For a quick interactive check, this is enough:
$ test -r /proc/apm && echo present || echo absent
absent
Checkpoint: if you get present, continue to the next step. If you get absent, skip to step 4 rather than trying to create the path.
2. Read the documented interface
When the file exists, read it as ordinary procfs data:
$ cat /proc/apm
The manual describes this path as providing advanced power management version and battery information. It does not define a stable field-by-field output format in the installed page, so do not build a parser from an example copied from another machine. Capture the exact output from the kernel you are supporting and verify any consumer against that system.
Reading the file is not the same as enabling APM. There is no documented option to pass to cat, and writing to /proc/apm is not part of the interface described by proc_apm(5). Keep the operation read-only.
3. Record the kernel and documentation versions
The procfs view depends on the running kernel, while the wording and scope of the local manual come from the installed man-pages package. Record both when diagnosing 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. The first command identifies the running kernel. The second identifies the local manual viewer, not the kernel feature itself. To confirm the page being used, ask the viewer for its header:
$ man -aw 5 proc_apm
/usr/share/man/man5/proc_apm.5.gz
If that command finds no page, install or consult the Linux man-pages documentation through your normal package source. Do not infer the procfs format from the absence of the manual.
4. Interpret an absent file
The installed manual gives one explicit boundary: /proc/apm is available when the kernel was compiled with CONFIG_APM. Therefore, an absent path means that this interface is not available through the current procfs view. It does not by itself prove that the machine has no battery, that ACPI is broken, or that all power-management support is disabled.
On this host the check reports absence:
$ test -e /proc/apm && echo present || echo absent
absent
Do not respond by creating a regular file at that path. A file you create elsewhere would not provide kernel APM data, and /proc is a kernel-managed virtual filesystem. If a program requires this legacy interface, report the missing capability clearly and use a documented alternative only after checking that program's own requirements.
5. Keep scripts narrow and safe
A script that only needs to detect the interface should test the path and make its fallback explicit:
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 deliberately a capability check, not a battery monitor. Do not parse undocumented columns, assume a particular number of batteries, or treat a successful read as proof that current charging policy is safe. If the read fails after the existence test, preserve the error and investigate the host's procfs mount and permissions without changing them.
No command in this guide needs sudo. Elevating the check will not compile CONFIG_APM into a running kernel or make a missing procfs entry appear. Any kernel replacement or boot configuration change is a separate, service-affecting operation. Take a backup and schedule maintenance before considering one.
Done means
- You tested
/proc/apmwith a read-only command. - You read the file only when it was present and readable.
- You treated absence as unavailable legacy APM exposure, not as proof that the machine lacks every power-management facility.
- You recorded the running kernel version when the result matters to troubleshooting.
- You avoided inventing a field format or attempting to create the procfs entry.