Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| rh124_sudo [2026/10/23 09:28] – created rpjday | rh124_sudo [2026/10/30 12:09] (current) – [Links] rpjday | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== RH124 sudo and sudoers file ====== | ====== RH124 sudo and sudoers file ====== | ||
| + | |||
| + | ===== Ask Google ===== | ||
| + | |||
| + | Does EX200 exam ask about sudo and sudoers file? | ||
| + | |||
| + | //" | ||
| + | |||
| + | ===== Links ===== | ||
| + | |||
| + | * [[https:// | ||
| + | * [[www.geeksforgeeks.org/ | ||
| + | * [[https:// | ||
| + | ===== The " | ||
| + | |||
| + | All members of the '' | ||
| + | |||
| + | ===== Using the same sudoers file across multiple hosts ===== | ||
| + | |||
| + | You can use the same ''/ | ||
| + | |||
| + | ===== General format of sudoers line ===== | ||
| + | |||
| + | < | ||
| + | username hostname = (run_as_user: | ||
| + | </ | ||
| + | |||
| + | Examples: | ||
| + | |||
| + | < | ||
| + | username ALL=(ALL: | ||
| + | username ALL=(ALL) ALL | ||
| + | %groupname ALL=(ALL) NOPASSWD: ALL | ||
| + | %groupname ALL=(ALL) NOPASSWD: / | ||
| + | %groupname host1, | ||
| + | username host_alias=(ALL) ALL | ||
| + | </ | ||
| + | |||
| + | ===== Very abbreviated / | ||
| + | |||
| + | Note much of this file is commented out. | ||
| + | |||
| + | < | ||
| + | ## This file must be edited with the ' | ||
| + | |||
| + | ## Host Aliases | ||
| + | ## Groups of machines. You may prefer to use hostnames (perhaps using | ||
| + | ## wildcards for entire domains) or IP addresses instead. | ||
| + | # Host_Alias | ||
| + | # Host_Alias | ||
| + | |||
| + | ## User Aliases | ||
| + | ## These aren't often necessary, as you can use regular groups | ||
| + | ## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname | ||
| + | ## rather than USERALIAS | ||
| + | # User_Alias ADMINS = jsmith, mikem | ||
| + | |||
| + | ## Command Aliases | ||
| + | ## These are groups of related commands... | ||
| + | |||
| + | ## Networking | ||
| + | # Cmnd_Alias NETWORKING = / | ||
| + | |||
| + | ## Installation and management of software | ||
| + | # Cmnd_Alias SOFTWARE = /bin/rpm, / | ||
| + | |||
| + | ## Services | ||
| + | # Cmnd_Alias SERVICES = / | ||
| + | |||
| + | ## Updating the locate database | ||
| + | # Cmnd_Alias LOCATE = / | ||
| + | |||
| + | ## Storage | ||
| + | # Cmnd_Alias STORAGE = / | ||
| + | |||
| + | ## Delegating permissions | ||
| + | # Cmnd_Alias DELEGATING = / | ||
| + | |||
| + | ## Processes | ||
| + | # Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, / | ||
| + | |||
| + | ## Drivers | ||
| + | # Cmnd_Alias DRIVERS = / | ||
| + | |||
| + | ... big snip ... | ||
| + | |||
| + | ## Next comes the main part: which users can run what software on | ||
| + | ## which machines (the sudoers file can be shared between multiple | ||
| + | ## systems). | ||
| + | ## Syntax: | ||
| + | ## | ||
| + | ## user MACHINE=COMMANDS | ||
| + | ## | ||
| + | ## The COMMANDS section may have other options added to it. | ||
| + | ## | ||
| + | ## Allow root to run any commands anywhere | ||
| + | root ALL=(ALL) ALL | ||
| + | |||
| + | ## Allows members of the ' | ||
| + | ## service management apps and more. | ||
| + | # %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS | ||
| + | |||
| + | ## Allows people in group wheel to run all commands | ||
| + | %wheel ALL=(ALL) ALL | ||
| + | |||
| + | ## Same thing without a password | ||
| + | # %wheel ALL=(ALL) NOPASSWD: | ||
| + | |||
| + | ## Allows members of the users group to mount and unmount the | ||
| + | ## cdrom as root | ||
| + | # %users | ||
| + | |||
| + | ## Allows members of the users group to shutdown this system | ||
| + | # %users | ||
| + | |||
| + | ## Read drop-in files from / | ||
| + | #includedir / | ||
| + | </ | ||
| + | |||
| + | Note well the final ''# | ||
| + | |||
| + | ===== Giving the class sudo access ===== | ||
| + | |||
| + | ==== Option 1 ==== | ||
| + | |||
| + | Add all class accounts to the '' | ||
| + | |||
| + | ==== Option 2 ==== | ||
| + | |||
| + | Create a new group, '' | ||
| + | |||
| + | < | ||
| + | %class ALL=(ALL) ALL | ||
| + | %class ALL=(ALL) NOPASSWD: ALL | ||
| + | </ | ||
| + | |||
| + | ===== How to examine your own sudo capabilities ===== | ||
| + | |||
| + | < | ||
| + | $ sudo -l | ||
| + | </ | ||