Moving a Process to the Foreground




Download 7,3 Mb.
Pdf ko'rish
bet76/115
Sana27.11.2023
Hajmi7,3 Mb.
#106243
1   ...   72   73   74   75   76   77   78   79   ...   115
Bog'liq
linuxbasicsforhackers

69
Moving a Process to the Foreground
If you want to move a process running in the background to the fore­
ground, you can use the 
fg
(foreground) command. The 
fg
command 
requires the PID of the process you want to return to the foreground, as 
shown next.
kali >fg 1234
If you don’t know the PID, you can use the 
ps
command to find it.
Scheduling Processes
Both Linux system administrators and hackers often need to schedule 
processes to run at a particular time of day. A system administrator might 
want to schedule a system backup to run every Saturday night at 2 
am
, for 
example. A hacker might want to set a script to run to perform reconnais­
sance on a regular basis, finding open ports or vulnerabilities. In Linux, 
you can accomplish this in at least two ways: with 
at
and 
crond
.
The 
at
command is used to set up the daemon—a background process—
atd
, which is useful for scheduling a job to run once at some point in the 
future. The 
crond
daemon is more suited for scheduling tasks to occur every 
day, week, or month, and we’ll cover this in detail in Chapter 16.
We use the 
at
daemon to schedule the execution of a command or set 
of commands in the future. The syntax is simply the 
at
command followed 
by the time to execute the process. The time argument can be provided in 
various formats. Table 6­2 contains the most common 
at
time formats.
Table 6-2: 
Time Formats Accepted by the 
at
Command
Time format
Meaning
at 7:20pm
Scheduled to run at 7:20 
pm
on the current day
at 7:20pm June 25
Scheduled to run at 7:20 
pm
on June 25
at noon
Scheduled to run at noon on the current day
at noon June 25
Scheduled to run at noon on June 25
at tomorrow
Scheduled to run tomorrow
at now + 20 minutes
Scheduled to run in 20 minutes from the current time
at now + 10 hours
Scheduled to run in 10 hours from the current time
at now + 5 days
Scheduled to run in five days from the current date
at now + 3 weeks
Scheduled to run in three weeks from the current date
at 7:20pm 06/25/2019
Scheduled to run at 7:20 
pm
on June 25, 2019


70
Chapter 6
When you enter the 
at
daemon with the specified time, 
at
goes into 
interactive mode and you are greeted with an 
at>
prompt. Here is where 
you enter the command you want executed at the specified time:
kali >at 7:20am
at >/root/myscanningscript
This code snippet will schedule myscanningscript to execute today at 
7:20 
am
. When you want to stop entering commands, hit 
ctrl
­D.
Summary
Managing processes in Linux is a key skill for every Linux user and hacker. 
You must be able to view, find, kill, prioritize, and schedule processes to 
manage your Linux instance optimally. A hacker often will need to find 
processes on the target they want to kill, such as the antivirus software or a 
firewall. They will also need to manage multiple processes in an attack and 
prioritize them. 

Download 7,3 Mb.
1   ...   72   73   74   75   76   77   78   79   ...   115




Download 7,3 Mb.
Pdf ko'rish