Sudo/es

La orden ofrece una forma sencilla y segura de configurar el escalado de privilegios, esto es, permitir a los usuarios normales correr algunas (o todas) las órdenes que se deseen como root o como otro usuario, posiblemente sin tener que suministrar una contraseña.

Cuando quiera que varias personas realicen ciertas tareas administrativas en su sistema sin que tenga que concederles un acceso total como root, el uso de sudo es la mejor opción. Con sudo puede controlar quién puede hacer según qué. Esta guía le ofrece una pequeña introducción a esta maravillosa herramienta.

This article is meant as a quick introduction. The package is a lot more powerful than what is described here. It has special features for editing files as a different user, running from within a script (so it can background, read the password from standard in instead of the keyboard, ...), etc.

Please read the and  manual pages for more information.

Registrar la actividad
One additional advantage of is that it can log any attempt (successful or not) to run an application. This is very useful if you want to track who made that one fatal mistake that took you 10 hours to fix :)

Conceder permisos
The package allows the system administrator to grant permission to other users to execute one or more applications they would normally have no right to. Unlike using the  bit on these applications  gives a more fine-grained control on who can execute a certain command and when.

With you can make a clear list who can execute a certain application. If you would set the setuid bit, any user would be able to run this application (or any user of a certain group, depending on the permissions used). You can (and probably even should) require the user to provide a password when he wants to execute the application.

The configuration is managed by the  file. This file should never be edited through or  or any other editor you might like. When you want to alter this file, you should use.

Esta herramienta se asegura que no haya dos administradores del sistema editando el fichero al mismo tiempo, conserva sus permisos y realiza una comprobación de la sintaxis para cerciorarse de que no se cometan errores fatales en el fichero.

Sintaxis básica
The most difficult part of is the  syntax. The basic syntax is like so:

This syntax tells that the user, identified by   and logged in on the system   can execute any of the commands listed in   as the root user. A more real-life example might make this more clear: allow the user to execute  if he is logged in on localhost:

The user name can also be substituted with a group name - in this case you should start the group name with a  sign. For instance, to allow any one in the group to execute :

You can extend the line to allow for several commands (instead of making a single entry for each command). For instance, to allow the same user to not only run but also  and  as root:

You can also specify a precise command and not only the tool itself. This is useful to restrict the use of a certain tool to a specified set of command options. The tool allows shell-style wildcards (AKA meta or glob characters) to be used in path names as well as command-line arguments in the sudoers file. Note that these are not regular expressions.

Pongamos todo esto a prueba:

The password that requires is the user's own password. This is to make sure that no terminal that you accidentally left open to others is abused for malicious purposes.

You should know that does not alter the   variable: any command you place after  is treated from your environment. If you want the user to run a tool in for instance he should provide the full path to, like so:

Sintaxis básica con LDAP
The  and   USE flags are needed for the LDAP support.

Cuando se utiliza sudo con LDAP, sudo también leerá la configuración del servidor LDAP, por lo que necesitará editar estos dos ficheros.

También necesitará añadir la siguiente entrada LDAP para sudo.

Las configuraciones del sudoer en LDAP son similares a los ficheros con algunas diferencias. Por favor, lea más sobre sudo con LDAP en el enlace de abajo página del manual de Sudoers LDAP

(para distinguir correctamente entre lo que son y no son alias, se recomienda utilizar mayúsculas para los alias). Como indudablemente habrá deducido, el alias  sirve para todas los valores posibles.

A sample use of the  alias to allow any user to execute the  command if he is logged on locally is:

Another example is to allow the user to execute the  command as root, regardless of where he is logged in from:

More interesting is to define a set of users who can run software administrative applications (such as and ) on the system and a group of administrators who can change the password of any user, except root!

Ejecución como no root
It is also possible to have a user run an application as a different, non-root user. This can be very interesting if you run applications as a different user (for instance for the web server) and want to allow certain users to perform administrative steps as that user (like killing zombie processes).

Dentro de se lista el o los usuarios entre   y   antes del listado de órdenes:

For instance, to allow to run the  tool as the  or  user:

With this set, the user can run to select the user he wants to run the application as:

Mediante la directiva  se puede establecer un alias para el usuario con el que se va a lanzar una aplicación. Su uso es idéntico al de otras directivas  mostradas anteriormente.

Contraseñas y configuraciones por defecto
By default, asks the user to identify himself using his own password. Once a password is entered, remembers it for 5 minutes, allowing the user to focus on his tasks and not repeatedly re-entering his password.

Este comportamiento, por supuesto, se puede cambiar: se puede establecer la directiva  en   para cambiar el comportamiento por defecto para un usuario.

Por ejemplo, para cambiar los cinco minutos preestablecidos a cero (no recordarla nunca):

Definiendo la opción a  permite recordar la contraseña indefinidamente (hasta que se reinicie el sistema).

A different setting would be to require the password of the user that the command should be run as and not the users' personal password. This is accomplished using. In the following example we also set the number of retries (how many times the user can re-enter a password before fails) to   instead of the default 3:

Otra característica interesante es mantener definida la variable  de modo que se puedan lanzar herramientas gráficas:

You can change dozens of default settings using the  directive. Fire up the manual page and search for.

Si, no obstante, desea permitir a cierto usuario lanzar un conjunto de órdenes sin proporcionar ningún tipo de contraseña, necesita entonces lanzar las órdenes con, así:

Completado de órdenes en bash
Los usuarios que quieran tener completado de órdenes en bash con sudo, tendrán que lanzar esto una sola vez.

Completado de órdenes en zshell
Los usuarios que deseen completado de órdenes en zsh para sudo pueden definir lo siguiente en y en  respectivamente.

Con el cambio de arriba, todas las órdenes en las localizaciones, y  estarán disponibles al intérprete de órdenes para completado cuando a la orden se le anteponga 'sudo'.

Listar privilegios
To inform yourself what your capabilities are, run :

Si tiene cualquier orden en que no le pida que introduzca una contraseña, tampoco se le pedirá una contraseña para listar las entradas. De no ser así, se le podría pedir su contraseña si no se recuerda.

Prolongar la caducidad de la contraseña
By default, if a user has entered their password to authenticate their self to, it is remembered for 5 minutes. If the user wants to prolong this period, he can run to reset the time stamp so that it will take another 5 minutes before  asks for the password again.

The inverse is to kill the time stamp using.