Hak5 -- Cyber Security Education, Inspiration, News & Community since 2005: ____________________________________________ This week we are controlling the processes that we learned about last week. Last week we discussed processes- what they are and how to view them. Now, let's control those. Let's open the program called gedit- a text editing program. You'll notice your shell prompt will not return until the program is closed. Press CTRL-C to interrupt the program (or terminate). This works for most command-line programs but not all. Now run gedit again with an & at the end. This says we started job number 1, with a PID of 3853. Running ps shows the proccess as well. If you type jobs, this will also show you that gedit is running. (one job, number 1, command gedit &). To return the process to the foreground from the terminal, type jobs to find the number, then fg %1. To terminate again, press CTRL-C. Type CTRL-Z to completely stop a process. So if gedit is running, then type CTRL-Z to stop or pause it. You can restore the program with fg, or move it to the background with bg (bg %1). The number is optional if you only have one job running. Opening a graphical program may be essential if opening it in the GUI doesn't work or it's not listed in the window manager's menus. Do you want to completely kill the process? To do so, first type gedit &, get the PID, then type kill 3651. This will terminate the process. kill sends a signal to the process to terminate. When the terminal sees these keystrokes, it can send a signal to the process to do something. kill can have specified signals attached to it such as HUP for hang up (old school for computers that were online with phone lines), INT for interrupt (same as CTRL-C), TERM for terminate, STOP for stopping the process without terminating, CONT to continue after stopping, just to name a few. You can type kill -1 1234 to hang up, or type kill -INT 1234 to interrupt it. Use kill -l for a complete listing of signals you can send. Last but not least, you can send a signal to multiple processes. Type gedit & a couple of times for several instances of the program, then type killall gedit to kill all of the gedit instances. You must have user priveledges to send signals to processes that don't belong to you. To give you an idea of some other common processes, take a look at these commands: pstree (parent-child relationships of processes), vmstat (system resource usage), xload (system load graph) and tload (terminal graph). How do you control processes? There are other options out there. Make sure to email me tips@hak5.org with your thoughts. And be sure to check out our sister show, http://www.hak5.org for more great stuff just like this. I'll be there, reminding you to trust your technolust. ____________________________________________ Founded in 2005, Hak5's mission is to advance the InfoSec industry. We do this through our award winning educational podcasts, leading pentest gear, and inclusive community – where all hackers belong.

LinuxbashterminalCommandoptionstandardinputoutputshelltipsprocessesCPUmemorybgfggeditpidterminate