본문 바로가기

나의 IT

Arch Linux SUDO 설치하기

Arch Linux를 쓰면서 왜 sudo 가 없는지 심히 궁금했습니다.

설정할때마다 root 계정으로 로그인 한다는건 정말 위험천만한 일이고 보안에도 좋지 못한 습관이기에 sudo를 써서 처리하는게 좋습니다.

(그동안 모든 리눅스 기반 머신에서 아무 생각없이 sudo를 써서 /sbin/ 에 들어있는줄 알았지만… 아니였습니다)

 

한글화는 시간날때 하겠습니다.

기본적으로

 

설치:

pacman -S sudo

 

sudo를 서용할 사용자 추가:

/etc/sudoers 파일을 수정

## User privilege specification
##
root ALL=(ALL) ALL

root 밑에 sudo를 허용할 사용자를 추가. 기타 그룹허용, 전체허용 등등은 하단의 설정을 참고.

 

https://wiki.archlinux.org/index.php/Samba 

Installation

Install the sudo package, available in the official repositories:

# pacman -S sudo

To begin using sudo as a non-privileged user, it must be properly configured. So make sure you read the configuration section.

Usage

With sudo, users can prefix commands with sudo to run them with superuser (or other) privileges.

For example, to use pacman:

$ sudo pacman -Syu

See the sudo manual for more information.

Configuration

View current settings

Run sudo -ll to print out the current sudo configuration.

Using visudo

The configuration file for sudo is /etc/sudoers. It should always be edited with the visudo command. visudo locks the sudoers file, saves edits to a temporary file, and checks that file's grammar before copying it to /etc/sudoers.

Warning: It is imperative that sudoers be free of syntax errors! Any error makes sudo unusable. Always edit it with visudo to prevent errors.

The default editor for visudo is vi. It will be used if you do not specify another editor, by setting either VISUAL or EDITOR environment variables (used in that order) to the desired editor, e.g. vim. The command is run as root:

# VISUAL="/usr/bin/vim -p -X" visudo

You can permanently change the setting system-wide to e.g. vim by appending:

export VISUAL="/usr/bin/vim -p -X"

to your ~/.bashrc file. Note that this won't take effect for already-running shells.

To change the editor of choice permanently only for visudo, add the following line to /etc/sudoers where vim is your prefered editor:

# Reset environment by default
Defaults      env_reset
# Set default EDITOR to vim, and do not allow visudo to use EDITOR/VISUAL.
Defaults      editor="/usr/bin/vim -p -X", !env_editor