본문 바로가기

Infra Architecture/linux

[ Linux ] sudo 권한 주기

반응형

sudo 권한주기

'usermod -a -G sudo userid' 를 통해 sudo권한을 줄 수 있다. 아래 duru계정이 sudo그룹에 속해있지 않아 sudo명령 처리가 안되었다가 sudo그룹에 속한 이후 sudo명령이 정상처리됨을 확인할 수 있다. 
duru@ykd2:/etc/security$ id
uid=1001(duru) gid=1001(duru) groups=1001(duru)

duru@ykd2:/etc/security$ sudo cat /etc/security/access.conf
[sudo] password for duru:
duru is not in the sudoers file.  This incident will be reported.

duru@ykd2:/etc/security$ su test
Password:
test@ykd2:/etc/security$ sudo usermod -a -G sudo duru

test@ykd2:/etc/security$ su duru
Password:
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

duru@ykd2:/etc/security$ id
uid=1001(duru) gid=1001(duru) groups=1001(duru),27(sudo)
duru@ykd2:/etc/security$ sudo cat /etc/security/access.conf
[sudo] password for duru:
# Login access control table.
.................중략...................
# All other users should be denied to get access from all sources.
#-:ALL:ALL
sudo그룹에 속해 있을때 sudo명령을 내릴 수 있는 이유는 /etc/sudoers 설정파일에 sudo그룹이 포함되어있기 때문이다.
duru@ykd2:/etc/security$ sudo cat /etc/sudoers
# This file MUST be edited with the 'visudo' command as root.
.................중략...................
# User privilege specification
root    ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
duru@ykd2:/etc/security$
반응형

'Infra Architecture > linux' 카테고리의 다른 글

[ Linux ] ifconfig  (0) 2023.01.08
[ Linux ] DNS 확인  (0) 2023.01.08
[ Linux ] 유저 생성  (0) 2023.01.08
[ Linux ] Shell Script 산술연산/조건문  (0) 2023.01.07
[ Shell Script ] awk 명령어  (0) 2023.01.07