Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have seen the following command:

$ kill %1

What is the usage of this statement?

share|improve this question

migrated from stackoverflow.com Jul 30 '11 at 22:39

This question came from our site for professional and enthusiast programmers.

    
    
Note also that zsh has job completion, such that running htop & and then disown %[TAB] will autocomplete to disown %htop. I love zsh :) – new123456 Jul 31 '11 at 2:40
up vote 9 down vote accepted

Briefly,

It means to kill job number 1, not process number one.

Jobs can be listed with the jobs command.

More broadly, it relates to whichever shell you are using, and the syntax could differ from shell to shell.

Using the bash shell, a user can have several processes (jobs) executing simultaneously, whose parent process is the shell you are using. Google bash job control basics

The builtin kill command is used to send a signal to one of those job pipelines. If the specific signal is not specified, SIGTERM is used, which typically ends (kills) the job, hence the name kill. But any signal can be specified some of which might somehow reset the process or cause non-killing behavior.

Finally, the %1 is one way (of many!) of specifying which job you wish to send the signal to. %1 refers to the job on top of the stack of background jobs.

share|improve this answer
    
Minor..but it is not a stack, it is like a queue. – endless Dec 6 '15 at 23:21

When you background a process for example:

# find / &
[1] ....

# ls -lr /usr &
[2] ....

Now, Here there are two processes running in background and connected to the current terminal. If you do: kill %1

the first, 'find' command above will get terminated. As told by Anders you can list the currently running background processes on the terminal and kill them:

# jobs
[1] find / ...
[2] ls -lr ...

# kill %1
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .