You are on page 1of 4

Process Management Prac

To track the running processes on your machine you can use the top
command.
To displays the currently-running processes.
ps command
To display all the currently running processes
ps -A
List all the signals use
kill -L
Kill any particular process
Kill -9 pid
To assign the nice value to any particular process
nice -n [value] [process name]

Niceness value can range from -20 to 19. 0 is the default value.

Execute the top command to check


To change nice value of a process that is already running use:

renice [value] -p 'PID'

Execute the top command to check


Example of foreground process.

sleep 5
Stop a foreground process in between its execution

Sleep 100

Press cntrl Z

To get the list of jobs that are either running or stopped.


jobs
To run all the pending and force stopped jobs in the background.
Bg
To get details of a process running in background.

ps -ef | grep sleep

To run all the pending and force stopped jobs in the foreground.

fg

To run some processes in the background directly.

sleep 100&
To run processes with priority.

nice -n 5 sleep 100


You can also check the process status of a single process, use the
syntax –

ps PID

Command to check free disk space(Hard Disk) on all the file systems.
df
If you want in human readable format

df -h

This command shows the free and used memory (RAM) on the Linux
system.

free

C program:
#include <stdio.h>
int main()
{
printf("Learning C");
}
Read user input
#include <stdio.h>
int main()
{
char name[100];
int age;
printf("Enter your name: ");
scanf("%s",name);
printf("Enter your age: ");
scanf("%d",&age);
printf("Hello, %s,You are %d years old", name, age);
}
Find even numbers from a list using while loop
#include <stdio.h>
int main(){
int numbers[10] = { 21, 78, 62, 90, 55, 10, 85, 45 };
int i = 0;
printf("The even numbers from the list are:\n");
while(i < 10) {
if((numbers[i] % 2) == 0)
printf("%d\n", numbers[i]);
i++;
}
}
Find out the area of a rectangle using the function

#include <stdio.h>
int area(int h, int w);
int area(int h, int w)
{
int area = h * w;
return area;
}

int main()
{
int height, width;
printf("Enter the height of the rectangle:");
scanf("%d", &height);
printf("Enter the width of the rectangle:");
scanf("%d", &width);

printf("The area of the rectangle = %d\n",area(height,width));


}

You might also like