RadarURL

유닉스/리눅스
2014.05.27 03:02

sudo 사용자 등록 (in CentOS)

조회 수 2186 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

sudo 사용자 등록 (in CentOS)

일반 사용자가 루트 권한을 획득하기 위해서는 su 명령을 사용해야 합니다. 사실 매번
루트 권한을 얻기 위해서 su를 수행하는 것은 불편하죠. Ubunto를 사용할 때 가장 편
리한 명령은 아마도 sudo일 것입니다. sudo는 일반사용자가 루트 권한을 임시적으로 획득하여 특정 명령을 할 수 있도록 합니다.

Ubuntu에서는 처음부터 일반 사용자가 sudo를 사용할 수 있도록 되어 있지만 CentOS >등 다른 리눅스 배포판에서는 sudo를 기본적으로 사용할 수 없도록 되어 있습니다.

[was@centos ~]$ sudo more /etc/sysctl.conf
[sudo] password for was:
was is not in the sudoers file.  This incident will be reported.
[was@centos ~]$

위 예를 보면 weblogic 사용자는 sudoers 파일에 등록되어 있지 않기 때문에 sudo를 사용할 수 없다는 메세지를 확인할 수 있습니다.

일반사용자가 sudo 명령어를 사용하기 위해서는 /etc/sudoers에 등록되어 있어야 합니다.

/etc/sudoers에 일반 사용자를 등록하는 방법은 다음과 같습니다.

  1. root로 사용자 전환 (su -)
  2. /etc/sudoers의 파일 permission 변경
    • chmod u+w /etc/sudoers
  3. /etc/sudoers에 일반 사용자 등록
  4. /etc/sudoers 퍼미션 원복
    • /etc/sudoers는 440 퍼미션이어야 함
    • chmod u-w /etc/sudoers
  5. sudo 테스트


/etc/sudoers의 초기 퍼미션은 다음과 같습니다.

1[devtainer@centos ~]$ ls -al /etc/sudoers
2-r--r----- 1 root root 3217 316 14:09 /etc/sudoers

파일 수정을 위하여 /etc/sudoers의 퍼미션을 수정해야 합니다. (root 전환 후 퍼미션 변경)

1[devtainer@centos ~]$ su -
2암호:
3[root@centos ~]# chmod u+w /etc/sudoers
4[root@centos ~]# ls -al /etc/sudoers
5-rw-r----- 1 root root 3217 316 14:09 /etc/sudoers

/etc/sudoers에 사용자 등록 방법은 다음과 같습니다. 다음과 같은 설정을 /etc/sudoers의 하단에 추가하면 설정은 완료됩니다.

case 1. 특정 사용자가 sudo를 사용할 수 있하는 설정
devtainer       ALL=(ALL)       ALL

case 2. 그룹에 포함된 모든 사용자가 sudo를 사용할 수 있하는 설정
%wheel        ALL=(ALL)       ALL

case 3. 패스워드 생략 설정
%wheel        ALL=(ALL)       NOPASSWD: ALL
devtainer        ALL=(ALL)       NOPASSWD: ALL

case 4. sudo를 사용하여 cd 마운트, 언마운트 가능하도록 설정
%users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
#users 그룹의 멤버는 sudo를 사용하여 cd롬 마운트와 언마운트만 허용

이제 사용자 등록이 완료된 상태 입니다. /etc/sudoers 의 퍼미션은 440이어야 합니다. 다음과 같이 퍼미션이 440이 아닐 경우에 에러가 발생됩니다. /etc/sudoers파일의 퍼미션을 440으로 변경하면 sudo명령이 정상적으로 동작하는 것을 확인할 수 있습니다.

01[devtainer@centos ~]$ sudo tail /etc/sudoers
02sudo: /etc/sudoers is mode 0640, should be 0440
03sudo: no valid sudoers sources found, quitting
04[devtainer@centos ~]$ su -
05암호:
06[root@centos ~]# chmod u-w /etc/sudoers
07[root@centos ~]# su - devtainer
08[devtainer@centos ~]$ sudo tail /etc/sudoers
09[sudo] password for devtainer:
10# %wheel ALL=(ALL) NOPASSWD: ALL
11
12## Allows members of the users group to mount and unmount the
13## cdrom as root
14# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
15
16## Allows members of the users group to shutdown this system
17# %users localhost=/sbin/shutdown -h now
18devtainer ALL=(ALL) ALL

 

출처 : http://devtainer.blogspot.kr/2011/03/sudo-in-centos_16.html

