Using Linux:Managing the Kernel
-->
Previous
Table of Contents
Next
Using the kill Command and Process IDs
The kill utility is used to send signals to processes. One of the uses, as the name of the utility suggests, is for terminating or removing unwanted processes from the system. kill can also send other signals to processes. For instance, the HUP signal by convention causes most daemon programs to re-read their initialization files.
Confusing signal names
Signal names such as HUP and KILL are often referred to as SIGHUP and SIGKILL. Either way of writing them is usually valid, but some utilities might accept only one or the other.
Another noteworthy point is that most shells, such as bash, contain their own built-in kill utilities. On some shells, this can be quite different than the kill thats described here, and youd do well to check your shells documentation to see how that behaves. In this section, you learn about bashs kill behavior.
The bash shell is capable of getting a process ID for you, provided the process is running in the background of that session. For other processes, you must use the ps utility to get the process ID. You can kill only processes that your user ID ownsunless, of course, you are logged on as root.
This syntax of the kill command is as follows:
kill -s <signal> <process id>
To print a list of signals and their numbers, execute the following command:
kill -l
The default signal that kill sends is TERM signal.
Killing a process
1. Obtain the process ID by running ps. If the list is too long, and if you know the process name, try piping the output to the grep utility to find the word for you.
2. With the process ID handy, type the command kill <PID>, where <PID> is the process ID number. The command prompt returns. If bash complains about there being no such process, then you have the wrong number, or the process has already terminated.
3. After the next command is executed, bash should produce a message such as the following:
[1]+ Terminated find / -name what
If it does not produce such a message, the process is not responding to TERM signals. In this example, the program find was terminated.
4. If bash does not issue that message, and another look using ps shows that the process is still merrily gobbling up your CPU time, youll need to do something more drastic. First make sure that the program is not doing some sort of shutdown processing that needs to be completed, and then issue the following command to kill the process:
kill s 9 <PID>
This is a signal that a program cannot ignore, so the process is terminated even if it does not want to be. After the next command (or just after pressing Enter if you have nothing else to do), bash should print the following message to tell you that the program has been killed:
[1]+ Killed find / -name what
Getting impatient when sending signals to programs
Some programs need to do some work before shutting down, such as saving open files. Be sure to give the program enough time to do this, or data loss can occur.
Recompiling the Kernel
Every once in a while, it is worthwhile to see whether a new kernel for Linux has been released. Usually new kernels provide fixes for problems that people have experienced, or provide performance improvements (usually both). The new kernels can also contain more device drivers. This section discusses how to obtain, compile, and install a new kernel on your Linux system.
The official repository for Linux kernels is the FTP site sunsite.unc.edu, in the directory /pub/Linux/kernel/v2.0. The Red Hat Linux installation program should have placed the source code to your current kernel in the /usr/src/linux directory on your hard disk. This is a symbolic link to the actual source directory.
The disclaimer
The process of compiling and installing kernels is not for the technically faint-of-heart: Mistakes here could leave your system in an unbootable state, or worse, could damage your hardware or disk contents. You have been warned.
Installing the New Kernel Source
After you have downloaded the kernel source, you must decompress it and extract the directories within. You must be logged on as root, as well, or at least have full permissions to the /usr/src directory. This assumes that you have downloaded the kernel source to the /root directory. Be sure to substitute the directory that the kernel was downloaded to for your system. You must also have about 1015 MB of free space to extract and compile a new kernel.
1. Delete the symbolic link pointing to the current Linux kernel source directory. The idea is to avoid overwriting the current source directory, because it might contain modifications you have made. Its also a setup that you should be able to restore if something goes wrong. The command is as follows:
rm linux
If rm tells you youre deleting a directory, then there is something wrong. Check the directory youre in, and make sure that linux is a symbolic link to the current source directory.
2. Create the new directory to hold the kernel source. The reason this is being done is that the source distribution wants to extract itself to a directory called linux, but this is not the way it is intended to be used. Create a directory with an appropriate name, usually linux-, followed by the kernel version (for example, linux-2.0.33).
3. Create the new symbolic link to the new directory by entering the following:
ln -s <your directory name> linux
4. Extract the file to the new directory by entering the following:
tar xzvf <kernel file name>
Your new kernel source is now correctly installed and you can configure the kernel. Depending on the speed of your system, this can take some time.
Previous
Table of Contents
Next
Wyszukiwarka
Podobne podstrony:
README (589)589,8,artykulCLATRONIC AR 589 CD AR 600 CD589 592589 640 (2)586 588więcej podobnych podstron