Ubuntu Process 1
Ubuntu Process 1
A process in Ubuntu (or any Linux-based system) is an instance of a running program. When you execute
a command, open an application, or run a script, the Linux kernel creates a process for that task. A process
consists of the program's executable code, data, and resources it uses (like CPU, memory, file descriptors,
and network connections).
Ubuntu, like other Linux distributions, is a multitasking and multi-user operating system, meaning that
multiple processes can run concurrently and be managed simultaneously.
TYPES OF PROCESSES
In Ubuntu, processes can be categorized into different types based on how they are created and
executed:
1. Foreground Processes
• A foreground process is one that runs directly under user control in the terminal.
• It takes input from the keyboard and sends output to the terminal.
• You can start a foreground process by typing a command and pressing Enter.
• Example:
gedit
2. Background Processes
• A background process is one that runs without user interaction.
• It does not take input from the terminal but can produce output.
• You can run a process in the background by adding & at the end of the command.
• Example:
gedit &
• To bring a background process to the foreground:
fg
start /b myscript.bat
Stop-Service MyService
• This method is useful for running background services like web servers or database
services.
Conclusion
There are multiple ways to run a background process in Windows:
Which method you choose depends on whether you want a temporary background process (like
a minimized app) or a long-running background task (like a service).
3. Daemon Processes
• A daemon is a background process that starts at system boot and runs continuously to
handle system-level tasks.
• These are service processes that don't have a terminal associated with them.
• Examples of daemons:
Windows does not use the term daemon like Linux or Unix systems, but it has an equivalent called
Windows Services. These services run in the background without user interaction and start
automatically when the system boots.
PROCESS STATES
• Example output
or
ps aux
• -e (or -A) → Shows all processes.
• aux:
o a → Shows processes of all users.
o u → Displays user information.
o x → Includes processes not attached to a terminal (like daemons).
• Example Output:
Column Breakdown
Column Meaning
USER The user who owns the process. root means the process runs with
administrator privileges.
PID Process ID (unique identifier for each running process).
%CPU Percentage of CPU time used by the process since the last update.
%MEM Percentage of physical RAM used by the process.
VSZ Virtual memory size in kilobytes (KB), including code, data, heap,
and shared libraries.
RSS Resident Set Size (actual memory in RAM), in kilobytes (KB).
TTY Terminal associated with the process (pts/1 for a user session, ? for
system processes with no terminal).
STAT Process status
START Time or date the process started.
TIME Total CPU time consumed by the process.
COMMAND The command that started the process, including arguments.
Column Meaning
R Running (actively using CPU).
S Sleeping (waiting for an event, like user input or disk read).
D Uninterruptible sleep (usually I/O wait, cannot be killed).
Z Zombie (process finished but still in process table, waiting for
parent cleanup).
T Stopped (suspended, often from Ctrl+Z).
Z Dead (process terminated but still listed).
Modifiers:
Example Analysis
a. System Process (/sbin/init)
o Owned by root
o PID = 1, the first process (init/systemd)
o Low CPU and memory usage
o TTY = ?, meaning it’s a background system process
o STAT = Ss, meaning it is a sleeping session leader
b. User Shell (bash)
• User = user1
• PID = 1234, unique process ID
• TTY = pts/1, meaning it's running in a terminal session
• STAT = Ss, meaning it's sleeping but still interactive
ps -p 1234