LoginSignup
8
9

More than 5 years have passed since last update.

「This account is currently not available.」なアカウントで任意のコマンドを実行する

Posted at

はじめに

ログインシェルに/sbin/nologinが指定されているユーザの権限で任意のコマンドを実行する方法を記述します。

環境

  • CentOS 6.4
  • sudo 1.8.6p3
  • bash 4.1.2

任意のコマンドを実行する

今回はapacheユーザを利用して動作を確認します。

$ getent passwd apache
apache:x:48:48:Apache:/var/www:/sbin/nologin
$ sudo su - apache
This account is currently not available.

一般ユーザの場合

sudoコマンドを利用します。

$ sudo -u apache whoami
apache

rootユーザの場合

suコマンド、またはsudoコマンドを利用します。

# su - apache -s /bin/bash -c whoami
apache

# sudo -u apache whoami
apache

参考

8
9
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
8
9