본문 바로가기

리눅스

[리눅스] sudo 사용법

728x90

sudo 사용법

sudo 패키지 확인

rpm -qa | grep sudo
$ rpm -qa | grep sudo
sudo-1.6.7p5-30.1.3

sudo 설정 파일 확인

vim /etc/sudoers
$ cat /etc/sudoers
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
# Defaults specification

# User privilege specification
root ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now

sudo 설정 파일 편집

- visudo 명령어로 파일 편집하면 문법체크까지 해준다.

- scbyun ALL=(ALL) NOPASSWD: ALL

visudo
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification
# User alias specification
# Cmnd alias specification
# Defaults specification

# User privilege specification
root ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now

scbyun ALL=(ALL) NOPASSWD: ALL

scbyun 계정에 모든 권한을 부여하고 있다.

 

scbyun 계정으로 로그인 한다.

sudo reboot

 

728x90