Welcome to the Linux Foundation Forum!

Chapter 4 - killall & pkill

Hi there! I am an old dog learning new tricks, but isn't below formula wrong?

Chapter 4 - killall & pkill

pkill sends a signal to a process using selection criteria:

$ pkill [-signal] [options] [pattern]

I think signal and options should be reversed. What do you guys think?

Comments

  • coop
    coop Posts: 916

    "-signal" is an option so the order is irrelevant. It is just showing special attention to the -signal option. Just try it (before posting). The following lines all do the same thing:
    pkill -44 -u 1000 cat
    pklll cat -u 1000 -44
    pkill -u 1000 cat -44

    etc, order is irrelvant, even where the pattern goes

  • Sudoaptgetgood
    Sudoaptgetgood Posts: 24
    edited May 2020

    Thanks for explaining! Since I'm a fish, I tend to take instructions very literally, plus order helps me remember this stuff.
    I think the explanation in the course threw me off, where I saw -u as an option, libby as process name, and foobar as identificator within the process. That being said, I think [-signal] was the one that confused me the most. Nevertheless, you are right. I will test in the future before asking any questions here.

    course expl:

    $ pkill [-signal] [options] [pattern]

    For example:

    $ pkill -u libby foobar

    will kill all of libby's processes with a name of foobar.

  • luisviveropena
    luisviveropena Posts: 1,249

    Hi,

    You always can do 'man ' to see the available information of the associated man pages about the command. In this case 'man pkill' shows the following:

    PGREP(1) User Commands PGREP(1)

    NAME
    pgrep, pkill - look up or signal processes based on name and other attributes

    SYNOPSIS
    pgrep [options] pattern
    pkill [options] pattern

    DESCRIPTION
    pgrep looks through the currently running processes and lists the process IDs which match the selection criteria to stdout. All the criteria have to match. For example,

    [...]

    OPTIONS
    -signal
    --signal signal
    Defines the signal to send to each matched process. Either the numeric or the symbolic signal name can be used. (pkill only.)

    [...]

    Regards,
    Luis.

Categories

Upcoming Training