/etc/sudoers (main configuration file)
usernames/group servername = (usernames command can be run as) command
Groups are the same as user groups and are differentiated from regular users by a % at the beginning. The Linux user group “users” would be represented by %users.
You can have multiple usernames per line separated by commas.
Multiple commands also can be separated by commas. Spaces are considered part of the command.
The keyword ALL can mean all usernames, groups, commands and servers.
If you run out of space on a line, you can end it with a back slash (\) and continue on the next line.
sudo assumes that the sudoers file will be used network wide, and therefore offers the option to specify the names of servers which will be using it.
In most cases, the file is used by only one server and the keyword ALL suffices for the server name.
The NOPASSWD keyword provides access without prompting for your password.
Granting All Access to Specific Users
Grant admin1 and admin2 full access to all privileged commands, with this sudoers entry.
admin1,admin2 ALL=(ALL) ALL
Granting Access To Specific Users To Specific Files
teamlead1, %Project ALL= /sbin/, /usr/sbin
This entry allows user teamlead1 and all the members of the group Project to gain access to all the program files in the /sbin and /usr/sbin directories
Granting Access to Specific Files as Another User
sudo -u entry allows allows you to execute a command as if you were another user, but first you have to be granted this privilege in the sudoers file.
This feature can be convenient for programmers who sometimes need to kill processes related to projects they are working on. For example, programmer user1 is on the team developing a financial package that runs a program called thread1 as user accounts. From time to time the application fails, requiring “user1” to stop it with the /bin/kill, /usr/bin/kill or /usr/bin/pkill commands but only as user “accountsmanager”. The sudoers entry would look like this:
user1 ALL=(accountsmanager) /bin/kill, /usr/bin/kill, /usr/bin/pkill
User user1 is allowed to stop the thread1 process with this command:
[user1@learnadmin user1]# sudo -u accountsmanager pkill thread1
Linux administration , Unix administration , Vmware Vsphere administration , Oracle DBA ,apache, backup, dhcp, dns, kvm, xen, kernel, ldap, kvm, monitoring, ticketing, networking, Mail servers, SAN,troubleshooting
Labels
- Amanda (2)
- Ansible (2)
- Answer these Questions (2)
- antivirus (2)
- apache (3)
- Bash (16)
- Chef (3)
- Citrix (2)
- clusters (2)
- Concept (22)
- DatabaseAdminstration (11)
- DevOps (1)
- dhcp (2)
- Downloads (3)
- ELK (1)
- ELK stack (1)
- encryption (1)
- Free trainings (1)
- Frequently Used Commands (46)
- FTP (1)
- git (1)
- gpg (2)
- Hardware (1)
- httpd (2)
- Interview Questions (53)
- iptables (1)
- IT NEWS (3)
- java (1)
- kibana (2)
- knife (1)
- KVM (2)
- linux (17)
- Linux installations (22)
- Linux Jobs (4)
- Linux Links (2)
- logstash (1)
- Mac (1)
- MediaWiki (1)
- MySql (2)
- Nagios (2)
- Networking (3)
- open Nebula (5)
- Open Source tools (12)
- OpenNMS (1)
- openSSL (1)
- Oracle on Linux (5)
- Performance Monitoring (1)
- php (1)
- postfix (1)
- postgres (1)
- postgres-XL (1)
- Product Reviews (1)
- Python (2)
- rssh (1)
- Samba (2)
- Scripting (16)
- security (4)
- selinux (1)
- Server (1)
- SFTP (1)
- Social Awareness (1)
- Solaris (1)
- SSL (1)
- svn (1)
- TCP/IP (1)
- Technology (1)
- Tips and Tricks (32)
- Training and materials (8)
- Troubleshooting (6)
- Ubuntu (18)
- unix (1)
- virtualization (17)
- Vmware (25)
- Vyatta (1)
- windows7 (1)
- xml (1)
No comments:
Post a Comment