Changes

Jump to: navigation, search

Tutorial8: Links / Process Management

8 bytes added, 15:03, 25 February 2021
INVESTIGATION 2: MANAGING PROCESSES
# Make certain that you are logged into your Matrix account.<br><br>
# Issue a Linux command to confirm that you are located in your '''home''' directory.<br><br>The '''sleep''' command '''pauses for a specified number of seconds''' before returning to the shell prompt.<br>In the tutorial, we will be using this command to '''simulate "long-running" processes''' for us to manage.<br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">sleep 700</span><br><br>Notice that this process will run for '''700 seconds''', and is forcing the user to wait until this process finishes.<br>A process that is '''running in the terminal''' is referred to as a '''foreground processprocesses'''.<br><br>The Unix/Linux system is designed to allow users to send '''preemptive signals''' to manage those processes.<br><br>
# Press the following '''key combination''' to '''terminate''' the command running on the terminal: <span style="color:blue;font-family:courier;font-weight:bold">ctrl-c</span><br><br>You should notice that the process that was running in the foreground has been '''interrupted''' (i.e. terminated).<br>'''NOTE:''' The '''ctrl-c''' key combination sends '''SIGINT''' ('''Signal Interrupt''' - which is signal '''#2''') signal to<br>''terminate'' a process that is running on the terminal (i.e. the '''foreground''').<br><br>
# Reissue the Linux command: <span style="color:blue;font-family:courier;font-weight:bold">sleep 700</span><br><br>
# Issue the '''jobs''' command. What do you notice?<br>You should notice all commands are run in a group as just one process.<br><br>
# Issue the following Linux command to terminate the first job running in the '''background''':<br><span style="color:blue;font-family:courier;font-weight:bold">kill %1</span><br><br>NOTE: If issuing the kill command does not work, then you would need to send a STRONGER signal<br>to "'''kill'''" (not "''SIGTERM'' - which is signal ''#15''") the process. The '''SIGKILL''' signal (signal '''#9''')<br>would be required to do this by issuing the '''kill''' command with the option: '''-9'''.<br><br>
# Issue the '''jobs''' command and make certain there are no processes that are running in the '''background'''.<br><br>You can also manipulate processes by their '''PID''' ('''process ID'''). Let's terminate our Matrix Bash shell process<br>by using the '''kill''' command using that processprocesses' '''PID'''.<br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">ps</span><br><br>
#Note in the '''ps''' command output the PID of the process called '''bash'''.<br><br>You will be using that PID when issuing the <u>next</u> Linux command.<br><br>
# Issue the following Linux command (using the bash processprocesses' PID number instead of "PID"):<br><span style="color:blue;font-family:courier;font-weight:bold">kill PID</span><br><br>What did you notice? '''It did not work''' since you need to send a STRONGER signal (eg. '''SIGKILL''', not ''SIGTERM'').<br><br># Issue the following Linux command (using the bash processprocesses' PID number instead of "PID"):<br><span style="color:blue;font-family:courier;font-weight:bold">kill -9 PID</span><br><br>What did you notice? You should have been '''logged off''' of your Matrix session!<br><br>
:In the next investigation, you will learn how to '''create aliases''' and '''view command history''' on your Matrix server.<br><br>
13,420
edits

Navigation menu