LinuxCommandLibrary

ipcrm

Remove System V inter-process communication (IPC) objects

TLDR

Delete a shared memory segment by ID

$ ipcrm [[-m|--shmem-id]] [shmem_id]
copy

Delete a shared memory segment by key
$ ipcrm [[-M|--shmem-key]] [shmem_key]
copy

Delete an IPC queue by ID
$ ipcrm [[-q|--queue-id]] [ipc_queue_id]
copy

Delete an IPC queue by key
$ ipcrm [[-Q|--queue-key]] [ipc_queue_key]
copy

Delete a semaphore by ID
$ ipcrm [[-s|--semaphore-id]] [semaphore_id]
copy

Delete a semaphore by key
$ ipcrm [[-S|--semaphore-key]] [semaphore_key]
copy

Delete all IPC resources
$ ipcrm [[-a|--all]]
copy

SYNOPSIS

ipcrm [options]
ipcrm shm
ipcrm msg
ipcrm sem

PARAMETERS

-M shmkey
    Remove shared memory segment using the specified key.

-m shmid
    Remove shared memory segment using the specified ID.

-Q msgkey
    Remove message queue using the specified key.

-q msqid
    Remove message queue using the specified ID.

-S semkey
    Remove semaphore set using the specified key.

-s semid
    Remove semaphore set using the specified ID.

-a
    Remove all possible resources.

--version
    Display version information and exit.

--help
    Display help text and exit.

DESCRIPTION

The ipcrm command is a utility for removing System V inter-process communication (IPC) objects. These objects include shared memory segments, message queues, and semaphore sets. It provides a way to clean up resources that are no longer needed by processes, preventing resource leaks and potential conflicts. Using ipcrm requires appropriate permissions to remove the specified IPC objects. If you created the object or have superuser privileges you should be able to remove the object. Removing objects when running a process can lead to application instability. Be careful to remove the correct object.
It's important to be cautious when using ipcrm, as removing IPC objects that are still in use by running processes can lead to unexpected program behavior or data loss.

CAVEATS

Incorrectly removing IPC objects can cause applications to crash or corrupt data. Ensure you know what you are deleting. Use ipcs to list the objects and their status before removing them.

PERMISSIONS

You must have appropriate permissions to remove an IPC object. Typically, this means you must be the creator of the object or have superuser privileges.

KEYS VS. IDS

IPC objects can be identified by a key or an ID. The key is a system-wide unique identifier, while the ID is an integer assigned to the object when it is created. Using the key is often more convenient, as you don't need to know the object's ID.

HISTORY

The ipcrm command is a standard Unix utility and has been available since the early days of System V Unix. It was designed to provide a way to manage System V IPC resources, which are essential for inter-process communication.

SEE ALSO

ipcs(1), shmctl(2), msgctl(2), semctl(2)

Copied to clipboard