{"id":79075,"date":"2026-11-17T01:52:54","date_gmt":"2026-11-17T01:52:54","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=79075"},"modified":"2026-11-17T01:52:54","modified_gmt":"2026-11-17T01:52:54","slug":"linux-basics-07-processes","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=79075","title":{"rendered":"Linux Basics 07 \u2014 Processes, Jobs, and Signals"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1990\">Linux Basics category<\/a> \u00b7 Lesson 7 of 8<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>AI disclosure<\/strong> \u2014 AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Learning goal<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Identify a process you own, inspect its state, and stop it gracefully.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Concepts and setup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A program is code. A process is a running instance with a process ID (PID). A shell job is the shell&#8217;s record of one or more processes started together. top refreshes a system view, while ps shows a snapshot. Use a specific PID rather than a broad name match when acting on a process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SIGTERM requests termination and can be caught by a process. SIGKILL is not catchable, so it prevents normal cleanup. The older source lists both. This lab starts and terminates only its own sleep process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Start a job and verify termination<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sleep 120 &amp;\npid=$!\njobs -l\nps -p &quot;$pid&quot; -o pid,ppid,stat,comm\nkill -TERM &quot;$pid&quot;\nwait &quot;$pid&quot;\nstatus=$?\nprintf 'wait status: %s\\n' &quot;$status&quot;\nps -p &quot;$pid&quot; -o pid= || printf 'process no longer listed\\n'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[1]+  3184 Running                 sleep 120 &amp;\n    PID    PPID STAT COMMAND\n   3184    3142 S    sleep\nwait status: 143\nprocess no longer listed<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Run interactively in Bash. PID and job notifications vary. The common Bash status 143 is 128 plus signal number 15. wait handles the shell&#8217;s own child.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Inspect the shell&#8217;s process context<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>ps -p &quot;$$&quot; -o pid,ppid,stat,comm\nuptime<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    PID    PPID STAT COMMAND\n   3142    3072 Ss   bash\n 14:09:38 up  2:12,  1 user,  load average: 0.07, 0.04, 0.01<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use the same shell when comparing its PID to the child\u2019s PPID. Load average is not a simple percentage of CPU use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Questions only<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>What does $! contain after sleep 120 &amp;?<\/li>\n\n\n<li>Why try SIGTERM before SIGKILL?<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Name two fields from ps useful for checking the target before a signal.<\/li>\n\n\n<li>What happens if you use wait for a PID that is not a child of this shell?<\/li>\n\n\n<li>Explain why jobs in a new terminal does not list the old terminal\u2019s sleep job.<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Questions and answers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check answers<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>What does $! contain after sleep 120 &amp;?<\/strong><br><strong>Answer<\/strong> \u2014 It contains the PID of the most recent background job&#8217;s last process, which is sleep here.<\/li>\n\n\n<li><strong>Why try SIGTERM before SIGKILL?<\/strong><br><strong>Answer<\/strong> \u2014 The process can handle SIGTERM and clean up. It cannot catch SIGKILL.<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment answer key<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>Name two fields from ps useful for checking the target before a signal.<\/strong><br><strong>Answer<\/strong> \u2014 PID and command name are a start. Verify owner and parent as needed.<\/li>\n\n\n<li><strong>What happens if you use wait for a PID that is not a child of this shell?<\/strong><br><strong>Answer<\/strong> \u2014 Bash normally reports that it is not a child and returns 127.<\/li>\n\n\n<li><strong>Explain why jobs in a new terminal does not list the old terminal\u2019s sleep job.<\/strong><br><strong>Answer<\/strong> \u2014 The job table belongs to the shell that created the job.<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Source articles on this site<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=76465\">Linux ps command<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=76475\">Terminating Process in Linux<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=76473\">Process Control in Linux<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=76460\">Monitor Process in Linux<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=9598\">\u0987\u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u09aa\u09cd\u09b0\u09b8\u09c7\u09b8 \u09ae\u09cd\u09af\u09be\u09a8\u09c7\u099c\u09ae\u09c7\u09a8\u09cd\u099f (Unix \u2013 Processes Management)<\/a><\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Continue the course<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Previous lesson 06 \u2014 File Permissions and umask. Next lesson 08 \u2014 Archives, Compression, and a Restore Test.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1990\">Linux Basics category<\/a> \u00b7 Lesson 7 of 8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Identify a process you own, inspect its state, and stop it gracefully.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1990],"tags":[],"class_list":["post-79075","post","type-post","status-publish","format-standard","hentry","category-linux-basics","item-wrap"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":79102,"url":"http:\/\/bangla.sitestree.com\/?p=79102","url_meta":{"origin":79075,"position":0},"title":"Linux Administration Course \u2014 Start Here and Lesson Index","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"A 33-lesson Linux course from shell fundamentals to server administration, performance, and a recovery capstone.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79069,"url":"http:\/\/bangla.sitestree.com\/?p=79069","url_meta":{"origin":79075,"position":1},"title":"Linux Basics 01 \u2014 Linux, the Shell, and Your First Lab","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Tell the kernel, distribution, terminal, and shell apart, then identify the system you are actually using.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79076,"url":"http:\/\/bangla.sitestree.com\/?p=79076","url_meta":{"origin":79075,"position":2},"title":"Linux Basics 08 \u2014 Archives, Compression, and a Restore Test","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Create and inspect an archive, then prove that you can recover a file from it.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79071,"url":"http:\/\/bangla.sitestree.com\/?p=79071","url_meta":{"origin":79075,"position":3},"title":"Linux Basics 03 \u2014 Editing Text and Reading Files","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Edit a text file in a terminal and verify the exact lines you saved.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79085,"url":"http:\/\/bangla.sitestree.com\/?p=79085","url_meta":{"origin":79075,"position":4},"title":"Linux Intermediate 09 \u2014 Block Devices, Filesystems, and Mounts","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Distinguish a block device from a filesystem and a mount point, and inspect each layer without changing it.","rel":"","context":"In &quot;Linux Intermediate&quot;","block_context":{"text":"Linux Intermediate","link":"http:\/\/bangla.sitestree.com\/?cat=1991"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79099,"url":"http:\/\/bangla.sitestree.com\/?p=79099","url_meta":{"origin":79075,"position":5},"title":"Linux Advanced 2 05 \u2014 Kernel Modules and Resource Limits","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Read kernel module information and identify the current process\u2019s resource-control group without changing the kernel.","rel":"","context":"In &quot;Linux Advanced 2&quot;","block_context":{"text":"Linux Advanced 2","link":"http:\/\/bangla.sitestree.com\/?cat=1993"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79075"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79075\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79075"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}