RadarURL
Skip to content
조회 수 2193 추천 수 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 3217316 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 3217316 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 •
?

List of Articles
번호 제목 글쓴이 날짜 조회 수
» sudo 사용자 등록 (in CentOS) JAESOO 2014.05.27 2193
61 Xmanager CentOS 설정 : CentOS 4.x, 5.x, 6.x JAESOO 2014.05.27 1661
60 리눅스에서 일반 계정으로 httpd 80포트 실행하기 JAESOO 2014.05.26 1075
59 Xmanager에서 CentOS 5.X 원격Xwindow 띄우기 JAESOO 2014.05.26 1372
58 Apache 파일시스템 권한 설정 JAESOO 2014.05.26 984
57 vi 명령어, vi 단축키, vi(Visual Editer), vim JAESOO 2014.05.26 1068
56 리눅스 파일의 소유자, 소유그룹 변경하기 JAESOO 2014.05.26 1166
55 CentOS 방화벽 설정 하기 JAESOO 2014.05.26 1218
54 Apache HTTP Server, Rewrite가 안되는 경우 JAESOO 2014.05.26 911
53 CentOS - samba 자동실행 JAESOO 2014.05.26 1512
52 vsftp에서 500 OOPS: cannot change directory 오류가 나올 때 JAESOO 2014.05.26 829
51 CentOS samba 공유 폴더 생성하기 JAESOO 2014.05.26 1031
50 CentOS Samba Server 설정 JAESOO 2014.05.26 1254
49 CentOS Samba 설치 및 설정 JAESOO 2014.05.26 1271
48 안전한 CentOS를 위한 방화벽, 보안 설정 JAESOO 2014.05.26 2066
47 CentOS 에 APM 설치하기 JAESOO 2014.05.26 1068
46 Xshell 한글 깨짐 JAESOO 2014.05.26 1002
45 CentOS 5.2 + Xmanager 설정 방법 JAESOO 2014.05.26 1201
44 CentOS X Window + Gnome Desktop 설치 JAESOO 2014.05.26 1286
43 [VMware] CentOS 6.5 설치 (64bit) - GUI(GNOME) JAESOO 2014.05.26 1855
Board Pagination Prev 1 2 3 4 5 6 7 8 9 Next
/ 9

PageViews   Today : 1358 Yesterday : 2356 Total : 21721477  /  Counter Status   Today : 1222 Yesterday : 1688 Total : 1146591

Edited by JAESOO

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소