Shared memory and Semaphores are types of IPC. IPC stands for Inter Process Communication. There are couple more IPCs, namely Pipes & Message Queue. I am not going to go deep into the details of these IPCs because its not in the context here. Lets directly go to the commands under discussion:
ipcs: To display the shared memory and semaphores.
Example: ipcs command with -a option lists all the IPC facilities which can be read by the current process. It provides details about message queue, semaphore and shared memory.
# ipcs -a ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0xc616cc44 1056800768 oracle 660 4096 0 0x0103f577 323158020 root 664 966 1 0x0000270f 325713925 root 666 1 2 ------ Semaphore Arrays -------- key semid owner perms nsems 0x0103eefd 0 root 664 1 0x0103eefe 32769 root 664 1 0x4b0d4514 1094844418 oracle 660 204 ------ Message Queues -------- key msqid owner perms used-bytes messages 0x000005a4 32768 root 644 0 0
Command to list all Message Queues, -q.
$ ipcs -q ------ Message Queues -------- key msqid owner perms used-bytes messages 0x000005a4 32768 root 644 0 0