ipcs Command in Linux: Syntax, Options & IPC Monitoring Examples

Deepak Prasad
Tested on Ubuntu 25.04 (Plucky Puffin)
Package ipcs from util-linux 2.40.2
Applies to Ubuntu, Debian, RHEL, Fedora
Privilege sudo or root
Man page ipcs(1)
Scope ipcs lists System V IPC facilities in the kernel — shared memory segments, message queues, and semaphore arrays. Use it to see what applications allocated, who owns each object, and whether limits are close to.
Related guides Linux commands

ipcs — quick reference

Resource selection

Choose which System V IPC facility to list. With no flags, ipcs shows all three.

When to use Command
List shared memory, message queues, and semaphores (default) ipcs
ipcs -a
Show only shared memory segments ipcs -m
ipcs --shmems
Show only message queues ipcs -q
ipcs --queues
Show only semaphore arrays ipcs -s
ipcs --semaphores
Print kernel details for one object by ID ipcs -m -i ID
ipcs -q -i ID
ipcs -s -i ID

Extra columns

Add ownership, process, timing, or size columns to the default tables.

When to use Command
Show creator and owner usernames ipcs -c
ipcs --creator
Show creator PID (cpid) and last-operator PID (lpid) ipcs -p
ipcs --pid
Show last attach, detach, and change times ipcs -t
ipcs --time
Show segment and queue sizes in bytes ipcs -b
ipcs --bytes
Show sizes in human-readable units ipcs --human

Limits and summary

Inspect kernel ceilings and overall IPC memory usage — useful when apps fail to allocate.

When to use Command
Print kernel limits for shared memory, queues, and semaphores ipcs -l
ipcs --limits
Print allocated vs resident pages summary ipcs -u
ipcs --summary

Help and version

When to use Command
Show built-in usage ipcs -h
ipcs --help
Show util-linux version ipcs -V
ipcs --version

ipcs — command syntax

Synopsis from ipcs --help on Ubuntu 25.04 (util-linux 2.40.2):

text
ipcs [resource-option...] [output-option]
ipcs -m|-q|-s -i <id>

Show information on IPC facilities.

Resource options:
 -m, --shmems      shared memory segments
 -q, --queues      message queues
 -s, --semaphores  semaphores
 -a, --all         all (default)

Output options:
 -t, --time        show attach, detach and change times
 -p, --pid         show PIDs of creator and last operator
 -c, --creator     show creator and owner
 -l, --limits      show resource limits
 -u, --summary     show status summary
     --human       show sizes in human-readable format
 -b, --bytes       show sizes in bytes

ipcs is read-only. It reports kernel System V objects; removing them requires ipcrm (usually as root).


ipcs — command examples

Essential List every System V IPC facility

Run this first when an app complains about IPC or after a crash — you see all three tables in one view.

Run the command:

bash
ipcs

Sample output (IDs and counts vary by host):

text
------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch

------ Semaphore Arrays --------
key        semid      owner      perms      nsems

Empty tables are normal on a quiet workstation. Database and middleware hosts often show many shared-memory rows.

Essential Inspect shared memory with owner and attach count

Databases and runtimes use shared memory heavily. -m limits the listing to segments; watch nattch (attached processes).

Run the command:

bash
ipcs -m

Sample output:

output
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch
0x00000000 32768      postgres   600        524288     2

nattch = 0 after the owning process exited can mean a leaked segment — confirm with ipcs -p before removing anything with ipcrm.

Essential List message queues and byte usage

Message queues show how many bytes and messages are waiting in the kernel.

Run the command:

bash
ipcs -q

Sample output:

output
------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x00000000 0          root       660        5            1

Pair with ipcs -q -p when you need the PIDs that created or last touched a queue.

Common See creator and last-operator PIDs

When cleaning orphans, cpid points to the creator and lpid to the last process that used the object.

Map those PIDs with ps -p or ps -fp; the ps command shows full-format command lines.

Run the command:

bash
ipcs -m -p

Sample output:

output
------ Shared Memory Segments --------
key        shmid      owner      cpid       lpid
0x00000000 32768      postgres   1520       1563

Look up those PIDs with ps -p 1520 -o pid,cmd to see whether the process is still alive.

Common Read kernel IPC limits

When shmget or semget fails with "No space left on device" or EINVAL, limits — not disk — are often the cause.

Run the command:

bash
ipcs -l

Sample output (values vary by kernel config):

text
------ Messages Limits --------
max queues system wide = 32000
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 18014398509465599
max total shared memory (kbytes) = 18014398509481980

------ Semaphore Limits --------
max number of arrays = 32000
max semaphores per array = 32000

