Sudo/ko

명령은 일반 사용자가 암호를 입력하지 않고도 가능하게 루트 권한으로 몇가지(또는 전부의)명령을 실행하는 등의 상황에서 권한 상승을 설정하는 간단하고 안전한 수단을 제공합니다.

일부 사용자에게 루트 권한을 전부 주지 않고도 시스템의 관리 과정을 수행하도록 하려면 sudo를 사용하는 것이 가장 탁월한 선택입니다. sudo를 통해서라면 누가 무엇을 할 수 있을지 통제할 수 있습니다. 이 안내서에서는 이 멋진 수단에 대한 간단한 소개를 드리고자 합니다.

이 글은 간단한 소개글을 의도합니다. 꾸러미는 여기서 언급한 내용보다 훨씬 더 강력한 기능을 보유하고 있습니다. 다른 사용자 처럼 파일을 편집하는 기능, 스크립트 내에서 실행하는(따라서 백그라운드에서 실행하거나 키보드 대신 표준 입력을 통해 암호 입력을 받을 수 있음), 등의 기능이 있습니다.

더 많은 내용은 sudo 와 sudoers 설명서 페이지를 읽어보십시오.

활동 기록
의 또 다른 장점은 프로그램을 실행하는 어떤 시도 과정(성공/실패)을 기록할 수 있다는 점입니다. 누가 10시간동안 삽질하도록 치명적인 실수를 했는지 추적할 때 유용합니다 :&#41;

권한 부여
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 sudo gives a more fine-grained control on who can execute a certain command and when.

With sudo 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 sudo configuration is managed by the file. This file should never be edited through nano /etc/sudoers or vim /etc/sudoers or any other editor you might like. When you want to alter this file, you should use visudo.

This tool makes sure that no two system administrators are editing this file at the same time, preserves the permissions on the file and performs some syntax checking to make sure you make no fatal mistakes in the file.

기본 문법
The most difficult part of sudo</tt> is the syntax. The basic syntax is like so:

This syntax tells sudo</tt> 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 larry to execute emerge</tt> 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 wheel</tt> group to execute emerge</tt>:

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 emerge</tt> but also ebuild</tt> and emerge-webrsync</tt> 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 sudo</tt> 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.

시험을 위해 다음 명령을 입력해보겠습니다:

The password that sudo</tt> 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 sudo</tt> does not alter the  variable: any command you place after sudo</tt> is treated from your environment. If you want the user to run a tool in for instance he should provide the full path to sudo</tt>, like so:

LDAP 기본 문법
LDAP 기능을 지원하려면 및  USE 플래그가 필요합니다.

When using sudo with LDAP, sudo will read configuration from LDAP Server as well. So you will need to edit two files.

또한 sudo 에 다음 LDAP 항목을 추가해야 합니다.

sudoer LDAP 설정은 다른 설정을 하는 파일과 비슷합니다. 아래 링크에 있는 sudo LDAP 글을 더 읽어보십시오.

alias (to make a good distinction between aliases and non-aliases it is recommended to use capital letters for aliases). As you might undoubtedly have guessed, the  alias is an alias to all possible settings.

A sample use of the  alias to allow any user to execute the shutdown</tt> command if he is logged on locally is:

Another example is to allow the user larry</tt> to execute the emerge</tt> 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 <tt>emerge</tt> and <tt>ebuild</tt>) on the system and a group of administrators who can change the password of any user, except 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 <tt>apache</tt> for the web server) and want to allow certain users to perform administrative steps as that user (like killing zombie processes).

Inside you list the user(s) in between   and   before the command listing:

For instance, to allow <tt>larry</tt> to run the <tt>kill</tt> tool as the <tt>apache</tt> or <tt>gorg</tt> user:

With this set, the user can run <tt>sudo -u</tt> to select the user he wants to run the application as:

You can set an alias for the user to run an application as using the  directive. Its use is identical to the other  directives we have seen before.

암호 및 기본 설정
By default, <tt>sudo</tt> asks the user to identify himself using his own password. Once a password is entered, <tt>sudo</tt> remembers it for 5 minutes, allowing the user to focus on his tasks and not repeatedly re-entering his password.

Of course, this behavior can be changed: you can set the  directive in  to change the default behavior for a user.

기본 5분값을 0(기억하지 않음)으로 바꾸려면:

A setting of  would remember the password indefinitely (until the system reboots).

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 <tt>sudo</tt> fails) to  instead of the default 3:

Another interesting feature is to keep the  variable set so that you can execute graphical tools:

You can change dozens of default settings using the  directive. Fire up the <tt>sudoers</tt> manual page and search for.

If you however want to allow a user to run a certain set of commands without providing any password whatsoever, you need to start the commands with, like so:

배시 자동 완성
sudo에 bash 명령 완성 기능을 사용하려는 사용자는 다음 명령을 한번 실행하십시오.

Z쉘 명령 완성
sudo에 zsh 명령 완성 기능을 사용하려는 사용자는 와 에 각각 다음 내용을 설정할 수 있습니다

위 내용으로 바꾸면,, , 위치에 있는 값은 'sudo' 다음에 놓은 명령에 대한 명령 완성 기능을 쉘에서 사용할 수 있습니다.

권한 확인
자신의 권한을 알아보려면 를 실행하십시오:

에 암호를 입력할 필요가 없는 명령이 있다면, 항목에 있는 명령에 암호를 요구하지 않습니다. 그렇지 않아 항목에 없어 기억하지 않으면 암호를 물어봅니다.

암호 입력 제한 시간 미리 연장
기본적으로 사용자가 로 자신의 암호로 진입하면 5초간 기억합니다. 사용자가 이 기간보다 더 길게 세션을 유지하길 바란다면 에서 암호를 다시 묻기 전에 명령을 실행하여 타임 스탬프를 다시 설정하고, 5분을 다시 세도록 할 수 있습니다.

반대로, 명령으로 타임스탬프를 없앨 수 있습니다.