LoginSignup
43
42

More than 5 years have passed since last update.

suできなくてもsuする

Posted at

お前は何を言っているんだ。

と言いたくなりますが、例えばapacheユーザー等はログインシェルに/sbin/nologinが指定されているので、普通にsuしようとするとスイッチ出来ません。

# cat /etc/passwd | grep apache
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin

# su - apache
This account is currently not available.

上記の通り怒られます。ので、下記のようにします。

su -s /bin/bash apache

-sオプション用いることでログインシェルを指定することが出来ます。(ここでは/bin/bashを指定)
結果apacheユーザーへもログインすることが出来ます。

また-付きでsuすると、現在の環境変数を解除した上でそのユーザーにスイッチすることが出来ます。

su -s /bin/bash - apache
43
42
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
43
42