Linux Processes

From rbachwiki
Jump to navigation Jump to search

Viewing Processes

PS Commands
Kill Signals
Kill Signals
ps # view process that are running in the current shell
ps -f # Displays PID

Display an entire list of processes across all terminals and including daemons

ps -ef

Some options to the ps command are not prefixed by a dash character; these are referred to as Berkeley-style options. The two most common of these are the a option, which lists all processes across terminals, and the x option, which lists processes that do not run on a terminal

ps ax
ps -l

View Zombie Process

ps -el | grep Z

Top Command

press h key while in the top command to see a list of options

top

Killing Processes

Kill signal have many options; Kill followed by signal number then process ID

kill -1 5555

The KILLALL command uses the process name instad of the pid

killall -3 sample

Running Processes in the background

Add the & after the command to run in the background

samplescrpit &

Will run the script in the background and return the shell immediately back to the user

jobs # view the background job id

To kill a job id with the id number

kill -2 %1 # the %1 is the jobid number

After a background has been started you can move it to the foreground

fg %1 # the %1 is the jobid

You can pause a foreground process by CTRL Z

Nice command

You cannot change the PRI directly, but you can influence it indirectly by assigning a certain nice value to a process.
A negative nice value increases the likelihood that the process will receive more time slices, whereas a positive nice value does the opposite.

nice -n -20 ps -l # Starts the ps command with a nice value of -20

After a process has been started, you can change its priority by using the renice command and specifying the change to the nice value, as well as the PID of the processes to change.
To lower priority of the first two sample processes by changing the nice value from 0 to +15 and view the new values, you can execute the following commands:

renice +15 123 345