GNU/Linux >> Linux の 問題 >  >> Linux

SSH経由で特定のユーザーのすべてのプロセスを強制終了します

特定のユーザーのすべてのプロセスを強制終了したい場合があります。これは、シェルコマンド pkillを使用して実行できます。 およびkillall

pkillコマンドとkillallコマンドの違いを確認するには、この投稿の最後にリストされているヘルプページを参照してください。

したがって、ユーザーのすべてのプロセスを強制終了するには、

pkill -u username

使用法の構文は次のとおりです。

root@web [~]# pkill -h

Usage:
 pkill [options] 

Options:
 -<sig>, --signal <sig>    signal to send (either number or name)
 -e, --echo                display what is killed
 -c, --count               count of matching processes
 -f, --full                use full process name to match
 -g, --pgroup <PGID,...>   match listed process group IDs
 -G, --group <GID,...>     match real group IDs
 -n, --newest              select most recently started
 -o, --oldest              select least recently started
 -P, --parent <PPID,...>   match only child processes of the given parent
 -s, --session <SID,...>   match session IDs
 -t, --terminal <tty,...>  match by controlling terminal
 -u, --euid <ID,...>       match by effective IDs
 -U, --uid <ID,...>        match by real IDs
 -x, --exact               match exactly with the command name
 -F, --pidfile <file>      read PIDs from file
 -L, --logpidfile          fail if PID file is not locked
 --ns <PID>>               match the processes that belong to the same
                           namespace as 
 --nslist <ns,...>         list which namespaces will be considered for
                           the --ns option.
                           Available namespaces: ipc, mnt, net, pid, user, uts

 -h, --help     display this help and exit
 -V, --version  output version information and exit

killall ツール、シェルコマンドは似ています:

killall -u username

使用法の構文は次のとおりです。

root@web [~]# killall -h
Usage: killall [-Z CONTEXT] [-u USER] [ -eIgiqrvw ] [ -SIGNAL ] NAME...
       killall -l, --list
       killall -V, --version

  -e,--exact          require exact match for very long names
  -I,--ignore-case    case insensitive process name match
  -g,--process-group  kill process group instead of process
  -y,--younger-than   kill processes younger than TIME
  -o,--older-than     kill processes older than TIME
  -i,--interactive    ask for confirmation before killing
  -l,--list           list all known signal names
  -q,--quiet          don't print complaints
  -r,--regexp         interpret NAME as an extended regular expression
  -s,--signal SIGNAL  send this signal instead of SIGTERM
  -u,--user USER      kill only process(es) running as USER
  -v,--verbose        report if the signal was successfully sent
  -V,--version        display version information
  -w,--wait           wait for processes to die
  -Z,--context REGEXP kill only process(es) having context
                      (must precede other arguments)

リソース:
https://linux.die.net/man/1/pkill
https://linux.die.net/man/1/killall


Linux
  1. SSH経由でrootユーザーのログインを無効にする方法

  2. SSHで実行中のユーザーのプロセスを表示するにはどうすればよいですか?

  3. 特定の部分名を持つすべてのプロセスを強制終了する方法は?

  1. zshですべてのバックグラウンドプロセスを強制終了するには?

  2. UID を使用してすべてのユーザーのプロセスを強制終了するにはどうすればよいですか

  3. デフォルトで SSH 経由のログインが許可されているユーザーは?

  1. アプリケーションに関連するすべてのプロセスを強制終了します

  2. SSH アクセスを IP アドレスで特定のクライアントに制限する

  3. 特定のユーザーが書き込み可能なすべてのファイルとディレクトリを見つけるにはどうすればよいですか?