Posted: . At: 12:17 PM. This was 3 years ago. Post ID: 15069
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Using the kill command on Linux.


Killing rogue programs in Linux

The kill command included by default with the Linux suite of commands may be used to terminate a process by passing kill a process ID (PID). By default, kill just tells the process to die, but if the process has made previous arrangements with the Linux kernel it is sometimes able to ignore the request. If you want to force a stubborn process to die, you can use the ‘-9’ or ‘-KILL’ switch to force it to die. One way to tell whether a process actually did die is to simply repeat the kill command by pressing your up-arrow and then Enter. If the process has died, kill will produce an error message ‘No such pid’; if the process hasn’t died, kill won’t output anything. The kill command is more general than its name implies. It can be used to terminate a process, but this is just a case of using signals. A signal is a single number that gets sent to a process by the Linux kernel (either directly, or from another process). The kill command just happens to be a convenient way to send any signal to any process from the command line by specifying the signal number or name. In the previous example, ‘9’ was the signal number, and ‘KILL’ was the signal name; to get a listing of all signals, type kill -l.

As an example of a nonviolent signal, number 10 is ‘USR1’, which is the first user-defined signal; this is by default ignored by processes, but it can trigger some application-specific behavior. For example, if you send the Apache Web server a USR1 signal, it will perform a reload of its configuration files — a quick and easy way to initialize any changes. The killall command is a handy shortcut for sending a signal to a process if you know the name of the process, but not its PID. For example, you can kill your pppd daemon at the command line with killall pppd without ever issuing a ps to look up the process ID. It’s also useful if you want to kill multiple instances of a program without individually looking up and terminating each process with ps and kill. For example, if Firefox has bombed out on you and you have multiple instances running, you can terminate them all at once with killall Firefox. A word of warning though: if you ever happen to be using a non-Linux Unix computer, don’t use killall. On many other Unixes, this will kill many more processes than you would expect it to!

Copying and pasting in X

Even if they don’t have Edit —> Copy and Edit —> Paste menus, most X applications support copying and pasting of text between windows using only the mouse. In its simplest form, copying is just a question of highlighting the relevant text by clicking and dragging. To paste, just put the mouse pointer where you want to paste, and press your middle mouse button. If you only have a two-button mouse, X is most likely set up so that pressing both buttons together simulates the middle mouse button. For applications that don’t allow you to change the point at which you insert text, such as Xterm or gnome-terminal, it doesn’t matter where in the window you click the middle button — the text will just be pasted at the cursor. For others where you can move the text cursor around, such as Netscape, you need to click where you want the text inserted. Many applications also let you double-click to highlight a single word, or do a double-click-drag (press, release, press your mouse button quickly, then drag) to highlight a word at a time.

In a similar way, selecting a whole line or range of lines can be achieved by triple-clicking or performing a triple-click-drag. This might take a bit of practice, but it’s rather useful. If you have the GPM daemon loaded, this same functionality is available to you in full-screen console sessions. It can save a lot of time when it comes down to editing configuration files at the console.

Use the /etc/hosts file

Tired of typing in long IP addresses when you Telnet or FTP to a host? Do you find it hard to remember the addresses themselves? Not a problem: throw the addresses and hostnames into your /etc/hosts file. In fact, you should add the IP addresses and hostnames of all machines on the local network you expect to interact with. It’s not just a matter of telnet Hal being easier to type than telnet 192.68.0.2. Many parts of your Linux system will look to the /etc/hosts file to find out the addresses of other hosts. You’ll notice an entry for ‘localhost’. Now you know why you can do nifty things like type ‘localhost’ in your browser to access services such as Webmin and Swat.


1 thought on “Using the kill command on Linux.”

  1. ffmpeg -i 2021.05.08-22.18.mp4 -ss 00:47:50 -t 24 output.mp4

    Streamable———

    ffmpeg -i output.mp4 -vf scale=1280×720 -c:v libvpx-vp9 -crf 7 -b:v 1.5M -crf 6 -c:a libvorbis output.webm

    4chan————–

    ffmpeg -i output.mp4 -vf scale=1280×720 -c:v libvpx -an -crf 7 -b:v 1M output.webm

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.