雑草SEの備忘録

東大を卒業し、SEとして働くことになった。備忘録的に作業を綴る。

Linuxのユーザーまわりの備忘録

Linuxのユーザー一覧を見る

less /etc/passwd

特定のユーザーの権限だけを見たい場合

$ getent passwd webapp
webapp:x:496:494::/home/webapp:/sbin/nologin

$ getent passwd ec2-user
ec2-user:x:501:501:EC2 Default User:/home/ec2-user:/bin/bash

ログインシェルに/sbin/nologinと指定してある場合、ログインすることができない。ログインしようとすると、This account is currently not availableが表示される。

$ sudo su - webapp
最終ログイン: 2019/05/07 (火) 07:20:07 JST日時 pts/0
su: warning: cannot change directory to /home/webapp: そのようなファイルやディレクトリはありません
This account is currently not available

ログインできないユーザーでコマンドを実行したいとき

sudo -uを使う。

$ sudo -u webapp whoami
webapp