View all users under Linux (Shell scripting get)

Source: Internet
Author: User
In Linux systems, the two most important files for user account management are/etc/password and/etc/shadow.
In the/etc/password file, each line represents an account, but there are many accounts that are system accounts. Like what:
Bin, ADM, etc., as well as administrator account root. The rest is for general user accounts.
Each line is composed of (to: Split):
1 account name;
2 password (combined with/etc/shadow);
3 UID User ID, where 0 is the root, 1~499 is the system user account, and the general users account.

As a result, all users (general users) under Linux can be obtained according to the scope of the UID.
You can use the shell command to get:
cat/etc/passwd | Awk-f: ' $3>=500 ' | Cut-f 1-d:
Output the/etc/passwd file, processing each row, judging by a colon: the third element of the split, extracting the rows greater than 500, and using cut to output the first column (user account name).
Test system: Fedora release 9 (sulphur) kernel:2.6.25

View all users under Linux (Shell scripting get)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.