How to search for multiple users?

QuestionsQuestions4 SkillsProUser Account ManagementSep, 17 2025
0177

To search for multiple users in the /etc/passwd file, you can use the grep command with a regular expression. Here's an example command that searches for users 'joker' and 'batman':

sudo grep -E '^(joker|batman):' /etc/passwd

Breakdown:

  • sudo: Runs the command with superuser privileges.
  • grep: The command used for searching text.
  • -E: Enables extended regular expressions, allowing the use of the | operator for "or".
  • ^(joker|batman):: This pattern matches lines that start with either 'joker' or 'batman', followed by a colon, which is the format used in the /etc/passwd file.

You can add more usernames by extending the pattern within the parentheses, separated by the | operator.

If you need further assistance, feel free to ask!

0 Comments

no data
Be the first to share your comment!