댓글 쓰기 권한이 없습니다. 로그인 하시겠습니까?
LINUX
2016.03.21 08:45
리눅스 계정 목록 보기
조회 수 8990 댓글 0
전체 목록
cat /etc/passwd cut -f1 -d: /etc/passwd
[root@zetawiki ~]# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin .. (생략) named:x:25:25:Named:/var/named:/sbin/nologin [root@zetawiki ~]# cut -f1 -d: /etc/passwd root bin daemon .. (생략) named bash 사용자 목록[편집]useradd로 계정을 만들면 기본적으로 /bin/bash 환경이 적용된다. bash 사용자 목록이 의미 있는 경우가 많다.
grep /bin/bash /etc/passwd grep /bin/bash /etc/passwd | cut -f1 -d:
[root@zetawiki ~]# grep /bin/bash /etc/passwd root:x:0:0:root:/root:/bin/bash mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash [root@zetawiki ~]# grep /bin/bash /etc/passwd | cut -f1 -d: root mysql 일반 사용자 목록useradd 명령어로 생성되는 일반 사용자 계정은 UID가 500 이상이다.UID 500 이상
awk -F':' '{if($3>=500)print $1}' /etc/passwd
[root@zetawiki ~]# tail -6 /etc/passwd saslauth:x:499:76:"Saslauthd user":/var/empty/saslauth:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin devuser:x:500:500::/home/devuser:/bin/bash deployuser:x:501:501::/home/deployuser:/bin/bash testuser:x:502:502::/home/testuser:/bin/bash [root@zetawiki ~]# awk -F':' '{if($3>=500)print $1}' /etc/passwd devuser deployuser testuser UID_MIN 이상
u1=$(grep "^UID_MIN" /etc/login.defs | awk '{print $2}') u2=$(grep "^UID_MAX" /etc/login.defs | awk '{print $2}') awk -F':' -v "u1=$u1" -v "u2=$u2" '{ if ( $3>=u1 && $3<=u2 ) print $0}' /etc/passwd awk -F':' -v "u1=$u1" -v "u2=$u2" '{ if ( $3>=u1 && $3<=u2 ) print $1}' /etc/passwd
[root@zetawiki ~]# u1=$(grep "^UID_MIN" /etc/login.defs | awk '{print $2}') [root@zetawiki ~]# u2=$(grep "^UID_MAX" /etc/login.defs | awk '{print $2}') [root@zetawiki ~]# awk -F':' -v "u1=$u1" -v "u2=$u2" '{ if ( $3>=u1 && $3<=u2 ) print $0}' /etc/passwd devuser:x:500:500::/home/devuser:/bin/bash deployuser:x:501:501::/home/deployuser:/bin/bash testuser:x:502:502::/home/testuser:/bin/bash [root@zetawiki ~]# awk -F':' -v "u1=$u1" -v "u2=$u2" '{ if ( $3>=u1 && $3<=u2 ) print $1}' /etc/passwd devuser deployuser testuser bash 및 일반 사용자 계정 목록
a=$(grep ^UID_MIN /etc/login.defs | awk '{print $2}') b=$(grep ^UID_MAX /etc/login.defs | awk '{print $2}') c=$(grep /bin/bash /etc/passwd | awk -F':' '{print $1}') d=$(awk -F':' -v "a=$a" -v "b=$b" '{ if ( $3>=a && $3<=b ) print $1}' /etc/passwd) echo -e "$c\n$d" | sort | uniq
[root@zetawiki ~]# a=$(grep ^UID_MIN /etc/login.defs | awk '{print $2}') [root@zetawiki ~]# b=$(grep ^UID_MAX /etc/login.defs | awk '{print $2}') [root@zetawiki ~]# c=$(grep /bin/bash /etc/passwd | awk -F':' '{print $1}') [root@zetawiki ~]# d=$(awk -F':' -v "a=$a" -v "b=$b" '{ if ( $3>=a && $3<=b ) print $1}' /etc/passwd) [root@zetawiki ~]# echo -e "$c\n$d" | sort | uniq root devuser deployuser testuser [root@zetawiki ~]# c=$(grep /bin/bash /etc/passwd | awk -F':' '{print $0}') [root@zetawiki ~]# d=$(awk -F':' -v "a=$a" -v "b=$b" '{ if ( $3>=a && $3<=b ) print $0}' /etc/passwd) [root@zetawiki ~]# echo -e "$c\n$d" | sort | uniq root:x:0:0:root:/root:/bin/bash devuser:x:500:500::/home/devuser:/bin/bash deployuser:x:501:501::/home/deployuser:/bin/bash testuser:x:502:502::/home/testuser:/bin/bash Dreamy의 코드 스크랩내가 모으고 내가 보는
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Designed by sketchbooks.co.kr / sketchbook5 board skin
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5