Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What's the command to list the all I/O ports connected to system?

Also, how do I get the status of all individual ports?

For example: printer

How do I determine whether a printer is ready to print or if there are any jobs are waiting?

For example: monitor

How do I determine whether the monitor(s) is/are active or not?

share|improve this question
Pretty sure you do not actually mean port here ("port" refers to software ip sockets), but rather, "connected hardware". If so it's a heterogeneous realm, but there are various GUI tools that try to pull everything together in some sense -- eg, your DE may have a "hardware settings" somewhere that will give you information like this. – goldilocks Mar 18 '13 at 14:17
@goldilocks What about USB port or HDMI port? That seems to be the use of the term port here. – depquid Mar 18 '13 at 15:51
Fair enough, but "port" alone is ambiguous, because devices can be accessed over a network, in which case (network) ports are involved. Hence "Pretty sure you actually mean...". If you use ambiguous terms, you ask an ambiguous question, and someone who has a good answer to what you really mean may skip it, because what they see is "input/output ports" and not "hardware ports". – goldilocks Mar 18 '13 at 16:20

As goldilocks' comment says, this is extremely heterogeneous. A printer isn't a "port" in the sense you mean, there is a whole software infrastructure handling the queues of print jobs (CUPS here, there are other alternatives). The printer might be off/disconnected, but jobs waiting. What does a USB port "in use" mean? An unmounted pendrive is plugged in? What if a USB hub is connected, and nothing is connected to it? What is a monitor "in use"? A connected user, a screensaver running, a GDM greeter?

For some of the devices it might not be possible to determine if something is connected without some activity.

And that leaves out Bluetooth and other wireless stuff.

It makes much more sense to ask e.g. if sound output is available, without regard if it is on-board, via USB, by Bluetooth, or maybe even over WiFi to some media center. I.e., ask if some functionality is available, not ask for (perhaps ephemeral) devices.

share|improve this answer

There isn't a single method because those hardware devices are extremely diverse. For example, printers can be connected directly to a machine (typically over USB, or for older printers a parallel or serial port) or accessed via a network interface (wired or wireless, possibly going via an intermediate server). So there are tools to manage printers, and tools to manage monitors, and tools to manage storage media, and so on.

lshw is the closest thing to an all-in-one hardware enumerator. It reports available hardware that's directly connected to the machine. It doesn't probe the network, that's another kettle of fish.

You can find a lot of information about hardware in /sys. It's exposed in a form that's easily readable by programs, it's not primarily designed to make sense to humans.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.