tayadual.blogg.se

Linux list all processes
Linux list all processes





linux list all processes

RSS (Resident Set Size) is the portion of RAM (Physical Memory) that a process is using. VSZ is used to show the amount of virtual memory used by process.

  • VSZ and RSS : Show the amount of memory used by the process.
  • %MEM : Display the utilized memory by the process in percentage.
  • %CPU : Display the amount of CPU in percentage, the process is currently using.
  • You can see in the ps command output the INIT process has a process id 1.
  • PID : It gives you the PID number of the process.
  • USER: It gives you the name of user who started the process, you can say the owner of the process.
  • Let’s I will explain each and every column of the ps command output. USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND Don’t Miss: What is Process ID or PID in Linux? List Of All Running ProcessĮxecute the below command to list all running process on your Linux system. When we run this script, we get the same result: $. # Add the found child process to all_children Find the child processes of process $pĮcho "All child processes of process with PID $root_pid:" Local children=$(cat /proc/$pid/task/$tid/children) # Get the child processes in /proc/$pid/task/$tid/children # Iterate over all s in /proc/$pid/task directory # Recursive function to find the child processes # all_children: Array that shall store the child processes # That is the PID of the process whose child processes we want to find We can automate the above recursive process using a shell script, namely find_children.sh: #!/bin/bash So, the child processes we got are the same as the ones obtained by running the pstree command. The children files corresponding to these processes are empty.

    linux list all processes

    The processes with PIDs 62 don’t have any child processes. We can continue inspection in the same manner: $ ls /proc/6246/taskĪs we see from the output of the execution of the above commands, the process with PID 6246 has only one child.

    linux list all processes

    The PIDs of the child processes of the parent process with PID 6245 is in the /proc/6245/task/6245/children file, namely 62. There is only one directory, /proc/6245/task/6245, since our process is not multi-threaded. We have the directory /proc/6245 for the process obtained by running the parent.sh script. Keeping in mind the explanations so far, let’s investigate the directory structure in our example: $ ls /proc/6245/task The subdirectory corresponding to the main thread is the same as the PID of the process. Hence, we called the name of this subdirectory as (thread id). There is one subdirectory in the /proc//task directory for each thread of the process. The name of each subdirectory is the PID of the corresponding process. The /proc directory contains one subdirectory for each running process. Let’s explain the directory structure a little bit. We can find the PIDs of the child processes of a parent process in the children files located in the /proc//task/ directories. It contains information about the kernel, system, and processes. In fact, this isn’t a directory but a virtual file system mounted at /proc automatically by the system. We can also find the child processes of a parent process using the /proc directory.







    Linux list all processes