Open jbeadling opened 11 months ago
The commands bg and the shortcut Ctrl-z put processes in the background. Normally when you run a process on your terminal it will run it and not give your prompt back. Sometimes you want to run a process and do other things, that's where the Ctrl-z and bg command come in. These tools allow you to put processes in the background so you can have the terminal to do other stuff as well.
The jobs command will allow you to view all jobs that are running, stopped, or running in the background.
The fg command will bring processes in the background back to the terminal.
The kill command terminates a process manually. There are several flags you can use with it, kill -9 is the most famous example as this forcefully kills the process no exceptions. You will need the PID to use this command.
Below I use the sleep command but I put it in the background by using the & at the end of the command
Below we start a process called sleep, I interupt the process with Ctrl-Z, I put it in the background with the bg command. I list it with the jobs command, I then bring it into the foreground with fg. I then use the kill command with the process ID.
Summary
Master the essential job control commands like
bg,
fg,
jobs,
kill,
andCtrl-Z
to manage running processes in your shell. These commands are essential for multitasking and system administration tasks.Description
Objective: Acquire the skills to manage and control background and foreground processes using basic job control commands.
Scope:
bg,
fg,
jobs,
andkill
Learning Tasks
Introduction to Job Control:
Understanding Job Control Commands:
bg
,fg
,jobs,
kill,
andCtrl-Z,
including their syntax and usage.Practical Use-cases and Examples:
Hands-on Practice:
Ctrl-Z
to pause a running process and put it in the background.jobs
command.fg
command.bg
command.kill
command.Troubleshooting:
Learning Goals
Priority