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) | ipcsipcs -a |
| Show only shared memory segments | ipcs -mipcs --shmems |
| Show only message queues | ipcs -qipcs --queues |
| Show only semaphore arrays | ipcs -sipcs --semaphores |
| Print kernel details for one object by ID | ipcs -m -i IDipcs -q -i IDipcs -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 -cipcs --creator |
| Show creator PID (cpid) and last-operator PID (lpid) | ipcs -pipcs --pid |
| Show last attach, detach, and change times | ipcs -tipcs --time |
| Show segment and queue sizes in bytes | ipcs -bipcs --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 -lipcs --limits |
| Print allocated vs resident pages summary | ipcs -uipcs --summary |
Help and version
| When to use | Command |
|---|---|
| Show built-in usage | ipcs -hipcs --help |
| Show util-linux version | ipcs -Vipcs --version |
ipcs — command syntax
Synopsis from ipcs --help on Ubuntu 25.04 (util-linux 2.40.2):
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 bytesipcs 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:
ipcsSample output (IDs and counts vary by host):
------ Message Queues --------
key msqid owner perms used-bytes messages
------ Shared Memory Segments --------
key shmid owner perms bytes nattch
------ Semaphore Arrays --------
key semid owner perms nsemsEmpty tables are normal on a quiet workstation. Database and middleware hosts often show many shared-memory rows.
Essential List message queues and byte usage
Message queues show how many bytes and messages are waiting in the kernel.
Run the command:
ipcs -qSample output:
------ Message Queues --------
key msqid owner perms used-bytes messages
0x00000000 0 root 660 5 1Pair 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:
ipcs -m -pSample output:
------ Shared Memory Segments --------
key shmid owner cpid lpid
0x00000000 32768 postgres 1520 1563Look 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:
ipcs -lSample output (values vary by kernel config):
------ 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 = 32000Tune 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:
ipcs -uSample output:
------ Shared Memory Status --------
segments allocated = 3
pages allocated = 1024
pages resident = 1024
pages swapped = 0Rising 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:
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):
Shared memory Segment shmid=65536
uid=0 gid=0 mode=0644
access_time=... attach_time=... detach_time=...
size=4096 lpid=0 cpid=0 nattch=0Always 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:
ipcs -m --humanSample 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 when | Use something else when |
|---|---|
|
|
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.
Related commands
System V IPC workflow — inspect, create test objects, remove leaks.
| Command | One line |
|---|---|
| ipcs | List IPC resources (this page) |
| ipcrm | Remove shared memory, queues, or semaphores by ID |
| ipcmk | Create test IPC objects |
Browse the full index in our Linux commands reference.
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
- ipcrm(1) man page (Ubuntu noble)
- ipcmk(1) man page (Ubuntu noble)