Tune limits through /proc/sys/kernel/* or sysctl on production systems — document changes before reboot.

Common Summary of allocated IPC memory

-u answers "how much shared memory is in use overall?" faster than adding rows by hand.

Run the command:

bash
ipcs -u

Sample output:

output
------ Shared Memory Status --------
segments allocated  = 3
pages allocated     = 1024
pages resident      = 1024
pages swapped       = 0

Rising segments allocated with flat application count can signal leaks.

Advanced Detailed view for one shared memory ID

After ipcs -m gives you an shmid, -i prints the full kernel structure for that segment.

Create a test segment, inspect it, then remove it:

bash
ipcmk -M 4096
SHMID=$(ipcs -m | awk 'NR==3 {print $2}')
ipcs -m -i "$SHMID"
sudo ipcrm -m "$SHMID"

Sample output from ipcs -m -i (fields vary):

text
Shared memory Segment shmid=65536
uid=0	gid=0	mode=0644
access_time=... attach_time=... detach_time=...
size=4096	lpid=0	cpid=0	nattch=0

Always ipcrm test objects you created with ipcmk when finished.

Advanced Human-readable segment sizes

Combine -m with --human when you brief others on memory footprint without mental byte math.

Run the command:

bash
ipcs -m --human

Sample output:

output
------ Shared Memory Segments --------
key        shmid      owner      perms      size       nattch
0x00000000 32768      postgres   600        512.0K     2

-b forces raw bytes if you are scripting parsers that expect integers.


ipcs — when to use / when not

Use ipcs whenUse something else when
  • You need System V shared memory, message queues, or semaphores
  • An app failed to allocate IPC and you must see existing objects
  • You are hunting orphan segments after a crash (nattch = 0)
  • You want kernel IPC limits before changing sysctl
  • You need POSIX message queues → mq-stat / /dev/mqueue
  • You need pipes or Unix domain sockets → lsof or ss
  • You want to delete an object → ipcrm (root)
  • You want to create test objects → ipcmk

ipcs vs ipcrm

ipcs ipcrm
Action List / inspect Remove
Privilege Usually none root for others' objects
Typical flow ipcs -m → find shmid → ipcrm -m ID

ipcs never deletes resources — pair it with ipcrm only after you confirm the ID is unused.


ipcs — interview corner

What does the ipcs command show?

ipcs prints System V IPC objects the kernel knows about: shared memory segments, message queues, and semaphore arrays. Each row includes a key, an ID (shmid, msqid, or semid), owner, permissions, and size or usage columns.

It does not list POSIX mqueues, pipes, or network sockets.

A strong answer is:

"ipcs reports System V shared memory, message queues, and semaphores — keys, IDs, owners, and usage. It's the first tool I use when IPC allocation fails or after a crashed app."

What is the difference between ipcs and ipcrm?

ipcs is read-only inspection. ipcrm deletes a resource by type and ID, for example ipcrm -m 32768 for shared memory.

Workflow: list with ipcs -m, confirm nattch is zero or the app is gone, then remove with ipcrm as root.

A strong answer is:

"ipcs lists IPC objects; ipcrm removes them by ID. I never ipcrm production IDs until I verify nothing is attached."

What does nattch mean in ipcs -m output?

nattch is the number of processes currently attached to the shared memory segment. When it is 0, no process maps that segment — it may be orphaned after a crash, but confirm with ipcs -p and application docs before ipcrm.

A strong answer is:

"nattch is attached process count. Zero can mean an orphan, but I cross-check PIDs and app ownership before removing the segment."

How do you check IPC limits in Linux?

Run ipcs -l (or ipcs --limits). It prints maximum queue counts, message sizes, shared memory segment limits, and semaphore array ceilings enforced by the kernel.

When creation fails, compare current usage (ipcs -u) against these limits before raising sysctl values.

A strong answer is:

"ipcs -l shows kernel IPC limits for messages, shared memory, and semaphores — I use it when shmget or semget errors mention space or limits."

When do you use ipcs -i?

-i ID dumps detailed metadata for one object — attach times, mode, size, cpid, lpid, nattch. You must combine it with a resource flag: ipcs -m -i 32768.

Use it after ipcs -m when the summary table is not enough for a ticket or post-mortem.

A strong answer is:

"ipcs -m -i ID gives the full kernel record for one shared memory segment — times, mode, size, and attach count."


Troubleshooting

Symptom Likely cause Fix
Empty tables No System V IPC in use Normal on many hosts; reproduce while the app runs
shmget: No space left on device Limits or leaked segments ipcs -m; ipcs -l; remove orphans with ipcrm
Cannot remove segment Still attached (nattch > 0) Stop the process or detach; then ipcrm
ipcs -i fails Wrong ID or wrong -m/-q/-s flag Match ID from the correct table
Expected queue missing App uses POSIX mqueues, not SysV Not visible in ipcs
Sizes hard to read Default column units Add --human or -b

References

Rohan Timalsina

is a technical writer and Linux enthusiast who writes practical guides on Linux commands and system administration. He focuses on simplifying complex topics through clear explanations.

  • Linux
  • HTML5
  • JavaScript
  • Web Design
  • Front-end Web Development