CIT054 Index > Assignment: Processes

Assignment: Processes

You will do this assignment on your local Linux system; it is a “discovery exercise.“

  1. Download process054.pl, a Perl script which goes into a CPU-intensive loop for 15 seconds and then sleeps for 15 seconds. It keeps doing this until you stop the program. Put this program in your home directory.

  2. Open two terminal windows. You will be running processes in the first window and doing your testing in the other window. Make sure you are in the home directory in both windows!

  3. In the first window, type script process1.script

  4. In the first window, type perl process054.pl to record that window’s results.

  5. In the second window, type script processes.script to record your results.

  6. In the second window, find the process ID of the program you started in the first window by typing this command:

    ps -eo pid,cmd,user,group,ruser,rgroup | grep perl

    The columns are the process ID, command being run, effective user ID, effective group ID, true user ID, and true group ID. You may not see the entire command depending on the size of your terminal window.

  7. Kill the process with signal QUIT

  8. Restart the process in the first window (type the perl process054.pl command again).

  9. From the second window, find the process ID again and this time kill the process with signal HUP

  10. Restart the process in the first window.

  11. From the second window, find the process ID and kill the process with signal KILL

  12. In the first window, become the user root. If you are using Ubuntu, you have to do the following command, as the root login has no password:

    sudo su -

    For systems that have a true root user, just say

    su -

    Then change the permissions of process054.pl such that it is read-write-execute for the owner, read-execute for everyone else, and the setuid bit is set. Do an ls -l to see what that looks like.

  13. Still as the superuser, run process054.pl again.

  14. In the second window, find the process ID again, and notice the different effective and real user IDs.

  15. From the second window, try killing the process. Can you do it?

  16. If killing the program didn’t work, then, in the first window, kill the program by pressing CTRL-C.

  17. Now set the permissions of process054.pl to read-write-execute for owner, read-execute for everyone else, and set the group ID bit.

  18. Start the program again.

  19. From the second window, find the process and look at the user and group IDs.

  20. In the second window, type exit to save the processes.script file.

  21. In the second window, type top to see the processes running dynamically. Watch for about a minute. Fun, isn’t it?

  22. Stop top by pressing the q key to quit.

  23. Press CTRL-C in the first window to stop the Perl process.

  24. Remember to type exit in the “superuser window” to stop being root.

  25. Type exit in both the windows to finish the scripts.

When You Finish

Change the name of the process1.script file to the form lastname_firstname_process1.script and process2.script to the form lastname_firstname_process2.script and email them to the instructor.