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?

More than 1 year has passed since last update.

Linux sudoコマンドと環境変数TMOUTについて(自分用メモ

Posted at

●sudoコマンド
一般ユーザでも、管理者から実行権限を委譲されたコマンドであれば実行できる。

sudo [委譲されたコマンド]

自身に委譲されているコマンドは「sudo -l」で確認できる。

sudoコマンドを実行するとパスワードの入力を求められますが、rootのパスワードではなく、ユーザー自身のパスワードを入力。

●権限委譲の設定は「visudo」コマンドで「/etc/sudoers」ファイルを編集することで行う

「/etc/sudoers」ファイルの書式:
権限を委譲するユーザ名 ホスト名=(実行ユーザ) 委譲するコマンド

●su(Switch User)コマンド
ログイン中に別のユーザーに切り替わる。

suコマンドの特徴
・引数に「-」をつけると、切り替わる先のユーザの環境変数を使用
・ユーザー名を指定しない場合、rootユーザへ切り替わる
・ユーザを切り替える時に求められるパスワードは、切り替わる先のユーザのパスワード
・ただし、rootユーザから別のユーザに切り替わる時はパスワードは要求されない

●環境変数「TMOUT」
指定した時間、何も入力が無ければユーザを自動的にシェルからログアウトさせることができる。

TMOUTには自動ログアウトさせるまで入力を待つ秒数を設定。0(ゼロ)を設定した場合はログアウトしない。

例)1分間(60秒)入力が無ければ自動ログアウトさせる
export TMOUT=60

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?