システムのパスワード ファイルに含まれるパスワードの数を取得することによって、システムの潜在的なユーザーの数を決定する Bourne / BASH スクリプトを作成する際に助けが必要です。
/etc/passwd を試してみました。常に「許可が拒否されました」と出てきます。私はルートユーザーとして自分自身を変更しますが、同じ問題もあります。私はそれを行う方法を理解することができません。
ファイル/etc/passwd
は通常、通常のユーザーに対して読み取り保護されていないため、システムでこれが当てはまる理由を調査する必要があります。しかし、それを読むことができたとしても、多くのテクニカル ユーザー ( 、 、 、 など) が含まれlp
てsyslog
いbin
ますdaemon
。それらを含めたいかどうかはわかりません。これらを除外するには、既知のテクニカル ユーザーの名前のリストが必要です。
egrep -v '^(daemon|bin|sys|sync|games|man|lp|mail|news|uucp|proxy|nobody|syslog)' /etc/passwd
Assuming your non-system user accounts start numbering at 500:
getent passwd | awk -F':' '{ if ($3 >= 500) print $1}'
And if they start at 1000:
getent passwd | awk -F':' '{ if ($3 >= 1000) print $1}'
Next:
Count the number of high-id "nobody" accounts (e.g., "nfsnobody"). This is any users returned from the above commands that look like they're dummy accounts.
Append | wc -l
to the command used from above and subtract the count from step 1.
This should provide the number of non-system accounts (e.g., "potential" users) on the system.