Can I use wildcards in sudoers?

QuestionsQuestions8 SkillsProUser Account ManagementOct, 08 2025
0181

Yes, you can use wildcards in the /etc/sudoers file to specify commands. This allows for more flexible configurations. Here are some common ways to use wildcards:

  1. Command Wildcards: You can use * to match any characters in the command path. For example:

    username ALL=(ALL) /usr/bin/* 

    This allows the user to run any command located in the /usr/bin/ directory.

  2. Directory Wildcards: You can also use ? to match a single character. For example:

    username ALL=(ALL) /usr/bin/command?

    This allows the user to run commands like command1, command2, etc.

  3. Combining Wildcards: You can combine wildcards with specific commands. For example:

    username ALL=(ALL) /usr/bin/command* /usr/local/bin/script*

    This allows the user to run any command starting with command in /usr/bin/ and any script starting with script in /usr/local/bin/.

Important Note:

When using wildcards, be cautious as they can grant broader access than intended. Always review your configurations to ensure they align with your security policies. If you have more questions, feel free to ask!

0 Comments

no data
Be the first to share your comment!