Ramdeobaba University, Nagpur
School of Computer Science and Engineering
Session: 2024-2025
Fundamentals of Linux OS I Semester
PRACTICAL NO. 5
Aim: To understand the management of background and foreground processes in
Linux, and to explore the /proc directory to gain insights into process information in
the operating system.
Tasks:
a. Experiment with background and foreground processes (&, fg, bg).
b. Explore the /proc directory to understand process information.
Theory:
Types of Processes in Linux
In Linux, processes are of 2 types, let us go through each of them:
1. Foreground processes
Foreground processes are also called as interactive processes. These processes are launched
and controlled through the command line in a terminal session. There has to be a user in the
system to start such foreground processes as they cannot start automatically by themselves.
2.Background processes
Background processes are also called as non-interactive processes. These processes are the
complete opposite of the Foreground process. They don’t need any user input and are not
connected to the terminal. One such example of background processes is daemons.
What are Daemons?
Since we touched on the topic of Daemons, might as well learn what they are. Daemons are a
special type of background process that starts when the system boots and keeps running
forever, till eternity — they never die. Daemons can be controlled by a user through the init
process.
Key Concepts:
1. Background and Foreground Processes:
o Running in Background: Allows you to continue using the terminal while a
process runs in the background.
o Foreground/Background Management: Commands like fg, bg, and Ctrl+Z
help manage processes between the background and foreground.
2. Exploring Process Information:
o /proc Directory: Contains detailed information about system processes and
their resource usage.
3. Managing System Services:
o systemctl Command: Used to manage system services, including starting,
stopping, and configuring services to start on boot.
Different commands
1. Experimenting with Background and Foreground Processes
Commands:
1. Run a process in the background:
& - Runs the specified command in the background.
2. Bring a background process to the foreground:
fg %job_number - Brings the specified job from the background to the foreground.
3. Send a foreground process to the background:
o Suspend the process: Ctrl+Z
o Resume in the background: bg %job_number - Suspends a foreground
process and resumes it in the background.
__________________________________________________________________________
Experiment (PART-A):
1. Start a long-running process in the background using command &.
2. Use the jobs command to list background jobs.
3. Bring the process to the foreground using fg %job_number.
4. Suspend the process using Ctrl+Z and then resume it in the background using bg
%job_number.
___________________________________________________________________________
2. Exploring the /proc Directory
Commands:
1. List process directories:
ls /proc - Lists the contents of the /proc directory, where each subdirectory is named
after a PID.
2. View process information:
cat /proc/PID/status - Displays detailed status information about the process with the
specified PID.
Experiment (PART-B):
1. Find the PID of a process using ps aux or top.
2. Navigate to /proc/PID and explore files such as cmdline, status, and fd.
3. Use cat /proc/PID/status to examine the process’s status information.
___________________________________________________________________________
3. Managing System Services with systemctl
Commands:
1. Check the status of a service:
systemctl status service_name - Displays the current status of the specified service.
2. Start a service:
sudo systemctl start service_name - Starts the specified service.
3. Stop a service:
sudo systemctl stop service_name - Stops the specified service.
4. Restart a service:
sudo systemctl restart service_name - Restarts the specified service.
5. Enable a service at boot:
sudo systemctl enable service_name - Configures the service to start automatically at
boot.
6. Disable a service:
sudo systemctl disable service_name - Prevents the service from starting
automatically at boot.
___________________________________________________________________________
Experiment (PART-C):
1. Check the status of a common service like nginx or apache2.
2. Start and stop the service using systemctl.
3. Enable or disable the service to test its boot-time configuration.
__________________________________________________________________________