Originariamente inviato da
UnixMan
tranquillo, ho capito benissimo.
che funzioni tutto ne dubito fortemente... estratto dalle man page di "su" e "sudo":
codice:
NAME
su - change user ID or become superuser
SYNOPSIS
su [options] [username]
DESCRIPTION
The su command is used to become another user during a login session. Invoked without a username, su defaults to becoming the
superuser. The optional argument - may be used to provide an environment similar to what the user would expect had the user logged
in directly.
Additional arguments may be provided after the username, in which case they are supplied to the user's login shell. In particular,
an argument of -c will cause the next argument to be treated as a command by most command interpreters. The command will be
executed by the shell specified in /etc/passwd for the target user.
...
invece, sudo:
codice:
NAME
sudo, sudoedit — execute a command as another user
SYNOPSIS
sudo -h | -K | -k | -V
sudo -v [-AknS] [-a type] [-g group] [-h host] [-p prompt] [-u user]
sudo -l [-AknS] [-a type] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command]
sudo [-AbEHnPS] [-a type] [-C num] [-c class] [-g group] [-h host] [-p prompt] [-r role] [-t type] [-u user] [VAR=value] [-i | -s]
[command]
sudoedit [-AknS] [-a type] [-C num] [-c class] [-g group] [-h host] [-p prompt] [-u user] file ...
DESCRIPTION
sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.
sudo supports a plugin architecture for security policies and input/output logging. Third parties can develop and distribute their
own policy and I/O logging plugins to work seamlessly with the sudo front end. The default security policy is sudoers, which is
configured via the file /etc/sudoers, or via LDAP. See the Plugins section for more information.
The security policy determines what privileges, if any, a user has to run sudo. The policy may require that users authenticate
themselves with a password or another authentication mechanism. If authentication is required, sudo will exit if the user's pass‐
word is not entered within a configurable time limit. This limit is policy-specific; the default password prompt timeout for the
sudoers security policy is unlimited.
Security policies may support credential caching to allow the user to run sudo again for a period of time without requiring authen‐
tication. The sudoers policy caches credentials for 15 minutes, unless overridden in sudoers(5). By running sudo with the -v
option, a user can update the cached credentials without running a command.
When invoked as sudoedit, the -e option (described below), is implied.
Security policies may log successful and failed attempts to use sudo. If an I/O plugin is configured, the running command's input
and output may be logged as well.
The options are as follows:
...
I due comandi NON sono per nulla equivalenti. A te serve "sudo" (opportunamente configurato),
non puoi usare "su". Full stop.
esatto. Quello che ho postato è un esempio (per grandi linee, e che potrebbe contenere errori - era solo per rendere l'idea) di come puoi/devi configurare "sudo" per ottenere quello che ti serve (la configurazione di sudo è contenuta nel file "/etc/sudoers" e/o nei files in "/etc/sudoers.d"; in questo caso però i files non vanno editati direttamente ma sempre e soltanto attraverso l'apposito comando "visudo").
configurare "sudo" (cioè, il file "/etc/sudoers") in modo che l'utente che vuoi (in questo caso "www-data") sia autorizzato ad utilizzare "sudo" per eseguire i comandi che ti servono e "sudoedit" per accedere ai files che devi leggere/modificare (in entrambi i casi, senza che venga chiesta alcuna password).
N.B.: l'esempio che ho postato si riferiva (
esclusivamente) a tale configurazione (file "sudoers").
Come detto... RTFM!
se proprio non ti piacciono i manuali, ...
Let me google that for you
http://it.wikipedia.org/wiki/Sudo (per capire per sommi capi cos'è e come funziona sudo)
AmministrazioneSistema/Sudo - Wiki di ubuntu-it
Guida a Sudo - Guide@Debianizzati.Org (questa è la guida più completa)
Quick HOWTO : Ch09 : Linux Users and Sudo - Linux Home Networking
ecc, ecc...