Si può utilizzare "sudo" anche in Fedora ?
Certo. Vediamo un esempio di come configurarlo.
$ su -c 'yum install sudo'
Il file di configurazione di sudo è /etc/sudoers ovviamente solo root può modificarlo tramite il comando visudo
# visudo
Ammettiamo che sul nostro sistema ci siano tre utenti generici (user1, user2, user3), due collaboratori (free1, free2) e l'amministratore root.
Ai due collaboratori, essendo utenti con discreta esperienza, root vuole concedere alcuni dei propri permessi :
SEZIONE 'USERS 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 COLLABORATORI = free1, free2
La riga decommentata che inizia per User_Alias identifica i due utenti come COLLABORATORI; possiamo chiamarli diversamente a nostro piacimento, ricordandoci di elencare i nomi utente in oggetto (free1, free2).
SEZIONE 'COMMAND ALIASES'
## Command Aliases
## These are groups of related commands...
## Networking
# Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool
...
Questa sezione è già precompilata ed elenca degli alias per gruppi di comandi come, ad esempio, il gruppo NETWORKING che racchiude rfcomm, wvdial,... oppure il gruppo SOFTWARE che racchiude yum, rpm, up2date.
Decommentiamo i gruppi di comandi che vogliamo affidare agli utenti COLLABORATORI (nell'esempio SOFTWARE e SERVICES):
## Command Aliases
## These are groups of related commands...
## Networking
# Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool
## Installation and management of software
Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum
## Services
Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig
## Updating the locate database
# Cmnd_Alias LOCATE = /usr/bin/updatedb
## Storage
# Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount
## Delegating permissions
# Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp
## Processes
# Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall
## Drivers
# Cmnd_Alias DRIVERS = /sbin/modprobe
Mettiamo insieme il tutto, la riga root è già presente, mentre l'ultima riga è la nostra configurazione che permette agli utenti con l'alias COLLABORATORI di poter usare i comandi dei gruppi SOFTWARE E SERVICES:
SEZIONE PRINCIPALE
## 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
COLLABORATORI ALL=SOFTWARE,SERVICES
Dopo la modifica del file, salviamo con :wq
In questa situazione l'utente free1 può usare yum,rpm,service,chkconfig come se fosse root fornendo la propria password.