LoginSignup
29
29

More than 5 years have passed since last update.

sudo -s って何?

Posted at

nginx のインストールしようと思ったら sudo -s というのが出てきた。

man sudo によると

      -s [command]
                 The -s (shell) option runs the shell specified by the SHELL
                 environment variable if it is set or the shell as specified
                 in the password database.  If a command is specified, it is
                 passed to the shell for execution via the shell's -c
                 option.  If no command is specified, an interactive shell
                 is 

ということでシェルを指定するらしいんだけど、実際は現在のユーザーがrootに変更される。

何故か?

初めは意味がわからなかったけど、これはつまり今使ってるシェルがbashなら

$ sudo /bin/bash と同じことになるらしい。

例えば $ /bin/bash と入力すると画面の見た目は変わらないけど、実際はbashの入れ子構造になってて $ exit してもコンソールウィンドウは閉じずに”中の”bashだけが終了される。それを sudo, つまり root 権限で行ってるのでユーザーが root に変更されるというわけだ。多分そういうことだと思う。

もっと詳しく知りたい人は下にある「"su -s" と "sudo -s" の違いって何?」をお読みください。
私はよくわからなくなってきたのでそっとタブを閉じました。

参考

linux - What does "sudo -s" actually do? - Super User
http://superuser.com/questions/306923/what-does-sudo-s-actually-do

linux - What's the difference between the commands "su -s" and "sudo -s"? - Super User http://superuser.com/questions/29/whats-the-difference-between-the-commands-su-s-and-sudo-s

29
29
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
29
29