10+ ipcs command examples in Linux [Cheat Sheet]

Introduction to ipcs command

ipcs provides information on ipc facilities. ipc stands for Interprocess communication. It allows processes to communicate with each other. ipcs displays the information about message queues, shared memory segments, and semaphore arrays.

 

ipcs command syntax

The general syntax of ipcs command is:

Advertisement
$ ipcs [option]

You can use ipcs command without any option to view the information on the ipc facilities.

ipcs command to display information on the ipc facilities

Now, let's see different examples to use ipcs command in the Linux system.

 

Different examples to use ipcs command

1. ipcs command to display all information on ipcs facilities

-a or --all option is used to display all information on ipcs facilities. However, the output is the same as the default ipcs command output.

$ ipcs -a

OR

$ ipcs -all

Sample Output:

ipcs command to display all information on the ipc facilities

 

2. ipcs command to display only message queues

With -q or --queues option, you can view only message queues. The Message queues can be best described as an internal linked list within the kernel's addressing space. Messages can be sent to the queue in order and retrieved from the queue in several different ways. Each message queue (of course) is uniquely identified by an IPC identifier.

Advertisement
$ ipcs -q

OR

$ ipcs --queues

Sample Output:

ubuntu@golinux:~$ ipcs -q

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
           0          root       660        5            1    

ubuntu@golinux:~$ ipcs --queues

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
           0          root       660        5            1     

Here we see a single message queue which has an identifier of 0. It is owned by the user root, and has octal permissions of 660, or -rw-rw--. There is one message in the queue, and that message has a total size of 5 bytes.

 

3. Display only shared memory segments using ipcs command

-m or --shmems option displays the information of shared memory segments only.

$ ipcs -m

OR

$ ipcs --shmems

Sample Output:

ipcs command to display shared memory segments

 

4. Display only semaphore arrays using ipcs command

You can use -s or --semaphores option to view information of semaphore arrays only.

$ ipcs -s

OR

Advertisement
$ ipcs --semaphores

Sample Output:

ubuntu@golinux:~$ ipcs -s

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     

ubuntu@golinux:~$ ipcs --semaphores

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     

Currently there are no active semaphore operations ongoing on our server, to check the semaphore recourse limit you can use:

~]# ipcs -ls

------ Semaphore Limits --------
max number of arrays = 32000
max semaphores per array = 32000
max semaphores system wide = 1024000000
max ops per semop call = 500
semaphore max value = 32767

 

5. Show attach/detach/change time with ipcs command

-t or --time option tells ipcs to show attach, detach and change times in the output.

$ ipcs -t

OR

ipcs --time

Sample Output:

ipcs command to show attach, detach and change times

 

6. ipcs command display creator and owner

-c or --creator option helps to find the creator and owner of the ipc facilities.

$ ipcs -c

OR

$ ipcs --creator

Sample Output:

ipcs command to show creator and owner

 

7. Display PIDs of creator and last operator with ipcs command

-p or --pid option shows PIDs of the creator and last operator in the output.

$ ipcs -p

OR

$ ipcs --pid

Sample Output:

ipcs command to show PIDs of creator and last operator

 

8. ipcs command to show resource limits

-l or --limits option helps to show resource limits of ipc facilities.

$ ipcs -l

OR

$ ipcs --limits

Sample Output:

ipcs command to show resource limits

 

9. ipcs command to show information summary

You can view the summary of information using -u or --summary option with ipcs command.

$ ipcs -u

OR

$ ipcs --summay

Sample Output:

ipcs command to show status summary

 

10. ipcs command to show sizes in bytes

-b or --bytes option displays the used bytes in the output.

$ ipcs -b

OR

$ ipcs --bytes

Sample Output:

ipcs command to show sizes in bytes

 

11. ipcs command to show sizes in human-readable format

--human option tells ipcs to show sizes in human-readable format, i.e., in kilobytes, megabytes, etc.

$ ipcs --human

Sample Output:

ipcs command to show sizes in human readable format

 

12. ipcs command to display information of specified ID

You can use -i option to specify an ID of the resource. It shows the information of that particular resource. When using an -i option, you must identify only a single resource. For example, to print details on ID 27 of shared memory segments, you should use:

$ ipcs -m -i 27

Sample Output:

ipcs comand to print details with specific id

To print details on the ID of message queues, you can use:

$ ipcs -q -i ID

To print details on the ID of semaphore arrays, you can use:

$ ipcs -s -i ID

 

Conclusion

This is the end of our tutorial on ipcs command. We hope you will be now able to view information on the ipc facilities using ipcs command. If you still have any confusion, let us know in the comment section.

 

What's Next

15+ lsof command examples in Linux [Cheat Sheet]

 

Further Reading

man page for ipcs command

 

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment