|
In this lab, we will explore how we are able to manipulate processes.
When giving examples of the manipulation of processes, you should include the screenshots of the Linux commands and the outcomes.
See the ‘Getting Started with Lab 14’ video on AULA to give you additional information on completing this lab.
If you have any additional questions on this lab or any other labs please do not hesitate to ask your tutor and/or email me on [email protected].
Basic Task – Process Manipulation |
|||
Basic Task a) |
|||
Investigate the Linux commands nohup, disown and screen. How are they used? What are their similarities and what are their differences? |
|||
Basic Task a) Solution |
|||
The nohup command allows a user to execute processes even when logging out of the terminal. Usually this would result in a hang up signal being sent to terminate the process but nohup (no hang up) prevents this from happening (Yesmin, 2018). The disown command is a built in Linux command that is used to remove jobs from the job table. It can also be used to keep long complex jobs running in the background even after a user has logged out of a server, a similarity it shares with the nohup command (Hitesh, 2019). The screen command allows for users to create multiple shell sessions from one single SSH session. Every screen session created also creates a new process which can be detached and then reattached at a later time. These statements outline the differences in each command, but the similarity is that each command allows processes to continue to run in the background even if the user is not directly interacting with it (McKay, 2020). Hitesh, J. (2019). disown – Learn this Command [ Syntax, Parameters, Examples]. [online] www.webservertalk.com. Available at: https://www.webservertalk.com/disown [Accessed 18 Apr. 2021]. McKay, D. (2020). How to Use Linux’s screen Command. [online] How-To Geek. Available at: https://www.howtogeek.com/662422/how-to-use-linuxs-screencommand/ [Accessed 18 Apr. 2021]. Yesmin, F. (2018). Nohup Command in Linux – Linux Hint. [online] https://linuxhint.com. Available at: https://linuxhint.com/nohup_command_linux/ [Accessed 18 Apr. 2021]. |
|||
Basic Task b) |
|||
Describe what the watch command can be used for and give an example using the watch command. You don’t have to show this running, just describe the purpose and the commands you would type. |
|||
Basic Task b) Solution |
|||
The watch command can be used by a user to execute programs full screen periodically with the user able to specify interval times. By default, watch will execute a given program repeatedly with an interval of two seconds until the process is interrupted (Linuxise, 2019). An example command that can be used to execute the date command repeatedly in 10 second intervals is: $ watch -n 10 date Linuxise (2019). Linux Watch Command. [online] linuxize.com. Available at: https://linuxize.com/post/linux-watch-command/ |
Advanced Task – Process Manipulation |
||
Provide different Linux command-line examples to Start, Suspend and Terminate processes, and how to run processes in the Background and the You should offer at least 3 different Linux command-line examples to Start a process, 3 different examples of how to suspend a process, 1 example on how to run a process in the background and 1 example on how to run a process in the foreground, 4 different examples on how to terminate a process. |
||
Advance Task Solution |
||
Starting a process: 1. Execute the program name from command-line: EXAMPLE: $ ls 2. Create process by executing a bash script: EXAMPLE: $ ./menu.sh 3. Create process by executing multiple commands: EXAMPLE: $ ls ; hostname Suspending a process: 1. Suspend process using the kill command: EXAMPLE: $ kill -STOP 1234 2. Whilst in a shell press the Ctrl-Z keys 3. Use pkill with -SIGTSTP to send suspend signal process: EXAMPLE: $ pkill -STOP sleep Running a Process in the Background: 1. Add an ampersand at the end of the command: EXAMPLE: $ sleep 30 & Running a Process in the Foreground: Bring a background process to the foreground with the fg command: EXAMPLE: $ fg How to Terminate a Process: 1. Terminate a process with the kill command: kill <PID> EXAMPLE: $ kill 1234 2. Terminate all processes affiliated to a certain process name: killall <process name> EXAMPLE: $ killall top 3. Terminate all processes affiliated to a certain process name using pkill: pkill <process name> EXAMPLE: $ pkill sleep 4. When a process is running the shell Ctrl-C can be pressed to terminate the process. |
Lab Evidence |
|||
Description and comparison of the three commands: nohup, disown and screen. Description of the use of the watch command. Examples of Linux command-line manipulation of processes. Show what commands are used and their impact. |