0

システムのパスワード ファイルに含まれるパスワードの数を取得することによって、システムの潜在的なユーザーの数を決定する Bourne / BASH スクリプトを作成する際に助けが必要です。

/etc/passwd を試してみました。常に「許可が拒否されました」と出てきます。私はルートユーザーとして自分自身を変更しますが、同じ問題もあります。私はそれを行う方法を理解することができません。

4

2 に答える 2

0

ファイル/etc/passwdは通常、通常のユーザーに対して読み取り保護されていないため、システムでこれが当てはまる理由を調査する必要があります。しかし、それを読むことができたとしても、多くのテクニカル ユーザー ( 、 、 、 など) が含まれlpsyslogbinますdaemon。それらを含めたいかどうかはわかりません。これらを除外するには、既知のテクニカル ユーザーの名前のリストが必要です。

egrep -v '^(daemon|bin|sys|sync|games|man|lp|mail|news|uucp|proxy|nobody|syslog)' /etc/passwd
于 2013-11-13T11:06:27.683 に答える
0

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:

  1. 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.

  2. 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.

于 2013-11-13T11:17:19.213 に答える