Terminal Commands For Processes
There are two commands available in Linux to track running processes. These two commands are Top and Ps.
Using top
:
- PID: Unique Process ID given to each process.
- User: Username of the process owner.
- PR: Priority given to a process while scheduling.
- NI: ‘nice’ value of a process.
- VIRT: Amount of virtual memory used by a process.
- RES: Amount of physical memory used by a process.
- SHR: Amount of memory shared with other processes.
- S: state of the process
- ‘D’ = uninterruptible sleep
- ‘R’ = running
- ‘S’ = sleeping
- ‘T’ = traced or stopped
- ‘Z’ = zombie
- %CPU: Percentage of CPU used by the process.
- %MEM; Percentage of RAM used by the process.
- TIME+: Total CPU time consumed by the process.
- Command: Command used to activate the process.
using ps
:
Command | Description |
---|---|
PID | process ID |
TTY | terminal type |
TIME | total time the process has been running |
CMD | name of the command that launches the process |
To kill the particular process we can use the PID or process Id
kill [PID]
In case the process ignores the normal kill request then we can send the signal -9
SIGKILL
to the process.
kill -9 [PID]
How to read and execute commands without reloading the environment?
Using the source command, source ~/.bashrc |
What is a DocBlock?
A DocBlock is a piece of documentation in your source code that informs you what the function of a certain class, method or other Structural Element is.
Example:
<?php
/**
* This is a DocBlock.
*/
function associatedFunction()
{
}
Javascript
Closure
I am simplifying the JS closure again to get a better understanding of the concept.
A closure is when a function “remembers” its surrounding environment even after the function has finished executing. It’s like a function bundled together with the variables from its parent scope.
function outerFunction() {
let outerVariable = "I am from outerFunction";
function innerFunction() {
console.log(outerVariable);
}
return innerFunction;
}
// Create a closure by assigning the innerFunction to a variable
let closure = outerFunction();
// Call the closure, and it still has access to outerVariable
closure(); // Outputs: "I am from outerFunction"
In simple terms, a closure allows a function to access variables from its outer (enclosing) scope even after that scope has completed its execution.
“Good Work. Good People.”
Leave a Reply