|
Chapter 6
For example, you could terminate a hypothetical
rogueprocess
like this:
kali >killall -9 rogueprocessBog'liq linuxbasicsforhackers68
Chapter 6
For example, you could terminate a hypothetical
rogueprocess
like this:
kali >killall -9 rogueprocess
Finally, you can also terminate a process in the
top
command. Simply
press the K key and then enter the PID of the offending process.
Running Processes in the Background
In Linux, whether you’re working from the command line or the GUI,
you’re working within a shell. All commands that run are executed from
within that shell, even if they run from the graphical interface. When you
execute a command, the shell waits until the command is completed before
offering another command prompt.
At times, you may want a process to run in the background, rather than
having to wait for it to complete in that terminal. For instance, say we want
to work on a script in a text editor and so have called our text editor (leaf
pad) by entering the following:
kali >leafpad newscript
In this case, the bash shell will open the leafpad text editor to create
newscript. While we work in the text editor, the terminal is occupied with
running the text editor. If we return to the terminal, we should see that it
is running our text editor and that we have no new prompt to allow us to
enter more commands.
We could, of course, open another terminal to run more commands,
but a better option to save resources and screen real estate is to start the
text editor running in the background. Running a process in the back
ground simply means that it will continue to run without needing the ter
minal. In this way, the terminal is freed up for other duties.
To start the text editor in the background, just append an ampersand
(
&
) to the end of the command, like so:
kali >leafpad newscript &
Now, when the text editor opens, the terminal returns a new command
prompt so we can enter other commands on our system while also editing
our newscript. This is effective for any process that may run for a significant
length of time when you want use the terminal. As a hacker, you’ll find this
useful for running multiple terminals with multiple tasks, to save resources
and screen space.
You can also move a process to the background using the
bg
command
followed by the PID of the process. If you don’t know the PID, you can use
the
ps
command to find it.
|
| |