Skip to content

Sudo

sudo 권한 수정

sudo와 관련된 권한은 /etc/sudoers파일에 적용되어 있다. 이 파일은 vi를 사용하면 안되고, visudo를 사용하거나 sudoedit를 사용해야 한다.

sudo PATH 수정

sudo를 사용했을 경우 설정되는 PATH/etc/sudoers파일에서 아래의 내용을 사용하여 변경할 수 있다.

Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

사용자 정보

sudo 이후 SUDO_GID, SUDO_USER, SUDO_UID 환경변수를 사용하면 sudo를 사용한 사용자 정보를 획득할 수 있다.

Flags

-H
Stackoverflow: What is the -H flag for pip?
The -H (HOME) option requests that the security policy set the HOME environment variable to the home directory of the target user (root by default) as specified by the password database. Depending on the policy, this may be the default behavior.
-E, --preserve-env
Indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the user does not have permission to preserve the environment.

How to use

Add user

특정 사용자가 sudo를 사용할 수 있하는 설정:

devtainer       ALL=(ALL)       ALL

Add group

그룹에 포함된 모든 사용자가 sudo를 사용할 수 있하는 설정

%wheel        ALL=(ALL)       ALL

Skip password

패스워드 생략 설정

%wheel        ALL=(ALL)       NOPASSWD: ALL
devtainer        ALL=(ALL)       NOPASSWD: ALL

Mount & UnMount

sudo를 사용하여 cd mount, umount 가능하도록 설정

%users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

See also

Favorite site