Home / Alt manpages / ipcs(1)

  • ipcs(1)
  • User command
  • linux

Inspect Linux IPC Resources Safely with ipcs

A shared memory segment nobody remembers creating, or a queue that never drains: ipcs lists every System V IPC resource on the box in seconds. It is entirely read-only. The examples use the installed ipcs binary from util-linux 2.41.3, and the whole check takes about ten minutes.

  • What you need. A shell and a normal user account. The local manpage here is labelled util-linux 2.39.3, so confirm the syntax on your own host if the versions differ.
  • What this will not touch. No command below creates, removes or alters an IPC resource, and the normal inspection commands do not need elevated privileges. Reach for sudo only when a permission error says the information is not readable as your current user.

1. Confirm the installed command

Check which executable is being used and record its version. This is an ordinary read-only check:

$ command -v ipcs
/usr/bin/ipcs
$ ipcs --version
ipcs from util-linux 2.41.3

The version matters because ipcs is not identical across every util-linux release, and the Linux command is not fully compatible with the POSIX utility of the same name. Do not copy a POSIX-only option such as -o from another system and assume it works here.

Checkpoint

If command -v finds an unexpected path, inspect your PATH before trusting later output. If the binary is missing, install the distribution package that provides util-linux through your normal package-management process.

2. Take the default inventory

Run ipcs without options:

$ ipcs

The default view covers all three resource types: shared memory segments, message queues and semaphore arrays. On a quiet host, a section may hold only column headings or no entries at all. That is a valid result, not a command failure.

For a compact health view, ask for the status summary instead:

$ ipcs --summary
------ Messages Status --------
allocated queues = 0
used headers = 0
used space = 0 bytes

------ Shared Memory Status --------
segments allocated 1
pages allocated 1
pages resident  1
pages swapped   0
Swap performance: 0 attempts  0 successes

------ Semaphore Status --------
used arrays = 0
allocated semaphores = 0

Counts and spacing vary with kernel state, and the sample above is only an illustration from this machine. Treat the labels as the useful part. A non-zero count means resources exist; it does not by itself identify a leak or a fault.

3. Select one resource class

When the default output is noisy, select the class that actually matters:

$ ipcs --shmems
$ ipcs --queues
$ ipcs --semaphores

These are read-only views of active shared memory segments, message queues and semaphore sets. The short forms are -m, -q and -s. --all or -a explicitly requests all three classes, which is also the default.

Do not confuse an empty list with a permission problem. Check the command's exit status first:

$ ipcs --queues >/tmp/ipcs-queues.txt
$ status=$?
$ printf 'ipcs status: %s\n' "$status"
ipcs status: 0

This temporary capture changes no IPC state. Remove the file once you have finished reviewing it:

$ rm -- /tmp/ipcs-queues.txt

4. Add the view that answers your question

The resource class and the output format are separate choices. For example, show creator and owner details for shared memory:

$ ipcs --shmems --creator

Use --pid to show the creator and last operator PIDs:

$ ipcs --queues --pid

Use --time to see the operation times. The meaning depends on the resource: message send and receive times for queues, attach and detach times for shared memory, and semaphore operation times for semaphore sets:

$ ipcs --all --time

Only one output-format option takes effect at a time: give several and the last one wins. The practical trap is a command such as ipcs -p -t, where the time view silently replaces the PID view instead of adding to it. Run separate commands when you need two views.

5. Inspect limits without misreading the units

Ask for resource limits with --limits:

$ ipcs --limits

By default, sizes use human-readable binary units. The manpage describes a displayed K or M as a shortened form of KiB or MiB, based on powers of 1024. If a script needs unambiguous byte values, add --bytes:

$ ipcs --limits --bytes

--human requests human-readable formatting explicitly. These representation options affect the limits view only, not ordinary resource listings. Do not parse a human-readable value as decimal kilobytes without checking the header and the option used.

6. Get full details for one ID

First obtain an ID from the relevant listing, then combine --id with exactly one resource option. For a shared memory ID represented by SHM_ID:

$ ipcs --shmems --id SHM_ID

For a message queue or semaphore set, use the matching class instead:

$ ipcs --queues --id QUEUE_ID
$ ipcs --semaphores --id SEMAPHORE_ID

Replace the placeholders with numeric IDs copied from your own output. --id must be paired with --shmems, --queues or --semaphores; an ID on its own does not tell ipcs which resource namespace to inspect.

If the ID has disappeared, the command may report no matching resource. That can happen when an application removes it between the listing and the detail query. Re-run the listing rather than assuming a new ID refers to the same application.

7. Handle access and safety boundaries

The current implementation reads information by parsing /proc/sysvipc. If /proc is unavailable, util-linux can fall back to the older control-call mechanism, which can show only resources your user has read permission for.

If a listing is incomplete or reports a permission error, preserve the original output and retry only the same read-only command with the privilege your host requires:

$ sudo ipcs --all

Warning

Do not use sudo as a general fix for an empty result, and do not turn an inspection task into cleanup. ipcs does not remove resources. Resource removal belongs to ipcrm, which can disrupt running applications and should need an identified owner, a maintenance plan and a recovery path before you touch it.

Done means

  • Confirmed the binary and installed util-linux version match what this guide expects.
  • Know the state of shared memory, queues and semaphore sets on the host.
  • Selected a resource class and output view that match your actual question.
  • Used the matching resource option when looking up a particular ID.
  • Checked units before copying limits into a script or report.
  • Kept the workflow read-only and did not remove or alter an IPC resource.