20160412 리눅스 기초
모의해킹 침해대응 전문가 과정 / 2016. 4. 13. 01:30
2일차
복습
런레벨 리눅스 운영체제의 동작상태
1번 특이사항 2, 3, 5 의 차이정도는 알고 있어야한다
데몬?? 데몬이 뭐지
2번 3번은 텍스트기반은 동일 하지만 네트워크 연결 차이 NFS?? 5번은 그래픽 기반
runlevel 확인 및 조정 명령어
# who -r (# runlevel)
# halt
# init o (# telinit 0) 리눅스가 유닉스의 영향을 받았기 때문에 2가지 다 사용가능
# init o (# telinit 0) 리눅스가 유닉스의 영향을 받았기 때문에 2가지 다 사용가능
[참고] Server Power Off
# halt
# poweroff
# init 0
# shutdown -h now
# halt
# poweroff
# init 0
# shutdown -h now
[참고] Server Reboot
# reboot
# init 6
# shutdown -r now
# reboot
# init 6
# shutdown -r now
언어 확인 & 변경 후에는 재부팅(# reboot)을 해 줘야 한다 나중에 에러가 없다
root 암호를 변경하는 경우
GRUB Menu를 사용
GRUB Menu를 사용
Ctrl + C, Ctrl + D
2일차
0. man CMD & passwd CMD
man CMD
# ls --help
# man ls
man CMD
# ls --help
# man ls
# man ls
# man -k calendar //키워드
# whatis passwd //매뉴얼상 목록번호 확인
# man 5 passwd
# man -k calendar //키워드
# whatis passwd //매뉴얼상 목록번호 확인
# man 5 passwd
passwd CMD
1. 시스템의 기본 정보 확인
uname CMD
# uname -a
# cat /etc/redhat-release //redhat- 이부분은 변경가능 *release 로 대체해서 검색
[참고] 문서 사이트
http://docs.redhat.com/
http://www.centos.org/docs/
http://docs.redhat.com/
http://www.centos.org/docs/
date CMD
# date +%m%d
# date -d '1 day ago' +%m%d
# date +%m%d
# date -d '1 day ago' +%m%d
# rdate -p time.bora.net
# rdate -s time.bora.net
# rdate -s time.bora.net
cal CMD
2. 디렉토리 이동 관련 명령어
pwd CMD
[참고] PS1 변수
# export PS1='[\u@\h \w]\$ ' (~/.bashrc)
cd CMD
PATH
- 상대경로(Relative PATH) # cd dir1
- 절대경로(Absolute PATH) # cd /dir1
# cd -
# cd ../dir1
# cd ../dir1
[참고] 홈디렉토리로 이동
# cd (# cd ~) //~ 가 나의 홈폴더라는 뜻
# cd ~fedora //fedora 사용자의 홈 폴더로 이동
# cd (# cd ~) //~ 가 나의 홈폴더라는 뜻
# cd ~fedora //fedora 사용자의 홈 폴더로 이동
3. 디렉토리 관련 명령어
ls CMD
# ls -l dir1
# ls -ld dir1
OPTIONS: -a, -l, -R, -i, -d, -h, --color, -t, -r
# ls -altr
# alias ls='ls -h' (~/.bashrc)
# alias ls='ls -h' (~/.bashrc)
mkdir CMD
# mkdir -p dir1/dir2/dir3
rmdir CMD
# rm -rf dir1
# mkdir -p dir1/dir2/dir3
rmdir CMD
# rm -rf dir1
4. 파일 관리 명령어
touch CMD
# rouch -t 08301300 file2
cp CMD
# cp file1 file2
# cp file1 dir1
# cp -r dir1 dir2
OPTIONS : -i, -f, -r, -p(preserve), -a
touch CMD
# rouch -t 08301300 file2
cp CMD
# cp file1 file2
# cp file1 dir1
# cp -r dir1 dir2
OPTIONS : -i, -f, -r, -p(preserve), -a
[참고] 로그파일을 내용만 지우는 경우
# cp -f /dev/null file.log
# cat /dev/null > file.log
# > file.log
# cp -f /dev/null file.log
# cat /dev/null > file.log
# > file.log
[참고] 설정 파일을 백업하고 설정하는 경우
# cd /etc/httpd/conf
# cp -a httpd.conf httpd.conf.old
# vi httpd.conf
mv CMD
# mv file1 file2
# mv file1 dir1
# mv dir1 dir2
OPTIONS : -i, -f,
rm CMD
# rm -rf dir1
OPTIONS : -i, -r, -f
# cd /etc/httpd/conf
# cp -a httpd.conf httpd.conf.old
# vi httpd.conf
mv CMD
# mv file1 file2
# mv file1 dir1
# mv dir1 dir2
OPTIONS : -i, -f,
rm CMD
# rm -rf dir1
OPTIONS : -i, -r, -f
[참고] debugfs CMD
5. 파일 내용 확인 명령어
cat CMD
# cat -n file1 (# nl file1)
# cat file1 file2 > file3
cat CMD
# cat -n file1 (# nl file1)
# cat file1 file2 > file3
[참고] strings CMD
more CMD
# CMD | more
# cat /etc/services | more
# ps -ef | more
# rpm -qa | more
# chkconfig --list | more
head CMD
# alias pps='ps -ef | head -1 ; ps -ef | grep xinetd'
tail CMD
# tail -f /var/log/messages
more CMD
# CMD | more
# cat /etc/services | more
# ps -ef | more
# rpm -qa | more
# chkconfig --list | more
head CMD
# alias pps='ps -ef | head -1 ; ps -ef | grep xinetd'
tail CMD
# tail -f /var/log/messages
[참고] 서버 모니터링 명령어
# top (# gnome-system-monitor)
# tail -f /var/log/messages (# gnome-system-log)
# top (# gnome-system-monitor)
# tail -f /var/log/messages (# gnome-system-log)
[참고] 로그 파일 모니터링
# tail -f /var/log/messages
# tail -f /var/log/messages | egrep -i '(warn|err|crit|emerg)'
# tail -f /var/log/messages /var/log/secure
# tail -f /var/log/messages
# tail -f /var/log/messages | egrep -i '(warn|err|crit|emerg)'
# tail -f /var/log/messages /var/log/secure
실습실습 오늘의 실습
리눅스 명령어 형식
# ls -l /var
# 쉘 프롬프트
ls 명령어
-l 옵션
/var 인자
ls 명령어
-l 옵션
/var 인자
스크립트 작성중에 Tab 키 사용하면 자동완성
명령어의 옵션은 자리를 바꾸거나 혹은 합쳐서 사용해도 같은 의미로 동작한다
명령어의 옵션을 약자 형태로 쓰지않기 위해서는 --(double dash) 를 붙인다
# ls -all (# ls -a)
# ls -all (# ls -a)
# man //매뉴얼에 관한 명령어
# man ls //명령어나 파일의 이름으로 검색하는 경우
# man -k calendar //keyword로 검색하는 경우
# whatis passwd //매뉴얼 페이지의 목록을 확인하는 경우
# man 1 passwd //section 번호를 검색하는 경우
간략하게 정보 확인 # ls --help
자세하게 정보 확인 # man ls
space = ctrl+f(foward) 반대로 ctrl+b
/-a 로 시작하는 단어 검색
n 다음 N 이전
n 다음 N 이전
/OPTIONS 검색
/EXAMPLES 검색
h 는 help 명령어가 나온다
q 는 나가는거
# cal 달력을 출력
# whatis passwd 섹션 별로 검색 할 경우 사용 whatis
# info 보다 # pinfo 가 가독성이 더 좋음 웹페이지? 보듯??
# ssh 암호화 로그인 방식 키값을 받아야한다
-a 옵션은 all 모든 옵션 확인할때 추가해준다
[root@linux205 ~]# whatis
usage: whatis keyword ...
[root@linux205 ~]# whatis man
man: nothing appropriate
usage: whatis keyword ...
[root@linux205 ~]# whatis man
man: nothing appropriate
왜 이렇게 나오는것일까??
[root@linux205 ~]# whatis whatis
whatis: nothing appropriate
whatis: nothing appropriate
해결 # makewhatis
[EX2] 명령어를 알지 못하는 경우
# man –k calendar
calendar: nothing appropriate -> 에러메세지가 나오면
처음 –k 옵션을 실행하게 된다면 색인에 대해 생성이 되어있지 않기 때문에 에러 메시지를 출력한다.
# makewhatis
-> 약간 시간이 걸린다.(약 1분 정도) [ 명령어에 대한 색인을 생성한다 ]
# man -k calendar /* -k옵션 뜻 Equivalent to apropos로 적절한 말을 찾아 주는 옵션 */
[EX2] 명령어를 알지 못하는 경우
# man –k calendar
calendar: nothing appropriate -> 에러메세지가 나오면
처음 –k 옵션을 실행하게 된다면 색인에 대해 생성이 되어있지 않기 때문에 에러 메시지를 출력한다.
# makewhatis
-> 약간 시간이 걸린다.(약 1분 정도) [ 명령어에 대한 색인을 생성한다 ]
# man -k calendar /* -k옵션 뜻 Equivalent to apropos로 적절한 말을 찾아 주는 옵션 */
이런식으로 나오게 됨
[root@linux205 ~]# makewhatis
You have mail in /var/spool/mail/root
You have mail in /var/spool/mail/root
[root@linux205 ~]# whatis man
man (1) - format and display the on-line manual pages
man (1) - 온라인 매뉴얼 페이지를 형식화하고 표시
man (1p) - display system documentation
man (7) - macros to format man pages
man (rpm) - 문서 자료 도구 세트: man, apropos 와 whatis.
man-pages (rpm) - Linux 문서화 프로젝트의 Man (메뉴얼) 페이지.
man-pages-ko (rpm) - 한국어 Manpage 프로젝트의 한국어(한글) Man(메뉴얼) 페이지.
man.conf [man] (5) - man을 위한 구성 자료
man.config [man] (5) - configuration data for man
man (1) - format and display the on-line manual pages
man (1) - 온라인 매뉴얼 페이지를 형식화하고 표시
man (1p) - display system documentation
man (7) - macros to format man pages
man (rpm) - 문서 자료 도구 세트: man, apropos 와 whatis.
man-pages (rpm) - Linux 문서화 프로젝트의 Man (메뉴얼) 페이지.
man-pages-ko (rpm) - 한국어 Manpage 프로젝트의 한국어(한글) Man(메뉴얼) 페이지.
man.conf [man] (5) - man을 위한 구성 자료
man.config [man] (5) - configuration data for man
해결 기쁨!!
# date //시스템 시간 출력
# date 07241300 //시스템 시간 변경 날짜4시간4 24시
# date 081613002009 //2009년 8월 16일 13시
# date +%m%d //시간 출력 형태 변경
time.kriss.re.kr //한국표준과학연구원 타임서버
time.bora.net //보라넷 타임서버
[root@linux205 ~]# rdate -p time.bora.net
rdate: timeout for time.bora.net
rdate: timeout for time.bora.net
타임아웃이 뜨는 이유?
강사님이 도움을 주셨음
버츄얼네트워크에디터에서 설정을 좀 손봤음
오토매틱으로 설정한게 가상 리소스를 잡아서
실제 리소스를 잡게끔 변경하고 난 뒤 정상적으로 작동이 된다
버츄얼네트워크에디터에서 설정을 좀 손봤음
오토매틱으로 설정한게 가상 리소스를 잡아서
실제 리소스를 잡게끔 변경하고 난 뒤 정상적으로 작동이 된다
[root@linux205 ~]# rdate -s time.bora.net
[root@linux205 ~]# rdate -p time.bora.net
rdate: [time.bora.net] Tue Apr 12 18:55:12 2016
[root@linux205 ~]# rdate -p time.bora.net
rdate: [time.bora.net] Tue Apr 12 18:55:12 2016
해결 기쁨!!
[root@linux205 ~]# date +%m%d_%H%M
0816_1304
0816_1304
`커맨드` ' 이게 아니라 `
[root@linux205 ~]# cd /test
[root@linux205 test]# touch file_`date +%m%d`.log
[root@linux205 test]# ls -l
합계 70020
-r--r--r-- 1 root root 71613955 4월 12 2016 VMwareTools-10.0.1-3160059.tar.gz
-rw-r--r-- 1 root root 3 4월 11 2016 file1
-rw-r--r-- 1 root root 0 8월 16 13:05 file_0816.log
drwxr-xr-x 9 root root 4096 10월 19 2015 vmware-tools-distrib
[root@linux205 test]# date -d '1 day ago' +%m%d
0815
0815
오늘 날짜 기준에서 1일 전 2 day ago 면 2일 전
[root@linux205 test]# cal 2002
2002
1월 2월 3월
일 월 화 수 목 금 토 일 월 화 수 목 금 토 일 월 화 수 목 금 토
1 2 3 4 5 1 2 1 2
6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9
13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16
20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23
27 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30
31
4월 5월 6월
일 월 화 수 목 금 토 일 월 화 수 목 금 토 일 월 화 수 목 금 토
1 2 3 4 5 6 1 2 3 4 1
7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8
14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15
21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22
28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29
30
7월 8월 9월
일 월 화 수 목 금 토 일 월 화 수 목 금 토 일 월 화 수 목 금 토
1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7
7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14
14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21
21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28
28 29 30 31 25 26 27 28 29 30 31 29 30
일 월 화 수 목 금 토 일 월 화 수 목 금 토 일 월 화 수 목 금 토
1 2 3 4 5 1 2 1 2
6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9
13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16
20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23
27 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30
31
4월 5월 6월
일 월 화 수 목 금 토 일 월 화 수 목 금 토 일 월 화 수 목 금 토
1 2 3 4 5 6 1 2 3 4 1
7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8
14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15
21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22
28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29
30
7월 8월 9월
일 월 화 수 목 금 토 일 월 화 수 목 금 토 일 월 화 수 목 금 토
1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7
7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14
14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21
21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28
28 29 30 31 25 26 27 28 29 30 31 29 30
10월 11월 12월
일 월 화 수 목 금 토 일 월 화 수 목 금 토 일 월 화 수 목 금 토
1 2 3 4 5 1 2 1 2 3 4 5 6 7
6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14
13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21
20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28
27 28 29 30 31 24 25 26 27 28 29 30 29 30 31
일 월 화 수 목 금 토 일 월 화 수 목 금 토 일 월 화 수 목 금 토
1 2 3 4 5 1 2 1 2 3 4 5 6 7
6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14
13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21
20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28
27 28 29 30 31 24 25 26 27 28 29 30 29 30 31
[root@linux205 test]# cal 6 2002
6월 2002
일 월 화 수 목 금 토
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
pwd print working directory
cd change directory
[root@linux205 ~]# pwd
/root
[root@linux205 ~]# cd /test
[root@linux205 test]# pwd
/test
[root@linux205 test]# cd
[root@linux205 ~]# pwd
/root
/root
[root@linux205 ~]# cd /test
[root@linux205 test]# pwd
/test
[root@linux205 test]# cd
[root@linux205 ~]# pwd
/root
[root@linux205 ~]# echo $PS1
[\u@\h \W]\$
[\u@\h \W]\$
\u 유저네임
\h 호스트네임
\W 마지막경로
\$ root 면 # 일반사용자면 $으로 표시
\h 호스트네임
\W 마지막경로
\$ root 면 # 일반사용자면 $으로 표시
[root@linux205 ~]# PS1='a '
a PS1='[\u@\h \W]\$ '
[root@linux205 ~]#
a PS1='[\u@\h \W]\$ '
[root@linux205 ~]#
[root@linux205 ~]# gedit ~/.bashrc
------------------------------------------------------------------------
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
#
# Sfecific Configuration
#
export PS1='[\u@\h \w]\$ '
# Sfecific Configuration
#
export PS1='[\u@\h \w]\$ '
------------------------------------------------------------------------
[root@linux205 ~]# . ~/.bashrc
[root@linux205 ~]# echo $PS1
[\u@\h \w]\$
[root@linux205 ~]# cd /test
[root@linux205 /test]# //현재작업경로(pwd)가 표시
[root@linux205 ~]# echo $PS1
[\u@\h \w]\$
[root@linux205 ~]# cd /test
[root@linux205 /test]# //현재작업경로(pwd)가 표시
경로(PATH) /가 없으면 상대경로 /가 있으면 절대경로
[root@linux205 /test]# cd /etc
[root@linux205 /etc]# cd sysconfig/
[root@linux205 /etc/sysconfig]# cd network-scripts/
[root@linux205 /etc]# cd sysconfig/
[root@linux205 /etc/sysconfig]# cd network-scripts/
[root@linux205 /etc/sysconfig/network-scripts]# cd ../../
[root@linux205 /etc]#
[root@linux205 /etc]#
[root@linux205 /etc]# cd /tmp
[root@linux205 /tmp]# cd /etc/sysconfig/
[root@linux205 /etc/sysconfig]#
[root@linux205 /tmp]# cd /etc/sysconfig/
[root@linux205 /etc/sysconfig]#
root 사용자의 경우
[root@linux205 ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@linux205 ~]# cd
[root@linux205 ~]# pwd
/root
[root@linux205 ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@linux205 ~]# cd
[root@linux205 ~]# pwd
/root
fedora 사용자의 경우
[root@linux205 ~]# ssh fedora@localhost
fedora@localhost's password:
Last login: Tue Apr 12 16:32:21 2016 from linux205.example.com
[fedora@linux205 ~]$ id
uid=500(fedora) gid=500(fedora) groups=500(fedora)
[fedora@linux205 ~]$ pwd
/home/fedora
cd ~사용자 //사용자의 홈폴더로 이동
[root@linux205 ~]# cd ~fedora
[root@linux205 /home/fedora]# pwd
/home/fedora
[root@linux205 ~]# cd ~fedora
[root@linux205 /home/fedora]# pwd
/home/fedora
[참고] # cd ~fedora 와 # cd ~/fedora 는 다르다
[root@linux205 ~]# cd ~/fedora
bash: cd: /root/fedora: 그런 파일이나 디렉토리가 없음
[root@linux205 ~]# cd ~/fedora
bash: cd: /root/fedora: 그런 파일이나 디렉토리가 없음
[root@linux205 ~]# cd /etc
[root@linux205 /etc]# cd /etc/sysconfig/network-scripts/
[root@linux205 /etc/sysconfig/network-scripts]# cd /etc
[root@linux205 /etc]# cd -
/etc/sysconfig/network-scripts
[root@linux205 /etc/sysconfig/network-scripts]# cd -
/etc
[root@linux205 /etc]# cd -
/etc/sysconfig/network-scripts
[root@linux205 /etc/sysconfig/network-scripts]#
[root@linux205 /etc]# cd /etc/sysconfig/network-scripts/
[root@linux205 /etc/sysconfig/network-scripts]# cd /etc
[root@linux205 /etc]# cd -
/etc/sysconfig/network-scripts
[root@linux205 /etc/sysconfig/network-scripts]# cd -
/etc
[root@linux205 /etc]# cd -
/etc/sysconfig/network-scripts
[root@linux205 /etc/sysconfig/network-scripts]#
- 이전 디렉토리를 의미
dir 과 ls 가 뭐가 다르지? ls는 색이 나오는데
VM 스냅샷 기능 고스트와 유사 이미지 백업의 기능 정도?
동일수준의 폴더로 이동하는 기능 # cd ../폴더이름
[root@linux205 /test]# mkdir dir1 dir2
[root@linux205 /test]# ls
dir1 dir2
[root@linux205 /test]# cd dir2
[root@linux205 /test/dir2]# pwd
/test/dir2
[root@linux205 /test/dir2]# cd ..
[root@linux205 /test]# ls
dir1 dir2
[root@linux205 /test]# cd dir1
[root@linux205 /test/dir1]# cd ../dir2
[root@linux205 /test/dir2]# cd ../dir1
[root@linux205 /test/dir1]# pwd
/test/dir1
[root@linux205 /test]# ls
dir1 dir2
[root@linux205 /test]# cd dir2
[root@linux205 /test/dir2]# pwd
/test/dir2
[root@linux205 /test/dir2]# cd ..
[root@linux205 /test]# ls
dir1 dir2
[root@linux205 /test]# cd dir1
[root@linux205 /test/dir1]# cd ../dir2
[root@linux205 /test/dir2]# cd ../dir1
[root@linux205 /test/dir1]# pwd
/test/dir1
#ls -l //현재 디렉토리 안에 있는 내용들을 보여줌
#ls -ld //디렉토리의 속성정보를 보여줌
[root@linux205 ~]# cd /test
[root@linux205 /test]# rm -rf /test/* //삭제
[root@linux205 /test]# touch file1
[root@linux205 /test]# mkdir dir1
[root@linux205 /test]# touch dir1/file2
[root@linux205 /test]# ls -l
합계 4
drwxr-xr-x 2 root root 4096 4월 12 18:18 dir1
-rw-r--r-- 1 root root 0 4월 12 18:18 file1
[root@linux205 /test]# ls -ld
drwxr-xr-x 3 root root 4096 4월 12 18:18 .
[root@linux205 /test]# ls -l dir1
합계 0
-rw-r--r-- 1 root root 0 4월 12 18:18 file2
[root@linux205 /test]# ls -ld dir1
drwxr-xr-x 2 root root 4096 4월 12 18:18 dir1
[root@linux205 /test]# ls -lR /test
/test:
합계 4
drwxr-xr-x 2 root root 4096 4월 12 18:18 dir1
-rw-r--r-- 1 root root 0 4월 12 18:18 file1
합계 0
-rw-r--r-- 1 root root 0 4월 12 18:18 file2
[root@linux205 /test]# ls -ld dir1
drwxr-xr-x 2 root root 4096 4월 12 18:18 dir1
[root@linux205 /test]# ls -lR /test
/test:
합계 4
drwxr-xr-x 2 root root 4096 4월 12 18:18 dir1
-rw-r--r-- 1 root root 0 4월 12 18:18 file1
/test/dir1:
합계 0
-rw-r--r-- 1 root root 0 4월 12 18:18 file2
합계 0
-rw-r--r-- 1 root root 0 4월 12 18:18 file2
-lR = Recursive 하위내용까지
-al 모든 정보 all
-al 모든 정보 all
"ls -F" 옵션 실습 //일반, 링크, 실행, 디렉토리파일 구분
[root@linux205 /test]# cp /etc/passwd file1
[root@linux205 /test]# ln -s file1 file2
[root@linux205 /test]# cp /bin/ls file3
[root@linux205 /test]# mkdir dir1
[root@linux205 /test]# ls
dir1 file1 file2 file3
[root@linux205 /test]# ls -F
dir1/ file1 file2@ file3*
[root@linux205 /test]# ln -s file1 file2
[root@linux205 /test]# cp /bin/ls file3
[root@linux205 /test]# mkdir dir1
[root@linux205 /test]# ls
dir1 file1 file2 file3
[root@linux205 /test]# ls -F
dir1/ file1 file2@ file3*
ls -i inode 번호 고유번호
[root@linux205 /test]# ls -li /test/file1
5330754 -rw-r--r-- 1 root root 1904 4월 12 18:26 /test/file1
[root@linux205 /test]# ls -ldi /test/dir1
5330757 drwxr-xr-x 2 root root 4096 4월 12 18:26 /test/dir1
5330754 -rw-r--r-- 1 root root 1904 4월 12 18:26 /test/file1
[root@linux205 /test]# ls -ldi /test/dir1
5330757 drwxr-xr-x 2 root root 4096 4월 12 18:26 /test/dir1
alias(별칭) 일종의 핫키 등록하는거 int?
alias c='clear'
# c (# clear)
alias c='clear'
# c (# clear)
^ 라인의 처음 이라는 뜻
^- 라인 처음이 - 라고 시작하는것
grep 명령어
^- 라인 처음이 - 라고 시작하는것
grep 명령어
[root@linux205 /test]# alias lsf='ls -l | grep "^-"'
[root@linux205 /test]# alias lsd='ls -l | grep "^d"'
[root@linux205 /test]# lsf
-rw-r--r-- 1 root root 1904 4월 12 18:26 file1
-rwxr-xr-x 1 root root 95116 4월 12 18:26 file3
[root@linux205 /test]# lsd
drwxr-xr-x 2 root root 4096 4월 12 18:26 dir1
[root@linux205 /test]# alias lsd='ls -l | grep "^d"'
[root@linux205 /test]# lsf
-rw-r--r-- 1 root root 1904 4월 12 18:26 file1
-rwxr-xr-x 1 root root 95116 4월 12 18:26 file3
[root@linux205 /test]# lsd
drwxr-xr-x 2 root root 4096 4월 12 18:26 dir1
ls -h 옵션 human
[root@linux205 /test]# ls -l /etc/services
-rw-r--r-- 1 root root 362031 2월 23 2006 /etc/services
[root@linux205 /test]# ls -lh /etc/services
-rw-r--r-- 1 root root 354K 2월 23 2006 /etc/services
[root@linux205 /test]# ls -l /etc/services
-rw-r--r-- 1 root root 362031 2월 23 2006 /etc/services
[root@linux205 /test]# ls -lh /etc/services
-rw-r--r-- 1 root root 354K 2월 23 2006 /etc/services
[root@linux205 /test]# gedit ~/.bashrc
alias ls='ls --color=tty -h' //마지막줄에 추가
[root@linux205 /test]# . ~/.bashrc
-t : time sort 최근시간부터
-r : reverse sort 가장 처음시간부터
-r : reverse sort 가장 처음시간부터
ls -alt
ls -altr
ls -altr
mkdir
-p 옵션 없으면 만들고 있으면 냅두고??
[root@linux205 ~]# cd /test
[root@linux205 /test]# rm -rf /test/*
[root@linux205 /test]# mkdir dir4
[root@linux205 /test]# rm -rf /test/*
[root@linux205 /test]# mkdir dir4
[root@linux205 /test]# mkdir dir4/dir2/dir1
mkdir: `dir4/dir2/dir1' 디렉토리를 만들 수 없습니다: 그런 파일이나 디렉토리가 없음
[root@linux205 /test]# mkdir -p dir4/dir2/dir1
mkdir: `dir4/dir2/dir1' 디렉토리를 만들 수 없습니다: 그런 파일이나 디렉토리가 없음
[root@linux205 /test]# mkdir -p dir4/dir2/dir1
[root@linux205 /test]# ls -R
.:
dir4
.:
dir4
./dir4:
dir2
dir2
./dir4/dir2:
dir1
dir1
./dir4/dir2/dir1:
rmdir 전혀 쓰이지 않는다 비어있지 않으면 삭제가 안돼
비어있지 않은 디렉토리를 삭제하려면??
# rm -rf dir1
-r : recursive
-f : force (강제삭제, 묻지않고)
# rm -rf dir1
-r : recursive
-f : force (강제삭제, 묻지않고)
파일관리 명령어
touch 터치 생성
cp copy 카피 복사
mv move 무브 이동
rm remove 리무브 삭제
touch 명령어에 -t 옵션을 사용해서 생성시간을 변경가능하다
파일의 일반적인 구조
file1 = Inode + Date Block
Inode : 인덱스노드, 파일의 속성정보, 데이터블록을 가리키는 정보, 고유번호가 할당 작은숫자부터
-i 옵션으로 확인할수 있어
-i 옵션으로 확인할수 있어
Data Block : 4k 단위로
[root@linux205 /test]# touch file1
[root@linux205 /test]# ls -li file1
5330754 -rw-r--r-- 1 root root 0 4월 12 20:05 file1
[root@linux205 /test]# cp file1 file2
[root@linux205 /test]# ls -li file2
5330755 -rw-r--r-- 1 root root 0 4월 12 20:06 file2
[root@linux205 /test]# ls -li file1
5330754 -rw-r--r-- 1 root root 0 4월 12 20:05 file1
[root@linux205 /test]# cp file1 file2
[root@linux205 /test]# ls -li file2
5330755 -rw-r--r-- 1 root root 0 4월 12 20:06 file2
아이노드번호가 다른걸 확인할수 있다
[root@linux205 /test]# mkdir dir1
[root@linux205 /test]# touch dir1/file1 dir1/file2
[root@linux205 /test]# ls -R
.:
dir1
./dir1:
file1 file2
[root@linux205 /test]# cp -r dir1 dir2
[root@linux205 /test]# ls -iR
.:
5330754 dir1 5330757 dir2
file1 file2
[root@linux205 /test]# cp -r dir1 dir2
[root@linux205 /test]# ls -iR
.:
5330754 dir1 5330757 dir2
./dir1:
5330755 file1 5330756 file2
5330755 file1 5330756 file2
./dir2:
5330759 file1 5330758 file2
5330759 file1 5330758 file2
[root@linux205 /test]# mkdir dir1
[root@linux205 /test]# echo "linux200" > file1
[root@linux205 /test]# cat file1
linux200
[root@linux205 /test]# touch dir1/file1
[root@linux205 /test]# cat dir1/file1
[root@linux205 /test]# cp file1 dir1
cp: overwrite `dir1/file1'? y
[root@linux205 /test]# cp file1 file2
[root@linux205 /test]# ls -l
합계 12K
drwxr-xr-x 2 root root 4.0K 4월 12 20:10 dir1
-rwxrwxrwx 1 root root 9 4월 12 20:11 file1
-rwxr-xr-x 1 root root 9 4월 12 20:12 file2
[root@linux205 /test]# cp -p file1 file3
[root@linux205 /test]# ls -l
합계 16K
drwxr-xr-x 2 root root 4.0K 4월 12 20:10 dir1
-rwxrwxrwx 1 root root 9 4월 12 20:11 file1
-rwxr-xr-x 1 root root 9 4월 12 20:12 file2
-rwxrwxrwx 1 root root 9 4월 12 20:11 file3
[root@linux205 /test]# ls -l
합계 12K
drwxr-xr-x 2 root root 4.0K 4월 12 20:10 dir1
-rwxrwxrwx 1 root root 9 4월 12 20:11 file1
-rwxr-xr-x 1 root root 9 4월 12 20:12 file2
[root@linux205 /test]# cp -p file1 file3
[root@linux205 /test]# ls -l
합계 16K
drwxr-xr-x 2 root root 4.0K 4월 12 20:10 dir1
-rwxrwxrwx 1 root root 9 4월 12 20:11 file1
-rwxr-xr-x 1 root root 9 4월 12 20:12 file2
-rwxrwxrwx 1 root root 9 4월 12 20:11 file3
-p 옵션을 사용하면 퍼미션정보를 그대로 카피하게 된다
-p 옵션을 적용하지않고 복사한 file2
-p 옵션을 적용하고 복사한 file3
-p 옵션을 적용하지않고 복사한 file2
-p 옵션을 적용하고 복사한 file3
[root@linux205 /test]# chmod 777 /test
[root@linux205 /test]# su - fedora
[fedora@linux205 ~]$ id
uid=500(fedora) gid=500(fedora) groups=500(fedora)
[fedora@linux205 ~]$ pwd
/home/fedora
[fedora@linux205 ~]$ cd /test
[fedora@linux205 test]$ cp file1 file4
[fedora@linux205 test]$ ls -l
합계 20
drwxr-xr-x 2 root root 4096 4월 12 20:10 dir1
-rwxrwxrwx 1 root root 9 4월 12 20:11 file1
-rwxr-xr-x 1 root root 9 4월 12 20:12 file2
-rwxrwxrwx 1 root root 9 4월 12 20:11 file3
-rwxrwxr-x 1 fedora fedora 9 4월 12 20:14 file4
[fedora@linux205 test]$ cp -p file1 file5
[fedora@linux205 test]$ ls -l
합계 24
drwxr-xr-x 2 root root 4096 4월 12 20:10 dir1
-rwxrwxrwx 1 root root 9 4월 12 20:11 file1
-rwxr-xr-x 1 root root 9 4월 12 20:12 file2
-rwxrwxrwx 1 root root 9 4월 12 20:11 file3
-rwxrwxr-x 1 fedora fedora 9 4월 12 20:14 file4
-rwxrwxrwx 1 fedora fedora 9 4월 12 20:11 file5
실무 > 로그파일(file.log) 비우기
# cp /dev/null file.log
# cat /dev/null > file.log
# > file.log
# cp /dev/null file.log
# cat /dev/null > file.log
# > file.log
[root@linux205 /test]# cp -p /var/log/messages file.log
[root@linux205 /test]# cp -f /dev/null file.log
cp: overwrite `file.log'? y
[root@linux205 /test]# ls -l file.log
-rw------- 1 root root 0 4월 12 20:20 file.log
[root@linux205 /test]# cp -f /dev/null file.log
cp: overwrite `file.log'? y
[root@linux205 /test]# ls -l file.log
-rw------- 1 root root 0 4월 12 20:20 file.log
실무 > 설정 파일을 백업 받고 설정하는 경우
[root@linux205 ~]# cd /etc/httpd
[root@linux205 /etc/httpd]# ls
conf conf.d logs modules run
[root@linux205 /etc/httpd]# cd conf
[root@linux205 /etc/httpd/conf]# ls
httpd.conf magic
[root@linux205 /etc/httpd/conf]# cp -p httpd.conf httpd.conf.old
[root@linux205 /etc/httpd/conf]# ci httpd.conf
[root@linux205 ~]# cd /etc/httpd
[root@linux205 /etc/httpd]# ls
conf conf.d logs modules run
[root@linux205 /etc/httpd]# cd conf
[root@linux205 /etc/httpd/conf]# ls
httpd.conf magic
[root@linux205 /etc/httpd/conf]# cp -p httpd.conf httpd.conf.old
[root@linux205 /etc/httpd/conf]# ci httpd.conf
OPTIONS
-i 선택 interactive
-f 강제로 덮어쓰기 force
-r 하위
-p(preserve) 퍼미션정보 동일하게
-a 위에 다 포함
mv 이름을 바꾼다고 생각하면 될듯
# mv file1 file2 /file1 파일 이름이 file2 로 변함
# mv file1 dir1 /dir1 디렉토리 안에 file1 이동
# mv dir1 dir2 /dir2 하위 경로에 dir1 이동
# mv file1 dir1 /dir1 디렉토리 안에 file1 이동
# mv dir1 dir2 /dir2 하위 경로에 dir1 이동
[root@linux205 /test]# touch file1
[root@linux205 /test]# mkdir dir1
[root@linux205 /test]# touch dir1/file2
[root@linux205 /test]# mkdir dir1
[root@linux205 /test]# touch dir1/file2
[root@linux205 /test]# mv file1 file3
[root@linux205 /test]# tree
.
|-- dir1
| `-- file2
`-- file3
[root@linux205 /test]# tree
.
|-- dir1
| `-- file2
`-- file3
1 directory, 2 files
[root@linux205 /test]# mv file3 dir1
[root@linux205 /test]# tree
.
`-- dir1
|-- file2
`-- file3
[root@linux205 /test]# mv file3 dir1
[root@linux205 /test]# tree
.
`-- dir1
|-- file2
`-- file3
1 directory, 2 files
[root@linux205 /test]# mv dir1 dir2
[root@linux205 /test]# tree
.
`-- dir2
|-- file2
`-- file3
[root@linux205 /test]# mv dir1 dir2
[root@linux205 /test]# tree
.
`-- dir2
|-- file2
`-- file3
1 directory, 2 files
[root@linux205 /test]# cp -r dir2 dir1
[root@linux205 /test]# tree
.
|-- dir1
| |-- file2
| `-- file3
`-- dir2
|-- file2
`-- file3
[root@linux205 /test]# cp -r dir2 dir1
[root@linux205 /test]# tree
.
|-- dir1
| |-- file2
| `-- file3
`-- dir2
|-- file2
`-- file3
2 directories, 4 files
[root@linux205 /test]# mv dir1 dir2
[root@linux205 /test]# tree
.
`-- dir2
|-- dir1
| |-- file2
| `-- file3
|-- file2
`-- file3
[root@linux205 /test]# mv dir1 dir2
[root@linux205 /test]# tree
.
`-- dir2
|-- dir1
| |-- file2
| `-- file3
|-- file2
`-- file3
2 directories, 4 files
Inode 확인하는방법
[root@linux205 /test]# touch file1
[root@linux205 /test]# ls -li file1
5330754 -rw-r--r-- 1 root root 0 4월 12 20:34 file1
[root@linux205 /test]# mv file1 file3
[root@linux205 /test]# ls -li file3
5330754 -rw-r--r-- 1 root root 0 4월 12 20:34 file3
[root@linux205 /test]# touch file1 file2 file4
[root@linux205 /test]# ls
file1 file2 file3 file4
[root@linux205 /test]# mkdir dir1
[root@linux205 /test]# mv file* dir1
[root@linux205 /test]# ls dir1
file1 file2 file3 file4
[root@linux205 /test]# touch file1
[root@linux205 /test]# ls -li file1
5330754 -rw-r--r-- 1 root root 0 4월 12 20:34 file1
[root@linux205 /test]# mv file1 file3
[root@linux205 /test]# ls -li file3
5330754 -rw-r--r-- 1 root root 0 4월 12 20:34 file3
[root@linux205 /test]# touch file1 file2 file4
[root@linux205 /test]# ls
file1 file2 file3 file4
[root@linux205 /test]# mkdir dir1
[root@linux205 /test]# mv file* dir1
[root@linux205 /test]# ls dir1
file1 file2 file3 file4
파일이 여러개 이동하는거 볼 수 있음
* 와일드카드 위의 예제에서는 1~4를 포함한다고 보면됨
file*=file1+file2+file3+file4
* 와일드카드 위의 예제에서는 1~4를 포함한다고 보면됨
file*=file1+file2+file3+file4
[참고] 비어 있지 않은 디렉토리 삭제
# rm -rf dir1
[참고] rm 명령어로 지운 파일 복구(100% 장담할 수 없음)
# debugfs /dev/sda3
debugfs 명령어에 관한 내용을 한번 찾아보자!!
파일 시스템 디버깅
# debugfs /dev/sda3
debugfs 명령어에 관한 내용을 한번 찾아보자!!
파일 시스템 디버깅
cat = concatenate 파일 내용을 출력
# cat file1
# cat file1 file2
# cat -n file1 줄번호와 함께 출력
[root@linux205 /test]# echo 1111 > file1
[root@linux205 /test]# echo 2222 > file2
[root@linux205 /test]# cat file1 file2
1111
2222
[root@linux205 /test]# echo 2222 > file2
[root@linux205 /test]# cat file1 file2
1111
2222
[root@linux205 /test]# cat file1 file2 > file3
[root@linux205 /test]# cat file3
1111
2222
[root@linux205 /test]# cat file3
1111
2222
[root@linux205 /test]# cat -n /etc/passwd | grep --color fedora
41 fedora:x:500:500:fedora:/home/fedora:/bin/bash
41 fedora:x:500:500:fedora:/home/fedora:/bin/bash
strings 명령어
바이너리 파일을 cat 명령어로 보는 경우에 파일이 깨져보인다
# cat /bin/ls 를 입력하면
ÿÿÿÿ ÿÿÿÿ Ò¤°°×¤á¤ é¤ï¤ö¤ú¤ &-6��DHNTW_\cis�a|b�d�D���h�i���nGq�rfs�w�ABsFip�H0�,�1I��8LDNLQ��WR��a��tT��|�������� � ���~����}����',�T-���������D�|�=��
x���oh�h́ ��
a
`��8�x���oh���o���o���o����o����oЉ���o\����� �D(��0�� @( DS Lì@æ ¦ ⎻␌ À °à 0¿ ⎻ü ð± ◆ P P] À  ◆ % \ 0ñ Ðú °´ ðº PÈ␉ à À] @ À °ô @ ⎻! / ┼ À'£ Ð0 0+ Pö _ À/ ð _ ◆× ▒ ⎻+ ◆R à> ◆π 0┼ ° 0 ⎻0 Àà Ð ð ð>£ ◆3£ õ ;£ °ü À¤ Ý␉ À× 0¾ 8£ ◆ ≤ @ä␉ ◆����Ԍ����B�p��*��Ҍ``����Y��˓���)�����p���T���@�����p,����%+1 �ls.debug\��ELF��4i4(44�4�44�4���hUhU`P
@d@@��HH�H� P�td8;88LLQ�td
4�4H�H !���oh�hd+
́�P3� a;���o~ ê H þÿÿ⎺ �W 8�8x` ���
i���d� o�����uxx{���8 �88;L���@��`�`�`� ` �@@d�� e@�``e��g h0 �h,h�.shstrtab.interp.note.ABI-tag.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.text.fini.rodata.eh_frame_hdr.eh_frame.ctors.dtors.jcr.data.rel.ro.dynamic.got.got.plt.data.bss.gnu_debuglink.gnu.liblist.gnu.conflict.gnu.prelink_undo
4�4H�H !���oh�hd+
́�P����o� ��Љ� \
;���o~ ê H þÿÿ⎺ �W 8�8x` ���
i���d� o�����uxx{���8 �88;L���@�3hhU��`�`�`� ` �@@d�� e@�``e��g h0 �h,hl�m[
x���oh�h́ ��
a
`��8�x���oh���o���o���o����o����oЉ���o\����� �D(��0�� @( DS Lì@æ ¦ ⎻␌ À °à 0¿ ⎻ü ð± ◆ P P] À  ◆ % \ 0ñ Ðú °´ ðº PÈ␉ à À] @ À °ô @ ⎻! / ┼ À'£ Ð0 0+ Pö _ À/ ð _ ◆× ▒ ⎻+ ◆R à> ◆π 0┼ ° 0 ⎻0 Àà Ð ð ð>£ ◆3£ õ ;£ °ü À¤ Ý␉ À× 0¾ 8£ ◆ ≤ @ä␉ ◆����Ԍ����B�p��*��Ҍ``����Y��˓���)�����p���T���@�����p,����%+1 �ls.debug\��ELF��4i4(44�4�44�4���hUhU`P
@d@@��HH�H� P�td8;88LLQ�td
4�4H�H !���oh�hd+
́�P3� a;���o~ ê H þÿÿ⎺ �W 8�8x` ���
i���d� o�����uxx{���8 �88;L���@��`�`�`� ` �@@d�� e@�``e��g h0 �h,h�.shstrtab.interp.note.ABI-tag.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.text.fini.rodata.eh_frame_hdr.eh_frame.ctors.dtors.jcr.data.rel.ro.dynamic.got.got.plt.data.bss.gnu_debuglink.gnu.liblist.gnu.conflict.gnu.prelink_undo
4�4H�H !���oh�hd+
́�P����o� ��Љ� \
;���o~ ê H þÿÿ⎺ �W 8�8x` ���
i���d� o�����uxx{���8 �88;L���@�3hhU��`�`�`� ` �@@d�� e@�``e��g h0 �h,hl�m[
??????????????? 뭐 이런식으로 나옴
# strings /bin/ls 를 입력하면
.shstrtab.interp.note.ABI-tag.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.text.fini.rodata.eh_frame_hdr.eh_frame.ctors.dtors.jcr.data.rel.ro.dynamic.got.got.plt.data.bss.gnu_debuglink.gnu.liblist.gnu.conflict.gnu.prelink_undo
이렇게만 나온다 문자열만 뽑아서
more 명령어 쓰면 한줄(enter)당 한페이지(space)당 보여주는거
너무 많은 페이지가 출력되면 1페이지 내용을 확인할수가 없음
그럴때 사용하면 좋다
너무 많은 페이지가 출력되면 1페이지 내용을 확인할수가 없음
그럴때 사용하면 좋다
more 보다 | more 을 더 많이 써라
1) # cat /etc/services | more
2) # more /etc/services
2) # more /etc/services
같은 출력을 보이지만 1) 을 더 많이 쓴다고 한다
more 뒤에는 파일이름만 지정가능하다 하지만
파이프를 이용하게 되면 앞의 출력값을 기반으로 할수있기 때문
more 뒤에는 파일이름만 지정가능하다 하지만
파이프를 이용하게 되면 앞의 출력값을 기반으로 할수있기 때문
| : 파이프 라고 한다
a | b : a 의 출력값을 b에 입력한다
[root@linux205 /test]# ps -ef | head -1 ; ps -ef | grep inetd
UID PID PPID C STIME TTY TIME CMD
root 3967 1 0 16:48 ? 00:00:00 xinetd -stayalive -pidfile /var/run/xinetd.pid
root 19379 19216 0 21:25 pts/1 00:00:00 grep inetd
같이 쓰려면 세미콜론 ;
alias 해서 쓰면 좋다
alias 해서 쓰면 좋다
[root@linux205 /test]# alias pps='ps -ef | head -1 ; ps -ef | grep $1'
[root@linux205 /test]# alias pps
alias pps='ps -ef | head -1 ; ps -ef | grep $1'
[root@linux205 /test]# alias pps
alias pps='ps -ef | head -1 ; ps -ef | grep $1'
이런식으로 지정한다 $1 은 첫번째 인자(Argument)를 뜻한다
예로는 아래와 같다
[root@linux205 /test]# pps syslogd
UID PID PPID C STIME TTY TIME CMD
root 3624 1 0 16:48 ? 00:00:00 syslogd -m 0
root 19384 19216 0 21:28 pts/1 00:00:00 grep syslogd
[root@linux205 /test]# pps bash
UID PID PPID C STIME TTY TIME CMD
root 4400 4365 0 16:49 ? 00:00:00 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "/usr/bin/dbus-launch --exit-with-session /etc/X11/xinit/Xclients"
root 19216 19210 0 20:16 pts/1 00:00:00 bash
root 19388 19216 0 21:29 pts/1 00:00:00 grep bash
UID PID PPID C STIME TTY TIME CMD
root 3624 1 0 16:48 ? 00:00:00 syslogd -m 0
root 19384 19216 0 21:28 pts/1 00:00:00 grep syslogd
[root@linux205 /test]# pps bash
UID PID PPID C STIME TTY TIME CMD
root 4400 4365 0 16:49 ? 00:00:00 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "/usr/bin/dbus-launch --exit-with-session /etc/X11/xinit/Xclients"
root 19216 19210 0 20:16 pts/1 00:00:00 bash
root 19388 19216 0 21:29 pts/1 00:00:00 grep bash
[root@linux205 ~]# gedit ~/.bashrc
---------------------------------------------------------------------
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
#
# Sfecific Configuration
#
export PS1='[\u@\h \w]\$ '
alias ls='ls --color=tty -h'
alias pps='ps -ef | head -1 ; ps -ef | grep $1' //이부분추가
---------------------------------------------------------------------
[root@linux205 ~]# . ~/.bashrc
[root@linux205 ~]# pps syslogd
UID PID PPID C STIME TTY TIME CMD
root 3624 1 0 16:48 ? 00:00:00 syslogd -m 0
root 19447 19419 0 21:35 pts/1 00:00:00 grep syslogd
# Sfecific Configuration
#
export PS1='[\u@\h \w]\$ '
alias ls='ls --color=tty -h'
alias pps='ps -ef | head -1 ; ps -ef | grep $1' //이부분추가
---------------------------------------------------------------------
[root@linux205 ~]# . ~/.bashrc
[root@linux205 ~]# pps syslogd
UID PID PPID C STIME TTY TIME CMD
root 3624 1 0 16:48 ? 00:00:00 syslogd -m 0
root 19447 19419 0 21:35 pts/1 00:00:00 grep syslogd
tail 은 head 의 반대되는 개념
-f 파일의 크기가 변할때마다 추가된 정보를 출력한다
[참고] telnet 서비스 Open 방법(일반사용자)
[root@linux205 ~]# chkconfig --list
[root@linux205 ~]# chkconfig --list | grep krb5-telnet
ekrb5-telnet: 해제
krb5-telnet: 해제
[root@linux205 ~]# chkconfig krb5-telnet on
[root@linux205 ~]# chkconfig --list | grep krb5-telnet
ekrb5-telnet: 해제
krb5-telnet: 활성
[root@linux205 ~]# service xinetd restart
xinetd 를 정지 중: [ OK ]
xinetd (을)를 시작 중: [ OK ]
telnet localhost
fedora는 되는데 root는 추가적으로 작업해줘야 가능함
fedora는 되는데 root는 추가적으로 작업해줘야 가능함
[root@linux205 ~]# tail -f /var/log/messages
Apr 12 21:56:17 linux205 xinetd[3967]: Exiting...
Apr 12 21:56:17 linux205 xinetd[19531]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networking options compiled in.
Apr 12 21:56:17 linux205 xinetd[19531]: Started working: 1 available service
Apr 12 21:56:35 linux205 xinetd[19531]: START: telnet pid=19534 from=127.0.0.1
Apr 12 21:56:46 linux205 xinetd[19531]: EXIT: telnet status=1 pid=19534 duration=11(sec)
Apr 12 21:57:15 linux205 xinetd[19531]: START: telnet pid=19562 from=127.0.0.1
Apr 12 21:57:41 linux205 xinetd[19531]: EXIT: telnet status=1 pid=19562 duration=26(sec)
Apr 12 21:59:16 linux205 xinetd[19531]: START: telnet pid=19567 from=127.0.0.1
Apr 12 21:59:27 linux205 login: ROOT LOGIN pts/2 FROM linux205
Apr 12 21:59:32 linux205 xinetd[19531]: EXIT: telnet status=1 pid=19567 duration=16(sec)
Apr 12 22:02:35 linux205 xinetd[19531]: START: telnet pid=19667 from=127.0.0.1
Apr 12 21:56:17 linux205 xinetd[3967]: Exiting...
Apr 12 21:56:17 linux205 xinetd[19531]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networking options compiled in.
Apr 12 21:56:17 linux205 xinetd[19531]: Started working: 1 available service
Apr 12 21:56:35 linux205 xinetd[19531]: START: telnet pid=19534 from=127.0.0.1
Apr 12 21:56:46 linux205 xinetd[19531]: EXIT: telnet status=1 pid=19534 duration=11(sec)
Apr 12 21:57:15 linux205 xinetd[19531]: START: telnet pid=19562 from=127.0.0.1
Apr 12 21:57:41 linux205 xinetd[19531]: EXIT: telnet status=1 pid=19562 duration=26(sec)
Apr 12 21:59:16 linux205 xinetd[19531]: START: telnet pid=19567 from=127.0.0.1
Apr 12 21:59:27 linux205 login: ROOT LOGIN pts/2 FROM linux205
Apr 12 21:59:32 linux205 xinetd[19531]: EXIT: telnet status=1 pid=19567 duration=16(sec)
Apr 12 22:02:35 linux205 xinetd[19531]: START: telnet pid=19667 from=127.0.0.1
Apr 12 22:03:16 linux205 xinetd[19531]: EXIT: telnet status=1 pid=19667 duration=41(sec)
다른 터미널 창을 열어서 user01 로 telnet localhost에 접속하고 접속을 종료할때의 로그
로그 분석할때 사용함 -f 옵션이다 변경사항을 볼수있기때문
로그 분석할때 사용함 -f 옵션이다 변경사항을 볼수있기때문
서버를 실시간적으로 모니터링
[TERM1] # top (# gnome-system-monitor)
top - 22:05:49 up 5:18, 3 users, load average: 0.03, 0.04, 0.00
Tasks: 156 total, 1 running, 154 sleeping, 0 stopped, 1 zombie
Cpu(s): 0.2%us, 0.1%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1035008k total, 1000844k used, 34164k free, 96224k buffers
Swap: 1052248k total, 0k used, 1052248k free, 730464k cached
Tasks: 156 total, 1 running, 154 sleeping, 0 stopped, 1 zombie
Cpu(s): 0.2%us, 0.1%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1035008k total, 1000844k used, 34164k free, 96224k buffers
Swap: 1052248k total, 0k used, 1052248k free, 730464k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
19413 root 15 0 82140 13m 9900 S 0.7 1.4 0:04.53 gnome-terminal
19694 root 15 0 2336 1052 800 R 0.7 0.1 0:00.08 top
4337 root 15 0 52280 11m 6864 S 0.3 1.1 1:33.77 Xorg
1 root 15 0 2072 584 504 S 0.0 0.1 0:01.00 init
2 root RT -5 0 0 0 S 0.0 0.0 0:07.47 migration/0
3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
4 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
5 root RT -5 0 0 0 S 0.0 0.0 0:07.36 migration/1
6 root 39 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1
7 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/1
8 root RT -5 0 0 0 S 0.0 0.0 0:08.40 migration/2
9 root 34 19 0 0 0 S 0.0 0.0 0:00.14 ksoftirqd/2
10 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/2
11 root RT -5 0 0 0 S 0.0 0.0 0:07.36 migration/3
12 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/3
13 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/3
14 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/0
15 root 10 -5 0 0 0 S 0.0 0.0 0:00.31 events/1
16 root 10 -5 0 0 0 S 0.0 0.0 0:00.65 events/2
17 root 10 -5 0 0 0 S 0.0 0.0 0:00.30 events/3
18 root 16 -5 0 0 0 S 0.0 0.0 0:00.00 khelper
19 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kthread
19413 root 15 0 82140 13m 9900 S 0.7 1.4 0:04.53 gnome-terminal
19694 root 15 0 2336 1052 800 R 0.7 0.1 0:00.08 top
4337 root 15 0 52280 11m 6864 S 0.3 1.1 1:33.77 Xorg
1 root 15 0 2072 584 504 S 0.0 0.1 0:01.00 init
2 root RT -5 0 0 0 S 0.0 0.0 0:07.47 migration/0
3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
4 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
5 root RT -5 0 0 0 S 0.0 0.0 0:07.36 migration/1
6 root 39 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1
7 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/1
8 root RT -5 0 0 0 S 0.0 0.0 0:08.40 migration/2
9 root 34 19 0 0 0 S 0.0 0.0 0:00.14 ksoftirqd/2
10 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/2
11 root RT -5 0 0 0 S 0.0 0.0 0:07.36 migration/3
12 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/3
13 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/3
14 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/0
15 root 10 -5 0 0 0 S 0.0 0.0 0:00.31 events/1
16 root 10 -5 0 0 0 S 0.0 0.0 0:00.65 events/2
17 root 10 -5 0 0 0 S 0.0 0.0 0:00.30 events/3
18 root 16 -5 0 0 0 S 0.0 0.0 0:00.00 khelper
19 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kthread
[root@linux205 ~]# gnome-system-monitor
그래픽 기반으로 리소스 사용량을 확인할수있음
시스템정보(프로세스, 자원, 파일시스템)
그래픽 기반으로 리소스 사용량을 확인할수있음
시스템정보(프로세스, 자원, 파일시스템)
[TERM2] #tail -f /var/log/messages (# gnome-system-log)
'모의해킹 침해대응 전문가 과정' 카테고리의 다른 글
20160419 리눅스 기초 (0) | 2016.04.20 |
---|---|
20160418 리눅스 기초 (0) | 2016.04.19 |
20160415 리눅스 기초 (0) | 2016.04.15 |
20160414 리눅스 기초 (0) | 2016.04.15 |
20160411 리눅스 기초 (0) | 2016.04.12 |