To get a list of user accounts on your system using the Command Prompt, the command you use depends on your operating system.
For Windows:
- Using
net user
command:- Open Command Prompt as an Administrator.
- Run the following command:
net user
This will display a list of all user accounts on the local computer.
- To get more detailed information about a specific user, run:
net user <username>
Replace
<username>
with the name of the user account you want to investigate. This will show detailed information about the selected user.
For Linux or macOS (Using Terminal):
- Using
cat /etc/passwd
:- Open Terminal.
- Run the following command:
cat /etc/passwd
This will display a list of all users, along with information such as user ID (UID), group ID (GID), home directory, and shell.
- Using
getent passwd
(Alternative):- You can also use the following command, which gives similar results:
getent passwd
- You can also use the following command, which gives similar results:
- To get only the usernames, you can filter the output:
cut -d: -f1 /etc/passwd
This command extracts just the usernames from the
/etc/passwd
file.
Summary
- Windows: Use
net user
in Command Prompt to list user accounts. - Linux/macOS: Use
cat /etc/passwd
orgetent passwd
to view the list of users.