Inspect Linux IPC Resources Safely with ipcs
You will finish with a read-only workflow for finding System V shared memory segments, message queues and semaphore sets, then narrowing an entry down to its owner, creator, PIDs and timestamps. The examples use the installed ipcs binary from util-linux 2.41.3. The local manpage is labelled util-linux 2.39.3, so confirm the syntax on your own host if the versions differ.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes. You need a shell and a normal user account. No example below creates, removes or alters an IPC resource, and the normal inspection commands do not need elevated privileges. Use sudo only if a permission error tells you that 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 all util-linux releases, and Linux's command is not fully compatible with the POSIX utility. In particular, do not copy POSIX-only options such as -o from another system and assume they work 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 contain only column headings or no entries. That is a valid result, not a command failure.
For a compact health view, ask for the status summary:
$ 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 that 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 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. The --all or -a option explicitly requests all three classes, which is also the default.
Do not confuse an empty list with a permission problem. First check the command's exit status:
$ 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 when 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 are shown 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: if you provide several, the last one wins. The practical trap is a command such as ipcs -p -t, where the time view replaces the PID view rather than adding to it. Run separate commands when you need two views.
5. Inspect limits without misreading 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, 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:
$ ipcs --queues --id QUEUE_ID
$ ipcs --semaphores --id SEMAPHORE_ID
Replace the placeholders with numeric IDs copied from your own output. The --id option must be paired with --shmems, --queues or --semaphores; an ID alone 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 that 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 use the older control-call mechanism instead. That fallback can show only resources for which your user has read permission.
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 required by your host:
$ sudo ipcs --all
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 require an identified owner, a maintenance plan and a recovery path before it is considered.
Done means
- You confirmed the binary and installed util-linux version.
- You know whether the host has shared memory, queues or semaphore sets in use.
- You selected a resource class and an output view that match your question.
- You used the matching resource option when looking up a particular ID.
- You checked units before copying limits into a script or report.
- You kept the workflow read-only and did not remove or alter an IPC resource.