TAG •
?

공부 게시판

공부에 도움되는 글을 올려주세요.

  1. [공지] 공부 게시판 입니다.

    Date2003.08.18 By처누 Views947528
    read more
  2. [Rocky Linux 9] /home 용량 줄이고 /root 용량 늘리기

    Date2026.04.03 Category유닉스/리눅스 ByJaeSoo Views7
    Read More
  3. [Rocky Linux] LVM 환경에서 /root 파티션 공간 부족 해결

    Date2026.04.03 Category유닉스/리눅스 ByJaeSoo Views4
    Read More
  4. 일반적인 Htaccess 301 리디렉션 규칙

    Date2026.04.01 Category웹서버,WAS ByJaeSoo Views9
    Read More
  5. [Linux/Rocky] SSH Root 로그인하는 방법 (root 접속 허용)

    Date2026.04.01 Category유닉스/리눅스 ByJaeSoo Views11
    Read More
  6. MariaDB my.cnf 설정 파일

    Date2026.03.03 Category데이터베이스 ByJaeSoo Views50
    Read More
  7. MariaDB 설정 파일 개요와 구조

    Date2026.03.03 Category데이터베이스 ByJaeSoo Views41
    Read More
  8. 윈도우11 비밀번호 분실시 설정 변경방법 (Windows10 포함)

    Date2025.11.06 Category윈도우즈 ByJaeSoo Views699
    Read More
  9. 리눅스 서버 설치 중 에러 "Failed to find a suitable stage1 device"

    Date2025.10.03 Category유닉스/리눅스 ByJaeSoo Views886
    Read More
  10. Linux 11 . Linux 설치 시 lvm 수동설정

    Date2025.10.03 Category유닉스/리눅스 ByJaeSoo Views791
    Read More
  11. [Rocky Linux] 누구나 쉽게 따라하는 Rocky Linux 9.0 OS 다운로드 및 설치 방법~!!

    Date2025.10.03 Category유닉스/리눅스 ByJaeSoo Views757
    Read More
  12. Linux/Rocky Linux Rocky Linux : Composer 설치

    Date2025.09.29 Category유닉스/리눅스 ByJaeSoo Views1018
    Read More
  13. [Rocky Linux] 록키 리눅스 최신 업데이트 적용 방법

    Date2025.09.29 Category유닉스/리눅스 ByJaeSoo Views897
    Read More
  14. rocky linux 커널 업데이트

    Date2025.09.29 Category유닉스/리눅스 ByJaeSoo Views794
    Read More
  15. [Windows] OWASP ZAP 사용법

    Date2025.09.29 Category웹서버,WAS ByJaeSoo Views796
    Read More
  16. [웹 취약점] 웹서버 디렉토리 리스팅 방지

    Date2025.09.29 Category웹서버,WAS ByJaeSoo Views701
    Read More
  17. Clonezilla(클론질라) 백업파일 하드디스크로 복구 방법

    Date2025.09.28 Category유닉스/리눅스 ByJaeSoo Views878
    Read More
  18. 클론질라 사용 방법 - OS 이미지 백업 CloneZilla

    Date2025.09.28 Category유닉스/리눅스 ByJaeSoo Views836
    Read More
  19. [Linux / Rocky] FTP 접속 관련 설정 실습 예제

    Date2025.09.23 Category유닉스/리눅스 ByJaeSoo Views936
    Read More
  20. Could not reliably determine the server's fully qualified domain name

    Date2025.09.23 Category유닉스/리눅스 ByJaeSoo Views993
    Read More
  21. [아파치] 아파치 웹서버에 .htaccess 파일 설정하는 방법

    Date2025.09.23 Category유닉스/리눅스 ByJaeSoo Views895
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 35 Next
/ 35


즐겨찾기 (가족)

JAESOO's HOMEPAGE


YOUNGAE's HOMEPAGE


장여은 홈페이지


장여희 홈페이지


장여원 홈페이지


즐겨찾기 (업무)

알리카페 홀릭

숭실대 컴퓨터 통신연구실 (서창진)

말레이시아 KL Sentral 한국인 GuestHouse


즐겨찾기 (취미)

어드민아이디

유에코 사랑회

아스가르드 좋은사람/나쁜사람

JServer.kr

제이서버 메타블로그

재수 티스토리


즐겨찾기 (강의, 커뮤니티)

재수 강의 홈페이지


한소리


VTMODE.COM


숭실대 인공지능학과


숭실대 통신연구실


베너