Showing posts with label how to. Show all posts
Showing posts with label how to. Show all posts

Friday, June 5, 2015

How to Kill Linux Processes/Unresponsive Applications Using 'kill & pkill' Command

How to Kill Linux Processes/Unresponsive Applications Using 'kill & pkill' Command


kill process in linux

How do we kill a resource/process in Linux?

Obviously we find the PID of the resource and then pass the PID to the kill command. Speaking more accurately, we can find PID of a resource (say firefox) as:

Syntax :

ps -A | grep -i process name

e.g.

ps -A | grep -i firefox

or

alternatively we can use pgrep command to find PID

Syntax :

pgrep process name

e.g.

pgrep firefox

sample output:

sample output image not displyed

In the above output, the number '2697' is the PID of process (firefox), use the kill command to kill the process as shown below.

Syntax :

kill PID OR kill -signalName PID OR kill -signalNumber PID

Where,

  1. signalNumber : A non-negative decimal integer, specifying the signal to be sent instead of the default TERM.
  2. signalName : A symbolic signal name specifying the signal to be sent instead of the default TERM.

e.g.

kill 2697

The kill command sends a signal to a process, whose PID is passed along with the command.

SIGNAL NUMBERSIGNAL NAMEDescriptionUsed for
0SIGNULL (NULL)NullCheck access to pid
1SIGHUP (HUP)HangupTerminate; can be trapped
2SIGINT (INT)InterruptTerminate; can be trapped
3SIGQUIT (QUIT)QuitTerminate with core dump; can be trapped
9SIGKILL (KILL)KillForced termination; cannot be trapped
15SIGTERM (TERM)TerminateTerminate; can be trapped
24SIGSTOP (STOP)StopPause the process; cannot be trapped. This is default if signal not provided to kill command.
25SIGTSTP (STP)TerminalStop/pause the process; can be trapped
26SIGCONT (CONT)ContinueRun a stopped process

Alternatively, we can use pkill command, which kills a process based upon name and other attributes of a process. To kill a process say whose name is firefox, we need to execute:

Syntax :

pkill process name

e.g.

pkill firefox

Forced Killing (SIGKILL or kill -9)

The kill command has a misleading name because it does not actually kill processes. Rather, it sends signals to them. Each process is supplied with a set of standard signal handlers by the operating system in order to deal with incoming signals. When no signal is explicitly included in the command, signal 15, named SIGTERM, is sent by default. If this fails, the stronger signal 9, called SIGKILL, should be used. For example, the following command would nearly guarantee that process 485 would be killed:

Syntax :

kill -9 PID OR pkill -9 process name

kill -9 2697 OR pkill -9 firefox

The only situation in which signal 9 will fail is if the process is in the midst of making a system call, which is a request to the kernel (i.e., the core of the operating system) for some action such as process creation. In this situation, the process will die once it has returned from the system call.

To list the signal names, pass the -l option as follows:

There are more than 60 signals that can be used with kill, but, fortunately, most users will only need to be aware of signal 9. The full list is contained in the file /usr/include/linux/signal.h and can be viewed by using kill with its -l option, i.e.,

kill -l




Sunday, May 24, 2015

How to get started with Linux: A beginner's guide

Linux is one of the biggest Collaborative Development trend and project...



Linux already dominates the mobile space--via Android--as well as the cloud and high performance computing, but it's still worth pointing out. 
There's no end in sight to Linux's strength in these areas.

so we need to know some basic things about Linux before going to use it as our primary os...

let's see a beginner's guide for new linux users.. 

      The world of Linux is ready to welcome you, with a shower of free open-source software you can use on any PC: hundreds of active Linux distributions, and dozens of different desktop environments you could run on them. It's a far cry from the one-size-fits-all, this-is-just-what-comes-with-your-PC vision of Windows.


       Everything from software installation to hardware drivers works differently on Linux, though, which can be daunting. Take heart--you don't even need to install Linux on your PC to get started. Here's everything you need to know.

Choose and download a Linux distro

The first step is choosing the Linux distribution you'll want to use.

Unlike Windows, there's no single version of Linux. Linux distributions take the Linux kernel and combine it with other software like the GNU core utilities, X.org graphical server, a desktop environment, web browser, and more. Each distribution unites some combination of these elements into a single operating system you can install.

DistroWatch offers a good, in-depth summary of all the major Linux distributions you might want to try. Ubuntu is a fine place to start for former (or curious) Windows users. Ubuntu strives to eliminate many of Linux's rougher edges. Many Linux users now prefer Linux Mint, which ships with either the Cinnamon or MATE desktops--both are a bit more traditional than Ubuntu's Unity desktop.

 Choosing the single best isn't your first priority, though. Just choose a fairly popular one like Linux Mint, Ubuntu, Fedora, or openSUSE. Head to the Linux distribution's website and download the ISO disc image you'll need. Yes, it's free.

You can now either burn that ISO image to a DVD, or use a tool like the Universal USB Installer to copy that Linux system to a USB drive. Placing it on a USB drive is a better idea, if possible--the live system will boot and run faster. But if you plan on installing it immediately, a disc is also fine.

That's the way it'll work on a typical Windows PC, anyway. If you want to use Linux on a Chromebook, Raspberry Pi, or another type of device, there are special instructions you'll need to follow.

We'll do it live!

Now you'll need to boot that Linux system. Restart your computer with the disc or USB drive inserted and it should automatically boot. If it doesn't, you may need to change your BIOS or UEFI firmware boot order, or select a boot device during the boot process.

On modern Windows PCs that came with Windows 8, you may have to disable Secure Boot before booting Linux. Some Linux distributions will boot normally with Secure Boot enabled, while some won't. Most of the larger distributions will....



you may also like to read :