0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Linucレベル1勉強メモ #13

Last updated at Posted at 2025-05-04

# 第一章 Linuxのインストールと仮想マシン・コンテナの利用

練習問題1.13
fredユーザーが実行しているプロセスnanoを終了させようと、以下の操作を実行しました。

$ whoami
linucuser
$ ps aux | grep nano
fred 2474 0.0 0.0 115104 1804 pts/1 S+ 22:04 0:00 nano sample.txt
$ kill 2474
-bash: kill: (2474) - Operation not permitted

エラーが発生した原因として適切なものを選択してください。

A. fredユーザー以外の一般ユーザーでkillコマンドを実行したから

B. 指定すべきPIDが誤っているから

C. killコマンドの引数にはプロセス名を指定すべきだから

D. killコマンドでシグナルが指定されていないから

E. プロセスを終了できるのはrootユーザーだけだから

(解答)A.

(解説)
一般ユーザーがkillコマンドを使って終了できるプロセスは、そのユーザー自身が実行しているプロセスのみです。設問では、whoamiコマンドの実行結果から、killコマンドを実行したユーザーがfredユーザーではない(linucuserユーザーである)ことがわかります。なお、whoamiコマンドは、コマンドを実行したユーザーを表示するコマンドです。psコマンドの出力から、nanoプロセスのPIDは2474です。killコマンドの引数は間違えていません。引数にプロセス名を指定できるのは、killコマンドではなくkillallコマンドです。killコマンドでシグナルが指定されていない場合はTERMシグナルが使われますので設問のケースでは、シグナルの指定は必要ありません。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?