The Command Line / Monitor/Kill & Reprioritize
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.
Learn More
Subtitles of the Movie
Monitor, Kill and Reprioritize. Competent Linux administrators manage the processes which run on the local system. To that end you need to know how to monitor those processes currently running, reprioritize processes as needed, and kill those processes that are just getting in the way. First, to monitor what's happening the ps and conf commands can help. First, the ps command. By itself it lists those processes running in the current shell, basically just the shell itself, the command that's run and the fact that I've taken super user privileges on this particular shell. Going a step further the ps a command lists all running shells including, interestingly enough, the shell associated with the GUI on that particular system. If I want information about processes owned by a specific user the -u switch can help. I've opened up some VMware virtual machines as user michael. If desired I can substitute the user ID number for the account, which can be verified in the etc. password configuration file. As you can see here my user account is associated with user ID 1000. If you want a more comprehensive view the ps aux command lists all running processes and that's a lot of processes so I pipe it to a browser or a text pager and I see processes are classified by user, process identifier, the amount of CPU and memory it uses and so on. If I want a hierarchical view of processes on the current system I can run the pstree command and I can see how it starts with the first process, the init daemon and children of said processes and the hierarchy can go down as far as needed. To monitor those processes that are currently running the top command brings up a browser which gives you information about current CPU usage, the amount of memory that's used, the swap space situation, along with the processes identified by PID that are currently using a lot of CPU and memory. You can exit from the browser by pressing q. Now let's look at the iostate command which gives us information about CPU usage along with reads and writes to various block devices, a-k-a hard drives or perhaps USB keys. Sometimes a process will overwhelm anything else running in the local system, that's where the kill command can help. To use the kill command you'll need the process identifier, that's the PID number. In the left-hand column it's shown in the top task browser or in the output to the ps aux command, that PID number. If you were to use the kill command on some hypothetical process, just put in an arbitrary number, by default it sends signal 15 also known as the TERM signal which tries to ask nicely to terminate the process. A common practice, at least in the past, was to use signal 1, also known as HUP, to restart daemons such as servers. For example, if you were to run kill -1 on the user sbin smbd daemon, that would restart the Samba service. If you need to stop a process and these and other kill signals fail you could run the kill -9 followed by the PID number of the process. It's just something to be avoided as it's an "unclean stop" as it leaves things in RAM memory which could be used for other things but wouldn't be recovered, at least not easily without a reboot. Next, let's look at Process Priorities and this can be a little confusing as the highest priority of a process is minus 20 and the lowest priority of a process is positive in this actually positive 19. So to see how this works let's use the nice command to start a new process with an arbitrary party of minus 10. That's actually a -minus 10, thus the double -will start the top task browser with that priority and periodically you'll see the top task browser with the nice value, the ni of minus 10. If the double--were too confusing you could also run nice -n, number of minus 10. If you need the process to have a different priority you can re-prioritize with the renice command. Since it's the top task browser I go to a different terminal, but wait a second, I first need the PID number, 30922 and now I can go to that different terminal and run the renice command 0922 on that specific PID process identifier. The old priority is minus 10, the new priority is minus 13. I go back to the original terminal and I see the top task browser now running with the nice number of minus 13. There it is. Well, those are the basics of Process Management. Thank you and on to the next video.
Tutorial Information
| Course: | CompTIA Linux+ Certification 2009 |
| Author: | Michael Jang |
| SKU: | 34070 |
| ISBN: | 1-935320-91-2 |
| Release Date: | 2009-12-22 |
| Duration: | 6.5 hrs / 82 lessons |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 98,729 Video Tutorials (23,265 free)
- Video Available as Flash or QuickTime
- Over 1026 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 