0% found this document useful (0 votes)
9 views3 pages

Processes in Linux Notes

The document provides an overview of managing processes in Linux, including how to start and stop processes, the initialization process, and the mechanisms of process creation. It also covers job control, scheduling tasks with at, batch, and cron, and measuring execution time with the time command. Understanding these concepts is essential for effective system administration in Linux.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Processes in Linux Notes

The document provides an overview of managing processes in Linux, including how to start and stop processes, the initialization process, and the mechanisms of process creation. It also covers job control, scheduling tasks with at, batch, and cron, and measuring execution time with the time command. Understanding these concepts is essential for effective system administration in Linux.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

8/2/25, 2:04 PM BLACKBOXAI

BLACKBOXAI
Generated on: 8/2/2025 2:04:28 PM

User
Processes in Linux: Starting and Stopping Processes, Initialization Processes, Mechanism of
process creation, and Job control in Linux using at, batch, cron & time notes

BLACKBOXAI
In Linux, processes are fundamental to the operating system's functionality. Understanding
how to start, stop, and manage processes is crucial for effective system administration. Below
is an overview of key concepts related to processes in Linux, including initialization, process
creation, and job control.

1. Starting and Stopping Processes

Starting Processes: You can start a process in Linux by executing a command in the
terminal. For example, to start a text editor like nano , you would type:

bash
nano filename.txt

Stopping Processes: To stop a running process, you can use the kill command followed
by the process ID (PID). For example:

bash
kill 1234

To forcefully stop a process, you can use:

bash
kill -9 1234

2. Initialization Processes

Init System: The initialization process is the first process started by the Linux kernel.
Traditionally, this was the init process (PID 1). Modern Linux distributions often use
systemd or upstart as the init system.

Generated by BlackBox AI
https://www.blackbox.ai/chat/nHLUmjl 1/3
8/2/25, 2:04 PM BLACKBOXAI

Runlevels and Targets: In traditional init , runlevels define the state of the machine (e.g.,
single-user mode, multi-user mode). In systemd , targets serve a similar purpose, allowing
for more flexible service management.

3. Mechanism of Process Creation

Forking: The primary mechanism for creating a new process in Linux is the fork() system
call. This creates a child process that is a duplicate of the parent process.
Exec: After forking, the child process can replace its memory space with a new program
using the exec() family of functions. This is how a new program is executed in the context
of a new process.
Example: A simple example in C to create a new process:

c
pid_t pid = fork();
if (pid == 0) {
// Child process
execl("/bin/ls", "ls", NULL);
} else {
// Parent process
wait(NULL); // Wait for child to finish
}

4. Job Control in Linux

Job control allows users to manage multiple processes in a shell environment. Key commands
include:

Background and Foreground Jobs:

- To run a process in the background, append & to the command:

bash
sleep 100 &

- To bring a background job to the foreground, use the fg command:

bash
fg %1 # Brings job 1 to the foreground

Stopping and Resuming Jobs:

Generated by BlackBox AI
https://www.blackbox.ai/chat/nHLUmjl 2/3
8/2/25, 2:04 PM BLACKBOXAI

- You can stop a running job with Ctrl + Z , which suspends the job and puts it in the
background. - To resume a stopped job in the background, use:

bash
bg %1

5. Scheduling Jobs with at , batch , and cron

atCommand: The at command is used to schedule a one-time task to be executed at a


specific time. For example:

bash
echo "backup.sh" | at 2:00 PM

batch Command: The batch command schedules jobs to run when system load levels
permit. It is similar to at , but it runs jobs when the system is not busy.
cron Daemon: The cron daemon is used for scheduling recurring tasks. Users can create
a crontab file to specify commands to run at regular intervals. For example, to run a script
every day at 5 AM:

bash
0 5 /path/to/script.sh

6. Measuring Time with time

The time command is used to measure the duration of execution of a command. For
example:

bash
time ls -l

This will output the real time, user CPU time, and system CPU time taken to execute the ls -
l command.

Conclusion

Understanding processes in Linux, including how to start, stop, and manage them, is essential
for effective system administration. The mechanisms of process creation, job control, and
scheduling tasks with at , batch , and cron provide powerful tools for managing system
resources and automating tasks.

Generated by BlackBox AI
https://www.blackbox.ai/chat/nHLUmjl 3/3

You might also like