Use of Linux ipcs command

Use of Linux ipcs command

1. Command Introduction

The ipcs command is used to report the status of inter-process communication facilities in Linux. The displayed information includes message lists, shared memory, and semaphore information. It can help developers locate problems in inter-process communication.

2. Command format

ipcs [resource-option] [output-format]
ipcs [resource-option] -i id

3. Command Options

-i, --id [id]: Display detailed IPC information of the specified resource ID. You need to specify the resource type when using it. Resources include message queues (-q), shared memory (-m), and semaphores (-s).
-h, --help: Display help information -V, --version: Display version information IPC resource type options:
-q, --queues: Display active message queue information -m, --shmems: Display active shared memory information -s, --semaphores: Display active semaphore information -a, --all: Display all IPC information in the system. The default output format options for the command: When multiple options are specified, the last one takes precedence.
-c, --creator: View the creator and owner of the IPC -l, --limits: View the limit information of the IPC resource -p, --pid: View the process ID of the creator and last operator of the IPC resource
-t, --time: View the detailed time of the latest call to IPC resources. This includes operations on message queues using msgsnd() and msgrcv(), operations on shared memory using shmat() and shmdt(), and operations on semaphores using semop().
-u, --summary: View the IPC resource status summary information. Display size unit control options: Only effective for option -l (--limits).
-b, --bytes: Display size in bytes --human: Display size in human readable format

4. Common Examples

(1) Display all IPC information.

[root@TENCENT64 /]# ipcs
------ Message Queues --------
key msqid owner perms used-bytes messages  

------ Shared Memory Segments --------
key shmid owner perms bytes nattch status   
0x6674431e 0 root 600 50485760 9

------ Semaphore Arrays --------
key semid owner perms nsems   
0x0000870a 0 root 666 1

(2) Display information about the specified shared memory ID.

[root@TENCENT64 /]# ipcs -m -i 32769

Shared memory Segment shmid=32769
uid=0 gid=0 cuid=0 cgid=0
mode=0666 access_perms=0666
bytes=12000 lpid=2784 cpid=1077 nattch=3
att_time=Thu Dec 27 10:39:32 2018 
det_time=Thu Dec 27 10:39:32 2018 
change_time=Fri Jul 20 13:17:41 2018

(3) Check the process ID of the creator and the last operator of the IPC.

------ Message Queues PIDs --------
msqid owner lspid lrpid   

------ Shared Memory Creator/Last-op PIDs --------
shmid owner cpid lpid   
0 root 702 23364   
32769 root 702 5296

Among them, lspid represents the "process number" of the last message sent to the message queue, and lrpid corresponds to the "process number" of the last message read from the message queue. But please note: the process number here is a weak process number, that is, it may represent the thread number. If the thread in the process sends and receives messages to the message queue, the pid here corresponds to the thread number. You can use ps -AL | grep pid to find the process id corresponding to the thread.

The above is the detailed content of the use of Linux ipcs command. For more information about Linux ipcs command, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Detailed Tutorial on Using xargs Command on Linux
  • Use of Linux tr command
  • Linux sar command usage and code example analysis
  • Use of Linux ls command
  • Use of Linux sed command
  • Use of Linux read command
  • Use of Linux usermod command
  • Use of Linux passwd command
  • Detailed explanation of the use of Linux time command
  • Use of Linux ln command
  • Use of Linux telnet command

<<:  Vue+element implements drop-down menu with local search function example

>>:  Detailed analysis of MySQL optimization of like and = performance

Recommend

Detailed introduction to CSS font, text, and list properties

1. Font properties color, specifies the color of ...

Detailed explanation of the use of custom parameters in MySQL

MySQL variables include system variables and syst...

Solution to inconsistent display of cursor size in input box

The cursor size in the input box is inconsistent T...

CSS performance optimization - detailed explanation of will-change usage

will-change tells the browser what changes will h...

Tutorial on configuring and using i3 window manager in Linux

In this article, I will show you how to install a...

Build a WebRTC video chat in 5 minutes

In the previous article, I introduced the detaile...

Example code for implementing card waterfall layout with css3 column

This article introduces the sample code of CSS3 c...

Goodbye Docker: How to Transform to Containerd in 5 Minutes

Docker is a very popular container technology. Th...

jQuery implements clicking left and right buttons to switch pictures

This article example shares the specific code of ...

Summary of methods for writing judgment statements in MySQL

How to write judgment statements in mysql: Method...

Linux lossless expansion method

Overview The cloud platform customer's server...

Detailed explanation of Navicat's slow remote connection to MySQL

The final solution is in the last picture If you ...