0
1

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 3 years have passed since last update.

linuxで管理者にユーザーをスイッチするコマンド

Last updated at Posted at 2021-03-21

目的

  • linux系OSのターミナルで管理者ユーザーに切り替えるコマンドをメモ的に紹介する

条件

  • 紹介するコマンドを実行するユーザーもsudoコマンド実行権限があること。

方法

  1. 下記コマンドを実行して管理者ユーザーに切り替える。

    $ sudo su - root
    
  2. 下記コマンドを実行しても管理者ユーザーに切り替える事ができる。

    $ sudo -s
    

超ざっくりとしたコマンドの解説

  1. su ユーザー名コマンドは「ユーザー名」で指定したユーザーにスイッチするコマンドである。
  2. su - ユーザー名コマンドは「ユーザー名」で指定したユーザーにスイッチし、スイッチ後にスイッチしたユーザーのホームディレクトリに移動するコマンドである。(-はオプションということ。)
  3. sudoコマンドは言わずもがな管理者権限で後述するコマンドを実行するということである。
  4. 当該コマンドを日本語で表現すると「管理者権限で管理者ユーザーにユーザースイッチしますよ。スイッチ後は管理者ユーザーのホームディレクトリに移動してください。」ということになる。
0
1
2

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?