LinuxCommandLibrary

ipcs

Report Inter-Process Communication facilities status

TLDR

Show information about all the IPC

$ ipcs -a
copy

Show information about active shared [m]emory segments, message [q]ueues or [s]empahore sets
$ ipcs [-m|-q|-s]
copy

Show information on maximum allowable size in [b]ytes
$ ipcs -b
copy

Show [c]reator's user name and group name for all IPC facilities
$ ipcs -c
copy

Show the [p]ID of the last operators for all IPC facilities
$ ipcs -p
copy

Show access [t]imes for all IPC facilities
$ ipcs -t
copy

Show [o]utstanding usage for active message queues, and shared memory segments
$ ipcs -o
copy

SYNOPSIS

ipcs [options]

Common usage examples:
ipcs -a
ipcs -m -p -t

PARAMETERS

-s, --semaphores
    Displays information about semaphore arrays.

-q, --queues
    Displays information about message queues.

-m, --shmems
    Displays information about shared memory segments.

-a, --all
    A shorthand option to display information about all three IPC facilities: shared memory, message queues, and semaphores. (Equivalent to -s -q -m).

-p, --pid
    Shows the process IDs (PIDs) of the last operations on the IPC resources. For shared memory, it shows the PIDs of the last shmat/shmdt operations. For message queues, the PIDs of the last msgsnd/msgrcv. For semaphores, typically the last semop.

-l, --limits
    Shows the system-wide limits for IPC facilities as configured in the kernel. This includes maximum number of segments/queues/arrays, maximum size, etc.

-t, --time
    Shows the time of last operations on the IPC resources (e.g., last attach/detach for shared memory, last send/receive for message queues, last semaphore operation).

-c, --creator
    Displays the creator (process that created the resource) and owner (current owner) of the IPC facilities.

-u, --users
    Shows the user ID (UID) and group ID (GID) of the owner and creator of the IPC facilities.

-i id, --id id
    Displays detailed information about a specific IPC resource identified by its unique ID (e.g., shared memory ID, message queue ID, or semaphore array ID). This ID can be obtained from a general ipcs listing.

-k, --key
    Displays the IPC key associated with each resource. Keys are used by applications to obtain an ID for an IPC resource when creating or accessing it.

DESCRIPTION

The ipcs command provides a snapshot of interprocess communication (IPC) facilities currently in use on a Linux system. These facilities primarily include shared memory segments, message queues, and semaphore arrays, as managed by the System V IPC mechanism.

It is an essential tool for system administrators and developers to monitor, debug, and manage applications that rely on IPC. By listing details such as resource IDs, keys, owners, permissions, sizes, and the number of attached processes, ipcs helps identify potential resource leaks, monitor usage, and troubleshoot performance issues related to IPC resources.

CAVEATS

Permissions: To see all IPC facilities on the system, root privileges are often required. Without them, ipcs might only show resources owned by the current user or globally readable ones.

Output Format Variations: The exact column headers and format of the output can vary slightly between different Unix-like operating systems, Linux distributions, or even kernel versions. Always consult your system's man ipcs for precise details.

System V IPC Only: ipcs reports exclusively on System V IPC facilities. POSIX IPC mechanisms (e.g., shm_open(), mq_open(), sem_open()) are not reported by this command. For POSIX IPC, you might need to inspect files in /dev/shm or similar locations.

UNDERSTANDING OUTPUT COLUMNS

When ipcs lists IPC resources, it provides several columns of information. Common ones include:
ID: The unique identifier for the IPC resource (e.g., shmid, msqid, semid).
KEY: The IPC key used to access the resource.
OWNER: The user ID (UID) of the owner.
PERMS: The access permissions (octal) for the resource.
BYTES (for shared memory): The size of the shared memory segment in bytes.
NATTCH (for shared memory): The number of processes currently attached to the shared memory segment.
LAST_OP (for queues/semaphores): The PID of the process that performed the last operation.
CPID/LPID (for shared memory): The PID of the creator and last attach/detach process, respectively.
MSGQBYTES (for queues): The maximum number of bytes allowed in the message queue.

COMMON USE CASES

ipcs is frequently used for:
1. Debugging Applications: Identifying if IPC resources are being created correctly, if processes are attaching/detaching as expected, or if queues are filling up.
2. Resource Management: Checking for 'orphaned' IPC resources that might remain after a process crashes, which can consume system memory or other limits.
3. Performance Monitoring: Assessing the number of attached processes to shared memory segments or the size of message queues to identify potential bottlenecks.
4. System-Wide Limits: Using ipcs -l to verify current kernel IPC limits and compare them against application requirements or system capacity.

HISTORY

The ipcs command is a legacy utility that originated with System V Unix, which introduced the System V IPC mechanisms (shared memory, message queues, and semaphores) as a fundamental means for interprocess communication. It has been a core component of Linux since its early development, providing a crucial interface for inspecting the status of these kernel-managed resources. Its design and functionality have remained largely consistent over the decades, reflecting its foundational role in Unix-like operating systems.

SEE ALSO

ipcrm(1), ipcmk(1), lsipc(1), sysctl(8)

Copied to clipboard