2014년 9월 4일 목요일

rhel 7 레드햇 리눅스 7.0 유저 su switch user 관리하기

일반 유저는 su 를 통해서 root user로 계정 변경이 가능하며

이를 통해 시스템에 대한 절대적 권한을 지니게 된다.

이러한 이유 때문에 su 권한을 지니는 유저를 별도의 그룹으로 분류해야한다. 

su 가능한 유저 그룹으로 추가하는 가장 간단한 방법은 해당 유저를 wheel그룹에 생성하는 것이다. wheel 그룹은 시스템에 기본으로 존재하는 그룹이며 su 권한을 주기 위해 생성되었다. 

usermod 명령어를 통해 해당 유저를 wheel 그룹으로 추가한다. 

usermod -G wheel <username>

이후에 허용된 wheel그룹의 유저만 su 커맨드를 사용할 수 있도록 하기 위해 
/etc/pam.d/su파일의 아래 auth값의 주석을 제거한다.  

#auth required pam_wheel.so use_uid 

해당 주석의 제거는 오직 wheel 그룹 안에 있는 유저만 su커맨드를 통해 다른 유저로 switch할 수 있음을 의미한다.

root 유저의 경우 default로 wheel 그룹에 포함되어있다. 

rhel 7 레드햇 리눅스 7.0 유저 user 그룹 group 계정 관리

리눅스 7.0에서의 유저 및 그룹 계정 관리는 기존 버전과 크게 다르지 않다.

user add 명령어를 사용하여 유저를 추가한다.

useradd [option] username 

user add 로 생성한 계정은 locked 된 상태로 생성된다. 
unlock을 위해서 root 계정에서 

passwd username

명령어로 생성한 계정의 password를 생성해야한다.  

useradd 명령어 실행 시 다양한 옵션으로 유저에 대한 권한을 사전에 정의 가능하다. ​

- c 'comment' : 유저에 대한 comment 입력
-d 'home_directory': 유저 로그인 시 home 디렉토리 설정 ( default 값은 /home/username/)
-e date : 유저계정의 사용가능 기한 설정 
-f days : 패스워드 만료 후 사용 가능한 기간 설정, 0일 시 만료 후 바로 disabled, -1일 경우 만료후에도 계속 사용가능
-g group_name : 유저 계정이 소속될 group설정
-G group_list : 추가 그룹 등록
-m  : home directory가 없을 시 생성한다. 
-M : home directory를 생성하지 않음
-N : 해당 유저에 대한 별도의 개인그룹을 생성하지않음
-p passwd :  useradd시 패스워드도 같이 설정
-r : UID 를 500이하로 생성하고 홈디렉토리 없이 설정 
-s : 유저 로그인 쉘 설정 default 는 /bin/bash
-u uid : uid설정한다. 499보다 커야한다.


  • useradd(8) — The manual page for the useradd command documents how to use it to create new users.
  • userdel(8) — The manual page for the userdel command documents how to use it to delete users.
  • usermod(8) — The manual page for the usermod command documents how to use it to modify users.
  • groupadd(8) — The manual page for the groupadd command documents how to use it to create new groups.
  • groupdel(8) — The manual page for the groupdel command documents how to use it to delete groups.
  • groupmod(8) — The manual page for the groupmod command documents how to use it to modify group membership.
  • gpasswd(1) — The manual page for the gpasswd command documents how to manage the /etc/group file.
  • grpck(8) — The manual page for the grpck command documents how to use it to verify the integrity of the /etc/group file.
  • pwck(8) — The manual page for the pwck command documents how to use it to verify the integrity of the /etc/passwdand /etc/shadow files.
  • pwconv(8) — The manual page for the pwconv command documents how to use it to convert standard passwords to shadow passwords.
  • pwunconv(8) — The manual page for the pwunconv command documents how to use it to convert shadow passwords to standard passwords.
For information about related configuration files, see:
  • group(5) — The manual page for the /etc/group file documents how to use this file to define system groups.
  • passwd(5) — The manual page for the /etc/passwd file documents how to use this file to define user information.
  • shadow(5) — The manual page for the /etc/shadow file documents how to use this file to set passwords and account expiration information for the system.

rhel 7 레드햇 리눅스 7.0 system locale 시스템 언어 설정

리눅스 7.0 지역 설정은 /etc/locale.conf 파일에 설정되어 있다. 

리눅스 내 한글 텍스트가 정상적으로 출력되지 않을 시 해당 locale.conf 또는 localectl 파일을 설정하면 된다.  

cat /etc/locale.conf
LANG=de_DE.UTF-8
LC_MESSAGES=C 

locale conf는 아래 설정 파일의 파라미터를 설정한다. 일반적으로 LANG만 설정하는 듯
LANG=en_US.utf8

한글 설정이 필요할 시 ko_KR.
LANG = ko_KR.utf8 로 설정

localectl 커맨드를 통해 언어 설정도 가능하다.
localectl status ​입력 시 현재 언어 설정 정보가 출력된다. 
localectl list-locales 입력 시 설정 가능한 언어 리스트가 출력된다.
localectl set-locale 명령어로 locale.conf 파일 수정 대신 설정값 수정이 가능하다.
ex)localectl set-locale LANG=en_GB.utf8

rhel 7 레드햇 리눅스 7.0 부팅 시 init 3 init 5 user level 유저레벨 모드 설정

기존 리눅스 5, 6버전의 경우 부팅 시 해당 유저의 user level변경을 원할 시  

/etc/inittab 파일 안에 

 Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)



id:3:initdefault:
위 숫자 부분을 변경하면 부팅 시 런레벨 변경이 가능했다. 대부분 텔넷모드는 Level 3, GUI X window 모드는 Level 5를 설정한다.  

rhel 7 버전에서는 기존 /etc/inittab 파일을 더이상 사용하지 않는다.  

cat /etc/inittab 을 read할 시 더이상 사용하지 않고, target설정으로 대신한다.  

ln -sf /lib/systemd/system/<target name>.target /etc/systemd/system/default.target

위의 명령어로 /etc/systemd/system/default.target 에 자신이 원하는 target를 link시키면 된다.  

runlevel 3 : multi-user.target
runlevel 5 : graphical.target

/ib/systemd/system 폴더 안에 다양한 target파일들이 있다.