VOOZH about

URL: https://www.geeksforgeeks.org/linux-unix/getting-system-and-process-information-using-c-programming-and-shell-in-linux/

⇱ Getting System and Process Information Using C Programming and Shell in Linux - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Getting System and Process Information Using C Programming and Shell in Linux

Last Updated : 17 May, 2020
Whenever you start a new process in Linux it creates a file in /proc/ folder with the same name as that of the process id of the process. In that folder, there is a file named "status" which has all the details of the process. We can get those Process Information Through shell as follows:
cat /proc/1/status
👁 to-get-process-information-using-shell
As can be seen, it displays most of the information about the process. Note:, In this case, the process id is 1, it may be changed as per need. You can get the System Information through the shell. The basic system information is stored in a file named os-release in /etc/ folder.
cat /etc/os-release
👁 System-information-through-shell
You can also get the System Information using C programming. The below code is used to get the details of the system. In this code, utsname maintains a structure that has the details of the system like sysname nodename, release, version, etc. On execution the above code will give the following output: 👁 system-information-though-c
To get Process Information using C programming, use the below code. In this code, we execute the Linux command through a c program to get the details of the process. On execution the above code will give the following output: 👁 to-get-process-information1
Comment
Article Tags:
Article Tags:

Explore