Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers 2

up vote 8 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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.