Skip to content

shb003/01_LinuxEssential

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Linux Essential κ³Όμ • 정리

제 01μž₯. Linux Command 제 02μž₯. 디렉토리 μΆ”κ°€ 관리

hostnamectl set-hostname (이름)

ipμ„€μ •μ°½ 뢈러였기 nm-connection-editor

ip μ„€μ •μ°½μ˜ 이더넷 λͺ©λ‘μ—μ„œ λ””λ°”μ΄μŠ€λ₯Ό μ•„λž˜ λ§₯μ£Όμ†Œλ‘œ μ„ νƒν•΄μ•Όν•œλ‹€. μ™œλƒν•˜λ©΄ 이것은 κΈ°μ‘΄ main을 μŠ€λƒ…μƒ· ν•œκ²ƒμ΄κΈ° λ•Œλ¬Έμ— λ‹€λ₯Έ λ§₯μ£Όμ†Œλ₯Ό μ‚¬μš©ν•΄μ•Ό 였λ₯˜κ°€ μ—†λ‹€.

적용 ν›„, nmcli connection up ens 33으둜 μ΅œμ’… μ μš©ν•œλ‹€.

-λͺ…λ Ήμ–΄ λ©”λ‰΄μ–Όλ‘œ 탐색 man -k calendar = μΊ˜λ¦°λ”μ˜ ν‚€μ›Œλ“œ 메뉴얼 man -kλŠ” λ‹€μŒ λͺ…λ Ήμ–΄κ°€ λ­”μ§€ 기얡이 μ•ˆλ‚ λ•Œ μ“°λ©΄ μ’‹μŒ

man -f passwd = νŒ¨μŠ€μ›Œλ“œμ™€ κ΄€λ ¨λœ 맀뉴얼 탐색 λ²ˆν˜ΈλŠ” 메뉴얼 μ„Έμ…˜ 번호. 각 μ„Έμ…˜λ§ˆλ‹€ 정보가 닀름. μ±…λ²ˆν˜Έ 라고 μƒκ°ν•˜λ©΄ νŽΈν•˜λ‹€

man ls /* λͺ…λ Ήμ–΄λ‚˜ 파일의 μ΄λ¦„μœΌλ‘œ κ²€μƒ‰ν•˜λŠ” 경우 */

man -k calendar /* keyword둜 κ²€μƒ‰ν•˜λŠ” 경우 */

man -f passwd (# whatis passwd)

man 1 passwd /* section번호둜 κ²€μƒ‰ν•˜λŠ” 경우, man -s 1 passwd *

β–  Linux Manual Section --------------------------------------------------------- Section 1 : μ‚¬μš©μž λͺ…λ Ή(μ‹€ν–‰κ°€λŠ₯ν•œ λͺ…λ Ή 및 μ‰˜ ν”„λ‘œκ·Έλž¨) Section 2 : μ‹œμŠ€ν…œ 호좜(μ‚¬μš©μž κ³΅κ°„μ—μ„œ 호좜된 컀널 루틴) Section 3 : 라이브러리 κΈ°λŠ₯(ν”„λ‘œκ·Έλž¨ λΌμ΄λΈŒλŸ¬λ¦¬μ—μ„œ 제곡) Section 4 : 특수 파일(예: μž₯치 파일) Section 5 : 파일 ν˜•μ‹(λ§Žμ€ ꡬ성 파일 및 ꡬ쑰의 경우) Section 6 : κ²Œμž„(였락 ν”„λ‘œκ·Έλž¨μš© μ„Ήμ…˜) Section 7 : λ²”λ‘€, ν‘œμ€€ 및 기타(ν”„λ‘œν† μ½œ, νŒŒμΌμ‹œμŠ€ν…œ) Section 8 : μ‹œμŠ€ν…œ 관리 및 κΆŒν•œ λͺ…λ Ή(μœ μ§€ 보수 μž‘μ—…) Section 9 : λ¦¬λˆ…μŠ€ 컀널 API(λ‚΄λΆ€ 컀널 호좜)

ctrl+shift+t = νƒ­ν˜•νƒœλ‘œ μƒˆλ‘œ λ„μš°κΈ° ctrl+shift+n = μœˆλ„μš° ν˜•νƒœλ‘œ μƒˆμ°½ λ„μš°κΈ°

μ•”ν˜Έλ³€κ²½: passwd λ³€κ²½ν•  μ‚¬μš©μž 이름 원격 접속: ssh μ‚¬μš©μžμ΄λ¦„@localhost

μ‹œμŠ€ν…œ κΈ°λ³Έ 정보 확인 uname date cal

cat λͺ…λ Ήμ–΄ = cat etc/ ~~ μ‹μœΌλ‘œ 경둜λ₯Ό κ²€μƒ‰ν•˜μ—¬ ν•΄λ‹Ήκ²½λ‘œμ˜ λ¬Έμ„œλ₯Ό μ‰˜λ‘œ 확인

uname Linux server1.example.com 4.18.0-240.el8.x86_64 #1 SMP Fri Sep 25 19:48:47 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

λ¦¬λˆ…μŠ€ λ ˆλ“œν—·μ— λŒ€ν•œ 정보듀을 λͺ¨μ•„λ‘λŠ” μ‚¬μ΄νŠΈ Red Hat Enterprise Linux - Red Hat Customer Portal γ„΄ centos의 정보λ₯Ό 확인할 λ•Œ, μ‚¬μš©ν•œλ‹€.

μƒˆμ°½ λ„μš°κΈ° crtl+shift+n

μ‚¬μš©μž 디렉토리 이동

이전 디렉토리 이동= cd - μ˜†μ— μžˆλŠ” λ””λ ‰ν† λ¦¬λ‘œ 이동= cd ../μ˜†λ””λ ‰ν† λ¦¬ μƒμœ„ 디렉토리 이동= cd .. 디렉토리 이동 cd /이동을 μ›ν•˜λŠ” ν•˜μœ„ 디렉토리 cd = ν™ˆλ””λ ‰ν† λ¦¬ 이동

디렉토리 관리 λͺ…λ Ήμ–΄ γ„΄ λ¦¬λˆ…μŠ€μ—μ„œ κ΄€λ¦¬λΌλŠ” 말이 λΆ™λŠ”λ‹€λŠ”κ²ƒμ€ λ³€κ²½ μ‚­μ œ μΆ”κ°€κ°€ κ°€λŠ₯ν•˜λŠ” λœ»μ„ λ§ν•œλ‹€

ls λͺ…λ Ήμ–΄ - λͺ©λ‘μ„ λ³΄μ—¬μ£ΌλŠ” λͺ…λ Ήμ–΄ ls -l = ν•΄λ‹Ή 디렉토리 μ•ˆμ— μžˆλŠ” ν΄λ”λ“€μ˜ κΆŒν•œκ³Ό 정보λ₯Ό ν‘œμ‹œν•΄μ€€λ‹€ ld -ld =ν˜„μž¬ λ””λ ‰ν† λ¦¬μ˜ κΆŒν•œκ³Ό μ΅œμ’… μ‚¬μš©λœ μ‹œκ°„μ„ ν‘œν˜„ν•΄μ€€λ‹€. γ„΄κΆŒν•œμ— λŒ€ν•œ μ„€λͺ… rwx 읽고, μ“°κ³  ,μ‹€ν–‰ν•˜λŠ” κΆŒν•œμ„ λœ»ν•¨. λͺ…λ Ήμ–΄λ‘œ ν‘œν˜„λ  λ•ŒλŠ” rwx r__ w μ‹μœΌλ‘œ μ§€μ›ν•˜μ§€ μ•ŠλŠ”κ²ƒλ„ _둜 ν‘œν˜„ν•΄μ€€λ‹€. γ„΄ μ—¬κΈ°μ„œ ls 의 -l을 λΆ™μ—¬μ£Όλ©΄ 더 λ§Žμ€ 정보λ₯Ό ν‘œν˜„ν•΄μ€€λ‹€. ld - lR = ν˜„μž¬ 디렉토리 μ•ˆμ— λͺ¨λ“  파일의 κΆŒν•œκ³Ό 정보λ₯Ό ν‘œμ‹œ 함 ls -al = .으둜 μ‹œμž‘ν•˜λŠ” μˆ¨κ²¨μ§„ 디렉토리도 ν‘œν˜„ν•˜μ—¬ ν‘œκΈ°ν•΄μ€€λ‹€. ls -i = 각 파일의 인덱슀 λ„˜λ²„λ₯Ό 좜λ ₯ν•΄μ£ΌλŠ” 역할을 μˆ˜ν–‰ν•œλ‹€. ls - li = λ””λ ‰ν† λ¦¬μ˜ μ‹λ³„λ²ˆν˜Έλ₯Ό ν‘œμ‹œν•΄μ€€λ‹€. ls -lh = λ””λ ‰ν† λ¦¬μ˜ μš©λŸ‰ λ‹¨μœ„λ₯Ό ν™˜μ‚° ν•  λ•Œ , μžλ™μœΌλ‘œ λ‹¨μœ„λ₯Ό νŽΈν•˜κ²Œ 보기 μœ„ν•΄ λ³΄μ •ν•΄μ€Œ

[μ‹€λ¬΄μ˜ˆ] μ‹€λ¬΄μ—μ„œ 많이 μ‚¬μš©ν•˜λŠ” cmd cd /Log_dir ls- -altr

[μ°Έκ³ ] alias (μ„ μ–Έ) alias ls = β€˜ls -l | grep β€œ^-”’ (확인) alias (ν•΄μ œ) # unalias ls

파일 λ˜λŠ” λ””λ ‰ν† λ¦¬λ§Œ 좜λ ₯ 일반적으둜 λ¦¬λˆ…μŠ€μ—μ„œ λͺ…λ Ήμ–΄λ₯Ό λ§Œλ“€μ–΄μ„œ μ‚¬μš©ν•˜κΈ°λ„ ν•œλ‹€.

mkdir λͺ…λ Ήμ–΄ mkdir -p dir3/dir2/dir1 γ„΄ μ•„λž˜ -pλ₯Ό μΆ”κ°€ν•΄μ€€λ‹€λ©΄ μƒμœ„μ—μ„œ ν•˜μœ„ 디렉토리λ₯Ό ν•œλ²ˆμ— 생성

rmdir λͺ…λ Ήμ–΄ 폴더가 λΉ„μ›Œμ Έ μžˆλŠ” κ²½μš°μ—λŠ” μ§€μšΈ 수 μžˆλŠ” λͺ…λ Ήμ–΄ 이닀. 잘 μ‚¬μš© x rm -rf dir1 = -rfλŠ” μ§€μšΈλ•Œ νŒŒμΌλ§ˆλ‹€ ν•œλ²ˆμ”© μž¬ν™•μΈμ„ λ°›λŠ”λ° 그것을 λ°©μ§€ν•˜κ³  디렉토리λ₯Ό μ‚­μ œν•΄μ£ΌλŠ” λͺ…령어이닀.

파일/디렉토리 μ‚­μ œλ₯Ό 주의 해야함!!!!

touch λͺ…λ Ήμ–΄ touch λͺ…λ Ήμ–΄λŠ” 폴더 내에 bin νŒŒμΌμ„ 생성 touch file1 /* file1 μ΄λΌλŠ” νŒŒμΌμ„ ν•˜λ‚˜ μƒμ„±ν•œλ‹€. touch -t 08301300 file1 = file1의 μ‹œκ°„μ •λ³΄λ₯Ό λ³€κ²½ν•œλ‹€.

cp λͺ…λ Ήμ–΄ =copy λͺ…λ Ήμ–΄ cp file1 file2 = file1 νŒŒμΌλ‚΄μš©μ„ file2둜 생성 cp file1 dir1 = file1 νŒŒμΌλ‚΄μš©μ„ dir1 디렉토리에 file1으둜 생성 cp -r dir1 dir2 = -r을 μΆ”κ°€ν•˜μ—¬ dir1을 디렉토리 μ•ˆμ— μžˆλŠ” νŒŒμΌκΉŒμ§€ λ˜‘κ°™μ΄ λ³΅μ‚¬ν•˜μ—¬ dir2λΌλŠ” 폴더λͺ…μœΌλ‘œ λ³΅μ‚¬ν•˜μ—¬ 생성 γ„΄ μ˜΅μ…˜: -r, -i, -f echo 'linux200' > file1

cp file1 dir1 = file1을 dir1에 file1μ΄λΌλŠ” μ΄λ¦„μœΌλ‘œ λ˜‘κ°™μ΄ ν‘œν˜„ linux200μ΄λΌλŠ” λ‚΄μš©μ„ κ°€μ§„ file1을 생성

μ‹€λ¬΄μ˜ˆ - μ„€μ •νŒŒμΌμ„ λ°±μ—…ν•˜λŠ” 경우 cp -p httpd.conf httpd.conf.orig ` cp -a

μ‹€λ¬΄μ˜ˆ - 둜그파일 λΉ„μš°κΈ° 

cp /dev/null file.log

# cat /dev/null > file.log
# > file.log 

μ™€μΌλ“œμΉ΄λ“œ 문자 ls file* = file~λΌλŠ” νŒŒμΌλ“€μ„ λͺ¨λ‘ 검색

mv λͺ…λ Ήμ–΄ mv file1 file3 = ν˜„ 디렉토리 내에 file1을 file3둜 이름을 λ³€κ²½ν•œλ‹€. mv fire* dir1 = file~ 라고 μ‹œμž‘ν•˜λŠ”κ²ƒλ“€μ„ λͺ¨λ‘ dir1 디렉토리에 λ„£λŠ”λ‹€. mv dir 1 dir2 =dir1을 dir2라고 ν•˜κ³  λ³΅μ‚¬ν•΄μ„œ λ„£λŠ”λ‹€. μ˜΅μ…˜: -i, -f

rm λͺ…λ Ήμ–΄ rm -rf = λ¬»μ§€μ•Šκ³  λ°”λ‘œ μ‚­μ œν•˜λŠ” 방법, 주둜 이 방법을 μ‚¬μš©ν•œλ‹€. μ‹€λ¬΄μ˜ˆ: μ§€μš΄ 파일 λ³΅κ΅¬ν•˜κΈ°

rm f

cat cat -n file1 cat file1 file2 > file3 = 파일 3에 1, 2의 λ‚΄μš©μ„ λͺ¨λ‘ μ§‘μ–΄λ„£μŒ cat /etc/services | more = κΈ΄ 좜λ ₯문을 νŽ˜μ΄μ§€ λ‹¨μœ„λ‘œ 보게 ν•΄μ£ΌλŠ” μ½”λ“œ

more cmd cmd | more ps -ef | more cat /etc/serveices | more netstat -an | more systemctl list-unit-files

head cmd head /etc/passwd= κΈΈκ²Œλ‚˜μ˜΄ head -5 /etc/passwd = 5쀄 κΉŒμ§€λ§Œ 좜λ ₯

alias pps='ps -ef | head -1 ; ps -ef | grep $1'

tail cmd tail -f /val/log/massages top tail -f /val/log/massages | egrep -i '(warn|fail|error|crit|alert|emerg)'

ssh μ‚¬μš©μž 이름 = 원격접속 λͺ…λ Ήμ–΄ telnet μ„œλΉ„μŠ€ κΈ°λ™ν•˜κΈ° yun install telnet telnet-server systemctl enable β€”now telnet.socket γ„΄ ν…”λ„·μ„œλ²„ μ‹œμŠ€ν…œμ„ μ„€μΉ˜ν•˜κ³  λ°”λ‘œ 기동 –now 을 λΆ™μ—¬μ£Όλ©΄ λΆ€νŒ…μ΄λž‘ μŠ€νƒ€νŠΈ λ‘˜λ‹€ ν•΄μ€Œ

systemctl start telnet.socket = μ‹œμž‘ν•˜κ³  (--nowλ₯Ό 써주면 x) systemctl enable telnet.socket= λΆ€νŒ…μ‹œμ—λ„ 기동

wc cmd = μ›Œλ“œμΉ΄μš΄νŠΈ wc -c 문자수, -l = 라인수, -w = λ‹¨μ–΄μˆ˜ cat /etc/passwd | wc -l

μΆ”κ°€= rpm = λ ˆλ“œν—·μ—μ„œλ§Œ μ“°λŠ” μ†Œν”„νŠΈμ›¨μ–΄ κ΄€λ¦¬μž (μ„€μΉ˜λœκ±° λ³΄μ—¬μ€Œ) ps -ef ν”„λ‘œμ„ΈμŠ€ 정보λ₯Ό ν‘œμ‹œ μΆ”κ°€= df λͺ…λ Ήμ–΄= λ””μŠ€ν¬μ˜ 남은곡간 μœ„μ£Όλ‘œ 정보λ₯Ό 좜λ ₯ν•΄μ€€λ‹€ μ°Έκ³  = 데이터 μˆ˜μ§‘( data gathering) ps -ef | tail -n +2 | wc -l cat /etc/passwd | wd -l rpm -pq | wc -l cat /val/log/messges | grep β€˜jan 19’ | grep β€˜started Telnet server’ | wc-l = μ„œλ²„κ°€ λͺ‡λͺ…μ”© μ‚¬μš©ν•˜κ³  μžˆλŠ”μ§€ νŒŒμ•…ν•˜λŠ” μš©λ„ 라인카운트둜 μ‚¬μš©μžλ³„ ν•œμ€„μΈκ±Έλ‘œ νŒŒμ•…

su cmd = μ‚¬μš©μž μ „ν™˜ == su μ‚¬μš©μž 이름 su 와 su - 의 차이점 : 이전 μ‚¬μš©μžκ°€ μ‚¬μš©ν•˜κ³  있던 ν™˜κ²½λ³€μˆ˜κ°€ κ·ΈλŒ€λ‘œ μ˜€λŠ”κ°€ γ„΄ μŠ€μœ„μΉ­μ„ ν•  λ•ŒλŠ”, 기본적으둜 su - μ‚¬μš©μžμ΄λ¦„ μ‹μœΌλ‘œ μ‚¬μš©ν•˜λŠ”κ²ƒμ΄ μ’‹λ‹€.

sudo cmd(/etc/sudoers, /etc/sudoers.d/*) sudo su - μ‚¬μš©μž 이름 sudo -l = λͺ©λ‘ 확인 sudo -i = κ΄€λ¦¬μž κ³„μ •μœΌλ‘œ μž„μ‹œμ ‘μ† sudo λͺ…λ Ήμ–΄λ“€ = κΆŒν•œμ„ μž„μ‹œμ μœΌλ‘œ 가져와 κΆŒν•œν•„μš” λͺ…λ Ήμ–΄ μˆ˜ν–‰

su와 sudo의 차이점: suλŠ” μ™„μ „νžˆ 계정을 λ³€ν™˜ν•˜λŠ”κ²ƒμ΄κ³ , sudoλŠ” μž„μ‹œλ‘œ κ°€μ Έμ˜€λŠ”κ²ƒμœΌλ‘œ λ³΄μ•ˆ 상, sudoλ₯Ό μ‚¬μš©ν•˜λŠ”κ²ƒμ΄ λ³΄μ•ˆμƒ μ’‹λ‹€.

μΆ”κ°€ = usermod =μ‚¬μš©μžμ˜ λŒ€ν•œ μˆ˜μ •

id , groups λͺ…λ Ήμ–΄λŠ” κΈ°μ–΅λ§Œ ν•΄λ‘μž γ„΄ λ‹€λ₯Έμ‚¬μš©μžλ‘œ μ „ν™˜ν•˜κ²Œ 되면 ν•œλ²ˆμ”© ν•΄μ£Όμž. μš©μ–΄ = pts/0 – κ°€μƒμ„œλ²„/ 0번째

last cmd ** = λ³΄μ•ˆμƒμœΌλ‘œ μ€‘μš”ν•œ cmd 접속기둝!! last -i last -f /val/log/wtmp.20230128 lastlog(/val/log/lastlog) = μ‚¬μš©μžμ˜ λ§ˆμ§€λ§‰ 둜그인 μ‹œκ°„μ„ μ•Œλ €μ€Œ λ‚΄ μ„œλ²„μ— μ‘΄μž¬ν•˜λŠ” κ³„μ •μ€‘μ—μ„œ 1λ…„λ™μ•ˆ μ ‘μ†ν•˜μ§€ μ•Šμ€ 계정을 μ°Ύκ³  μ‹Άλ‹€! μ‹μœΌλ‘œ μ‚¬μš©μžλ₯Ό κ΅¬λ³„ν•˜μ—¬ μ²˜λ¦¬ν• λ•Œ 검색

lastb cmd = μ‚¬μš©μžλ“€μ˜ λ§ˆμ§€λ§‰ 둜그인 ν–ˆλŠ” 기둝 λͺ©λ‘μ„ 보여쀀닀. lastb (val/log/btmp)= λ‘œκ·ΈμΈμ— μ‹€νŒ¨ν•œ 기둝듀을 μ €μž₯

who cmd ** = μ‚¬μš©μžκ°€ μ‚¬μš©ν•œ λͺ…λ Ήμ–΄λ₯Ό λ³΄μ—¬μ€Œ who = ν˜„μž¬ μ„œλ²„μ— 접속쀑인 λͺ¨λ“  μ‚¬μš©μž γ„΄ (/val/run/utmp) = μ°Έμ‘° 파일경둜

w cmd = 둜그인 된 μ‚¬μš©μžλ“€μ΄ μ‚¬μš©ν•˜λŠ” λͺ…λ Ήμ–΄λ₯Ό 확인 while true ***** (반볡 μ‹€ν–‰λ¬Έ) do cmd sleep 2 donecle μ°Έκ³ - watch cmd

파일 μ’…λ₯˜

링크파일 ν•˜λ“œλ§ν¬νŒŒμΌ = lnμ—μ„œ νŠΉλ³„ν•œ 링크 없이 μ‹€ν–‰ dd if=/dev/zero of=/home/file1 bs=1M count=500 –500메가생성 ln으둜 링크λ₯Ό κ±Έμ–΄ μƒˆλ‘œμš΄ 파일234λ₯Ό 생성 λ‹€λ₯Έκ±Έ μ§€μ›Œλ„ μš©λŸ‰μ„ κ·ΈλŒ€λ‘œ μ°¨μ§€ν•œλ‹€. 즉, 링크λ₯Ό κ±Έμ–΄λ‘” 파일1을 μ§€μ›Œλ„ 링크된 234쀑 ν•˜λ‚˜λΌλ„ μ‚΄μ•„μžˆλ‹€λ©΄ μš©λŸ‰μ„ κ·ΈλŒ€λ‘œ μ°¨μ§€ν•œλ‹€.

심볼릭 링크 파일 = 심볼링크가 더 많이 μ‚¬μš© μš©μ–΄+ λ§ˆμ΄κ·Έλ ˆμ΄μ…˜=파일 이동

-μž₯치 β€” μž₯치 λ“œλΌμ΄λ²„ β€”-/β€”μš΄μ˜μ²΄μ œ μš΄μ˜μ²΄μ œμ—μ„œ μž₯치 λ“œλΌμ΄λ²„λ₯Ό 톡해 μž₯μΉ˜μ— 접근이 κ°€λŠ₯ν•˜λ‹€ μž₯치λ₯Ό μ œμ–΄ν•˜κΈ° μœ„ν•΄ 운영체제 내에 /dev/μž₯μΉ˜μ΄λ¦„ μ‹μœΌλ‘œ μž₯μΉ˜μ— λŒ€ν•œ 정보와 이름을 μ €μž₯ν•˜μ—¬ 이 νŒŒμΌμ„ 톡해 μž₯치λ₯Ό μ œμ–΄,μ ‘κ·Όν•œλ‹€. 즉 μš΄μ˜μ²΄μ œμ—μ„œ μž₯치둜 λ°”λ‘œ 접근이 κ°€λŠ₯ν•œκ²ƒμ΄ μ•„λ‹ˆλΌ 관문에 역할을 μˆ˜ν–‰ν•˜λŠ” μž₯치 λ“œλΌμ΄λ²„λ₯Ό μ„€μΉ˜ν•˜μ—¬ 접근이 κ°€λŠ₯ν•˜λ‹€.

** μ•ˆμ— νŒŒμΌμ„ λ³Ό 수 μžˆλŠ” λͺ…λ Ήμ–΄ : ll 링크 μ΄λ¦„μ΄λ‚˜ κ·Έλƒ₯ ll μ‚¬μš©!!! tty: 가상터미털과 번호λ₯Ό λ³Ό 수 μžˆλ‹€. γ„΄ ll /dev/sda

***----ls -l |grep '^b' ==b둜 μ‹œμž‘ν•˜λŠ”κ²ƒλ§Œ κ²€μƒ‰ν•˜κΈ°!!!

=============================== β€”-----------7μž₯ 파일의 속성관리—---------

β€”----------- rw-r--r-- 1 root root 1945 6μ›” 11 14:13 file1 β€”-------------- File Type : λ³€κ²½ λΆˆκ°€λŠ₯ Permission Mode: chmod Link Count : ln Owner : chown Group : chgrp File Size : Mtime : touch -t File Name : mv

chown cmd =파일의 κΆŒν•œ,μ†Œμœ κΆŒμ„ λ°”κΎΈκΈ° μœ„ν•΄ μ‚¬μš©ν•œλ‹€. chown user01 file1

chown user01.other file1 (# chown user01:other file1)

chown .other file1 (# chown :other file1)

chown -R user01 dir1 = -R은 νšŒκ·€μ μœΌλ‘œ ν•˜λŠ” 뜻! 많이 μ‚¬μš©λœλ‹€.

chown -R user01:other dir1

ls -l file1= 파일1의 κΆŒν•œμ •λ³΄μ™€ 생성 λ‚  확인 # chown -R fedora:fedora /home/fedora

chgrp cmd= 파일의 μ‚¬μš©μž 그룹을 λ°”κΎΌλ‹€. (c hownμœΌλ‘œλ„ λ³€κ²½κ°€λŠ₯)

-chmod cmd = 파일의 μ ‘κ·Ό κΆŒν•œλ³€κ²½(νΌλ―Έμ…˜ λ³€κ²½) γ„΄ ν•˜λ‚˜μ˜ λ¬Έμžκ°€ λͺ…령어듀을 λŒ€ν‘œν•΄μ„œ ν‘œν˜„ν•˜λŠ”κ²ƒ

심볼릭λͺ¨λ“œ == chmod u(μ‚¬μš©μžμ˜ μ•½μžλ“€ 확인) + r (κΆŒν•œ)file1(νŒŒμΌμ΄λ¦„) μ˜₯νƒˆλͺ¨λ“œ(8μ§„μˆ˜λͺ¨λ“œ) ***** (주둜 μ˜₯νƒˆλͺ¨λ“œ μ‚¬μš©!) chmod 744(u_g_o) file1 - μœ μ € κ·Έλ£Ή 기타 (4_2_1) γ„΄ rwx (- - -) (ll둜 κΆŒν•œν™•μΈ)

***** λ””λ ‰ν† λ¦¬μ˜ rwx에 λŒ€ν•΄ r= (ls -l) λͺ©λ‘μ„ λ³Ό 수 μžˆλŠ” κΆŒν•œ w= (디렉토리 μ•ˆμ— 폴더,νŒŒμΌμ— λŒ€ν•œ μˆ˜μ • κΆŒν•œ , 파일이 μ†ν•œ 상단폴더에 wκΆŒν•œμ΄ 있으면 o x= (cd) =디렉토리에 λ“€μ–΄κ°ˆ 수 μžˆλŠ”κ°€? – λ””λ ‰ν† λ¦¬λŠ” rμ΄λ‚˜ w κΆŒν•œμ„ μœ„ν•΄μ„œ λ°˜λ“œμ‹œ xκΆŒν•œμ΄ ν•„μš”ν•˜λ‹€

  • λͺ…λ Ήμ–΄ μ™Έμš°κΈ°! : touch = 파일 생성 mkdir = 폴더 생성 chmod κΆŒν•œ λΆ€μ—¬

umask cmd =파일 디렉토리 μƒμ„±μ‹œ, κΈ°λ³Έ 적용 κΆŒν•œμΈ λ””ν΄νŠΈ νΌλ―Έμ…˜μ„ μ‘°μ •ν•˜λŠ” λͺ…λ Ήμ–΄ γ„΄ 이걸 μ„€μ •ν•΄μ£Όλ©΄ 처음 디렉토리가 μƒμ„±λ˜λ©΄ μ„€μ •ν•œλŒ€λ‘œ μƒμ„±λœλ‹€ umask 022 == κΈ°λ³Έ κΆŒν•œ = 755 umaskκ°€ 클수둝 λ³΄μ•ˆμ΄ 쒋아짐 ** umaskλŠ” μ‹€λ¬΄μ—μ„œ μ™ λ§Œν•˜λ©΄ λ°”κΎΈμ§€λ§ˆλΌ 경둜 = /etc/bashrc(κ΄€λ¦¬μž) $HOME/bashrc(μ‚¬μš©μž)

mac= 잘 μ•Œλ €μ§„ μ„œλΉ„μŠ€λ₯Ό μœ„ν•΄ ν• λ‹Ήν•˜λŠ” 포트 번호 ex)ssh(22).telnet(23),smtp(25) λ“± ip=호슀트λ₯Ό κ΅¬λΆ„ν•˜λŠ” 번호 포트번호=μ„œλΉ„μŠ€λ₯Ό κ΅¬λΆ„ν•˜λŠ” 번호 집을 ip라고 ν•œλ‹€λ©΄ 포트번호λ₯Ό κ°€μ‘± κ΅¬μ„±μ›μœΌλ‘œ 보고 1ν˜Έμ§‘μ˜ μ•„λΉ ,λˆ„λ‚˜ μ΄λŸ°μ‹μœΌλ‘œ ꡬ뢄가λŠ₯

=============================== β€”-----------8μž₯ VI νŽΈμ§‘κΈ°β€”---------

생성, μˆ˜μ • = vi 파일 이름 i,o,O,h = μž…λ ₯λͺ¨λ“œ esc= escλͺ¨λ“œ μ‚¬μš© μ‚­μ œ= x,dd μ €μž₯/μ’…λ£Œ: μ‰¬ν”„νŠΈ+: -μ½”λ“œμž…λ ₯λͺ¨λ“œ- wq! μž…λ ₯μ‹œ μ’…λ£Œ γ„΄ 섀정에 λ”°λΌμ„œ λ°©ν–₯ν‚€λ‚˜ λ”œλ¦¬νŠΈν‚€ κ°€ λ¨Ήμ§€ μ•Šμ„ 수 있기 λ•Œλ¬Έμ— μ•Œμž!

: / 검색할 단어 , : 검색할 쀄 숫자 μ€„λ„˜λ²„ ν‘œμ‹œ: set number 단어 λ‹¨μœ„ 이동: w,b 첫라인,끝라인 이동: 0^, $ (escλͺ¨λ“œ) νŽ˜μ΄μ§€λ‹¨μœ„ 이동: 컨+f, 컨+B (νŽ˜μ΄μ§€)G, κ·Έλƒ₯ GλŠ” λ§‰νŽ˜μ΄μ§€(escλͺ¨λ“œ) vi νŽΈμ§‘κΈ° λͺ¨λ“œ μ’…λ₯˜: λͺ…λ Ήλͺ¨λ“œ,μž…λ ₯λͺ¨λ“œ,μ΅œν•˜μœ„λͺ¨λ“œ

vi νŽΈμ§‘κΈ°μ˜ μ‚­μ œ κΈ°λŠ₯ νŽ˜μ΄μ§€λ₯Ό κ²€μƒ‰ν•˜κ³  μ§€μš°λ©΄ κ²€μƒ‰ν•œμ€„μ˜ μ›Œλ“œλ§Œ μ§€μ›Œμ§„λ‹€ dd λˆ„λ₯΄λ©΄ κ·Έ 쀄 μ‚­μ œ, 3dd λˆ„λ₯΄λ©΄ 3쀄 μ§€μ›Œμ§ 라슀트라인 λͺ¨λ“œμ—μ„œ 11,15d 둜 μž…λ ₯ν•˜λ©΄ 11~15쀄 없어짐 escλͺ¨λ“œμ—μ„œ d1Gλˆ„λ₯΄λ©΄ ν˜„μž¬μ»€μ„œλΆ€ν„° μž…λ ₯μ€„κΉŒμ§€ μ‚­μ œ vi νŽΈμ§‘κΈ°μ˜ μž…λ ₯ κΈ°λŠ₯ i: ν˜„μž¬μ»€μ„œμ—μ„œ μž…λ ₯ - I:ν˜„μž¬μ»€μ„œ μžˆλŠ” ν–‰ μ²˜μŒμ— μž…λ ₯ a:ν˜„μž¬μ»€μ„œ 이후에 μž…λ ₯ -A: ν˜„μž¬μ»€μ„œκ°€ μžˆλŠ”ν–‰ λ§ˆμ§€λ§‰λΆ€ν„° μ‹œμž‘ o:ν˜„μž¬μ»€μ„œ μ•„λž˜ν–‰λΆ€ν„° -O: ν˜„μž¬μ»€μ„œμ˜ μœ„ ν–‰ λΆ€ν„° μ‹œμž‘

κ·Έ λ°–μ˜ μœ μš©ν•œ κΈ°λŠ₯λ“€ λ’€λ‘œκ°€κΈ° : u(escmod) -μ•žμœΌλ‘œκ°€κΈ°: ctrl+r ν˜„μž¬μ»€μ„œ 쀄 볡사: yy -λΆ™μ—¬λ„£κΈ°:p (PλŠ” ν˜„μž¬μ»€μ„œ μœ„λ‘œ λΆ™) yy: μ»€μ„œλ‘œλΆ€ν„° 3쀄 볡사 -1,3 co 5: 13쀄 볡사 18쀄 μ•„λž˜λ‘œ λΆ™ 1,3 m 5: 13쀄을 5쀄 μ•„λž˜λ‘œ 이동 5,10s/^(μ²«μ€„λΆ€ν„°λΌλŠ”λœ»)/#/ : 5~10쀄 μ£Όμ„μ²˜λ¦¬ 5,10s/^/ /:μ•žμ— 4쀄 띄어쓰기 μΆ”κ°€ –ZZ: μ €μž₯ν•˜κ³  λ‚˜κ°€κΈ°(escmod)

Vi νŽΈμ§‘κΈ° ν™˜κ²½μ„€μ • $HOME/ .vimrc(run commend) set nu set ai set ts=4 번호보이기:set number

[μ°Έκ³ ] vim ν™•μž₯자: μ˜ˆμ œν™”μΌ

=============================== β€”---------9μž₯ μ‚¬μš©μžν†΅μ‹ λͺ…λ Ήμ–΄β€”-------

mail cmd: 메일관련 cmd mail λ°›λŠ”μ‚¬λžŒ ctrl+d λˆ„λ₯΄λ©΄ 보냄 mail -u μœ μ €μ΄λ¦„ = κ΄€λ¦¬μž κ³„μ •μ—μ„œ λ‹€λ₯Έ μ‚¬μš©μžμ˜ 메일 탐색가λŠ₯ 외뢀메일보내기 γ„΄ mail -s β€œμ œλͺ©β€ μ΄λ©”μΌμ£Όμ†Œ < /etc/hosts

wall < /etc/MESS/work.txt: txt 파일 μ•ˆμ— 글을 접속 μ‚¬μš©μžμ—κ²Œ 곡지함

[μ°Έκ³ ] touch /etc/nologin(μƒˆλ‘œμš΄ μ‚¬μš©μž 접속 κΈˆμ§€ν•¨) wall < /etc/MESS/work.txt …. fuser -cu /home fuser -ck /home -μž‘μ—…λ“€ μ§„ν–‰- rm -f /etc/nologin(μ‚¬μš©μžλ“€μ˜ λ‘œκ·ΈμΈμ„ λ‹€μ‹œ ν—ˆμš©

talk

wall: μ„œλ²„ 내에 둜그인 λ˜μ–΄ μžˆλŠ” μ‚¬μš©μžμ—κ²Œ λ™μ‹œμ— λ©”μ‹œμ§€λ₯Ό 전솑 wall β€œλ©”μ‹œμ§€β€

=============================== β€”---------10μž₯ μœ μš©ν•œ λͺ…λ Ήμ–΄β€”-------

cmp/diff cmd: νŒŒμΌμ„ 비ꡐ할 λ•Œ μ‚¬μš©ν•œλ‹€. λ‘κ°œνŒŒμΌμ΄ λ‹€λ₯΄λ©΄ λ‹€λ₯Έ λΆ€λΆ„μ˜ 쀄과 ν‹€λ¦° λΆ€λΆ„μ˜ μš©λŸ‰μ„ μ•Œλ €μ€€λ‹€.

cmp λΉ„κ΅νŒŒμΌ1 λΉ„κ΅νŒŒμΌ2 : ν‹€λ¦° μ€„μ΄λž‘ μš©λŸ‰λ§Œ 좜λ ₯ diff λΉ„κ΅νŒŒμΌ1 λΉ„κ΅νŒŒμΌ2 : ν‹€λ¦° λΆ€λΆ„κΉŒμ§€ 좜λ ₯ν•΄μ€Œ diff -c λΉ„κ΅νŒŒμΌ1 λΉ„κ΅νŒŒμΌ2 : 파일1,2 전체λ₯Ό λ³΄μ—¬μ€˜ 비ꡐ diff -r λ””λ ‰1 λ””λ ‰2= 디렉토리 내에 λ‹€λ₯Έμ΄λ¦„μ˜ νŒŒμΌμ„ μ•Œλ €μ€Œ diff httpd.conf httpd.conf.OLD λ₯Ό μž…λ ₯ν•œλ‹€λ©΄ μˆ˜μ •λœ 점 ν‘œμ‹œ

[싀무 예] μ„€μ •νŒŒμΌ 비ꡐ diff httpd.conf httpd.conf.OLD [싀무 예] 디렉토리 λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ μ’…λ£Œ ν›„ 비ꡐ diff -r /wal1 /wal2

sort cmd : μ •λ ¬ λͺ…λ Ήμ–΄ -sort νŒŒμΌμ΄λ¦„ -r λ‚΄λ¦Όμ°¨μˆœ -sort νŒŒμΌμ΄λ¦„ -k 3(3번째 ν•„λ“œλΆ€ν„°) -n(μˆ«μžμ •λ ¬): ν•„λ“œ μ§€μ • μ •λ ¬ γ„΄ 3번째 ν•„λ“œλΆ€ν„° (uid κ΅¬λΆ„μœΌλ‘œ) -sortλ₯Ό ν™œμš©ν•œ 정렬방식 γ„΄ ps -ef | head | sort -k 3(μˆ«μžμ •λ Ή), -μ›ν•˜λŠ” 영문 γ„΄ sort -k 3 = 3번째 ν•„λ“œλ₯Ό μ€‘μ‹¬μœΌλ‘œ νŒŒμΌμ„ μ •λ ¬( -n=숫자, -nr λ°˜λŒ€) [μ‹€λ¬΄μ˜ˆ] μš©λŸ‰ ν™•μΈν•˜κΈ°! γ„΄ du -sk * | sort -nr = μš©λŸ‰μ΄ 큰 순으둜 보기

file cmd [cmd] file /etc/passwd 파일의 ν™•μž₯자,μ’…λ₯˜λ₯Ό μ•Œλ €μ€Œ γ„΄# file /etc/hosts /etc = μ—¬λŸ¬κ°œ 파일 μ§€μ • [μ—…λ¬΄μ—μ„œμ˜ 경우] γ„΄ ν™•μž₯μžκ°€ λ³€κ²½λ˜λŠ” μ˜ˆμ— λŒ€ν•΄μ„œ λ‹€λ₯Έμ’…λ₯˜μ˜ 운영체제 κ°„μ˜ 파일 전솑이 λ§Žμ€κ²½μš°, 파일의 ν™•μž₯μžκ°€ λ³€ν•˜λŠ” κ²½μš°κ°€ μ’…μ’… μžˆλ‹€. =λ¦¬λˆ…μŠ€.txt ->μœˆλ„μš°.txt = μ΄λ ‡κ²Œ λ°˜λ³΅ν•˜λ‹€λ³΄λ©΄ ν™•μž₯μžκ°€ 사라지기도함

[κΉ¨μ•Œμ½”λ“œ[ = 이름 λ³€κ²½: mv λ³€κ²½ν•  파일 λ³€κ²½ν›„ 이름 -파일 μ••μΆ•ν•˜κΈ°: zip file.zip μ••μΆ•ν•  νŒŒμΌλ“€ 이름 -파일 μ••μΆ•ν•΄μ œ: unzip μ••μΆ•νŒŒμΌ.zip

-l (-l : list files) νŒ¨ν„΄μ΄ μžˆλŠ” νŒŒμΌμ΄λ¦„λ§Œμ„ 좜λ ₯ν•œλ‹€. -n (-n : number line) νŒ¨ν„΄μ„ ν¬ν•¨ν•˜λŠ” 쀄을 좜λ ₯ν•  λ•Œ μ€„λ²ˆν˜Έμ™€ ν•¨κ»˜ 좜λ ₯ν•œλ‹€. -v (-v : inVerse, except) νŒ¨ν„΄μ„ ν¬ν•¨ν•˜λŠ” 쀄을 μ œμ™Έν•˜κ³  좜λ ₯ν•œλ‹€. -c (-c : count) νŒ¨ν„΄μ„ 찾은 μ€„μ˜ 수λ₯Ό 좜λ ₯ν•œλ‹€. -i (-i : ignore case, λŒ€λ¬Έμž/μ†Œλ¬Έμž) νŒ¨ν„΄μ„ 찾을 λ•Œ λŒ€μ†Œλ¬Έμžλ₯Ό κ΅¬λΆ„ν•˜μ§€ μ•ŠλŠ”λ‹€.

grep cmd grep option β€˜pattern’ file1 options: -i,-l,-v,-r,-n,--color, -A pattern: * . ^root root$ [abc] [a-c] [^a](aκ°€ μ•„λ‹ˆλ©΄ 띄움)

cmd | grep root γ„΄ cat /etc/passwd

[μ‹€μŠ΅μ˜ˆ] cat /var/log/messages | egrep -i '(warn|err|fail|crit|alert|emerg)' γ„΄ λ©”μ‹œμ§€ λ‘œκ·Έμ—μ„œ egrep으둜 μ—¬λŸ¬κ°œμ˜ ν‚€μ›Œλ“œλ₯Ό 같이 검색!

=alias 등둝 μ½”λ“œ = #!/bin/bash

if [ $# -ne 1 ] ; then echo "Usage: $0 " exit 1 fi

export LANG=C RE1=$(date +'%b') RE2=$(date +'%d') if [ $RE2 -le 9 ] ; then RE2=$(echo $RE2 | cut -c2-) RE2=" $RE2" fi cat $1 | egrep "$RE1 $RE2" | egrep -i --color 'warn|errror|fail|crit|alert|emerg'

-find cmd β–  자주 μ‚¬μš©λ˜λŠ” find λͺ…λ Ήμ–΄ ν˜•μ‹λ“€

(ν˜•μ‹1) # find / -name core -type [f|d] (# find / -name "oracle" -type f) (ν˜•μ‹2) # find / -user user01 -group class1 (ν˜•μ‹3) # find / -mtime [-7|7|+7] (ν˜•μ‹4) # find / -perm [-755|755] (ν˜•μ‹5) # find / -size [-300M|300M|+300M] (ν˜•μ‹6) # find / -name core -type f -exec rm -f {} ;

-find .(.은 ν˜„μž¬ 폴더 μ•„λž˜μ— λŒ€ν•΄μ„œ) , /(μƒμœ„ν΄λ”μ— λŒ€ν•΄) find . -mtime 3 -type f (μˆ˜μ •μΌμ΄ 3일전 파일 검색) find . -mtime -3 -type f (μˆ˜μ •μΌμ΄ 3일일 μ•ˆλœ 파일) find . -mtime +3 -type f(μˆ˜μ •μΌμ΄ 3일이 지남)

find . -perm -400 -type f -ls γ„΄ κΆŒν•œμ„ -400 μ΄ν•˜λ‘œ κ°€μ§„ μ• λ“€ 뢈러였기 find . -perm 400 -type f -ls γ„΄ κΆŒν•œμ΄ 400인 νΌλ―Έμ…˜ 파일 μ°ΎκΈ°

[μ‹€λ¬΄μ˜ˆ] 였래된 둜그 파일 μ‚­μ œ

find /Log_Dir1 -name "*.log" -type f -mtime +30 -exec rm -f {} ;

find /Log_dir2 -name "*.log" -type f -mtime +60 -exec rm -f {} ;

[μ‹€λ¬΄μ˜ˆ] νŒŒμΌμ‹œμŠ€ν…œμ΄ κ°‘μžκΈ° ν’€(Full) λ‚˜λŠ” 경우 예

find /var -mtime -2 -size +1G -type f

find /var -mtime -2 -size +512M -type f

γ„΄ 양일간에 μˆ˜μ •λœ νŒŒμΌλ“€ μ€‘μ—μ„œ μš©λŸ‰μ΄ 1κΈ°κ°€ 이상인것
   γ„΄ μ•ˆλ‚˜μ˜€λ©΄ 반으둜 μ€„μ—¬μ„œ ν•œ 번 더 검색. μ΄λŸ°μ‹μœΌλ‘œ 쀄여가며!

/var/server/log/file.log - μ΄λŸ°μ‹μœΌλ‘œ κ²€μƒ‰ν•΄μ„œ μš©λŸ‰μ΄ 큰 파일이 λ‚˜μ˜€λ©΄! γ„΄ lsof(list open file)

lsof | grep /var/server/log/file.log = μ–΄λ–€ ν”„λ‘œμ„ΈμŠ€κ°€ 이 νŒŒμΌμ„ 작고 μžˆλŠ”μ§€ ν™•μΈν•œλ‹€ !

[μ‹€λ¬΄μ˜ˆ] μ—λŸ¬ λ©”μ„Έμ§€ 검색 (μ†ŒμŠ€μ½”λ“œκ°€ μ‘΄μž¬ν•˜λŠ” 경우) μ†Œλ“œμ½”λ“œO: find /src -type f -exec grep -l β€˜server Error’ {} ; γ„΄ μˆ˜λ§Žμ€ 파일 쀑 μ„œλ²„ μ—λŸ¬λΌκ³  λœ¨λŠ”κ±Έ 찾아라 μ†ŒμŠ€μ½”λ“œX: κ΅¬κΈ€κ²€μƒ‰μœΌλ‘œ site:redhat.com β€œServer Error” μ‹μœΌλ‘œ 검색찾기!

β€”---------12μž₯ μ••μΆ•κ³Ό 아카이빙—-------

μ••μΆ• (효율 gzip<bzip<xz) [gzip/gunzip cmd] -gunzip -c file1.gz (-cλŠ” 파일 잠깐 ν’€μ–΄μ„œ μ•ˆμ„ 확인함, -dλŠ” μ••μΆ•ν•΄μ œ) -gzip -v file2( -vλŠ” 쀑간에 μ••μΆ•ν•˜λŠ”κ±Έ ν…μŠ€νŠΈλ‘œ 좜λ ₯) -gzip file1 = file1을 μ••μΆ• -gunzip file1 = μ••μΆ•ν•΄μ œ

[zcat] zcat file1.gz νŒŒμΌμ„ μž μ‹œ μ—΄μ–΄μ„œ ν™•μΈν•΄μ„œ μ•ˆκΉ¨μ§
γ„΄ μ••μΆ•νŒŒμΌμ„ μ›λž˜ cat으둜 ν™•μΈν•˜λ©΄ κΉ¨μ§„λ‹€

[bzip2/bunzip2 cmd] -bzip2 file1 =μ••μΆ• -bunzip2 -c file1.bz2 =μ••μΆ•ν•΄μ œ1 -bzip2 -d file1.bz2 =μ••μΆ•ν•΄μ œ2

[xz/unxz cmd] -xz file1 = μ••μΆ• -unxz -c file1.xz =μ••μΆ•νŒŒμΌ 확인 -unxz file1.xz = μ••μΆ• ν•΄μ œ

아카이빙 tar cvzf file.tar.gz file1 file2 tar tvzf file.tar gz tar xvzf file.tar gz tar cvjf file.tar.gz file1 file2 tar tvjf file.tar gz tar xvjf file.tar gz tar cvJf file.tar.gz file1 file2 tar tvJf file.tar gz tar xvJf file.tar gz

(싀무 예) 인터넷상에 받은 파일 μ••μΆ• ν•΄μ œ 방법 file.gz ---- gzip -----> # gunzip file.gz (# gzip -d file.gz) file.bz2 ---- bzip2 ----> # bunzip2 file.bz2 (# bzip2 -d file.bz2) file.xz ---- xz -------> # unxz file.xz (# xz -d file.xz) file.tar.gz ---- tar/gzip -> # tar xvzf file.tar.gz (# tar xvf file.tar.gz) file.tgz file.tar.bz2 ---- tar/bzip2-> # tar xvjf file.tar.bz2 (# tar xvf file.tar.bz2) file.tbz file.tar.xz ---- tar/xz ---> # tar xvJf file.tar.xz (# tar xvf file.tar.xz) file.txz file.zip ---- zip ------> # unzip file.zip file.jar ---- jar ------> # jar xvf file.jar

=============================== β€”---------13μž₯ λ°°μ‹œμ‰˜νŠΉμ„±β€”-------

β€“λ¦¬λ‹€μ΄λ ‰μ…˜β€“ μž…λ ₯ λ¦¬λ‹€μ΄λ ‰μ…˜ -wall < /etc/MESS/work.txt 좜λ ₯ λ¦¬λ‹€μ΄λ ‰μ…˜ -ls -l

[특수문자의미] >의 κ°―μˆ˜μ— λ”°λ₯Έ 의미차이! CMD 2> filename λ³€κ²½ CMD 2>> filename λ‚΄μš©μΆ”κ°€ν•΄μ„œ λ³€κ²½ν•΄μ€Œ

μ—λŸ¬ λ¦¬λ‹€μ΄λ ‰μ…˜ [cmd] ls -l /test /nodir > dirfilename1 ㄴ정상적인 좜λ ₯ κ²°κ³Όλ₯Ό 파일둜 μƒˆλ‘œ λ§Œλ“€μ–΄μ„œ μ €μž₯

ls /test /nodir > dirfilename 2>&1

γ„΄ dirfilename1에 μ •μƒμΆœλ ₯결과와 μ—λŸ¬μΆœλ ₯κ²°κ³Όλ₯Ό 같이 μ €μž₯

[μ‹€μŠ΅μ˜ˆ] 슀크립트 둜그 파일 생성

./script.sh > script.log 2>&1

[μ‹€μŠ΅μ˜ˆ] 좜λ ₯ λ‚΄μš©μ΄ κΈ΄ λͺ…λ Ήμ–΄ μˆ˜ν–‰ μ‹œ, 좜λ ₯ ν™”λ©΄ 뢄석

configure > config.log 2>&1

γ„΄ κΈ΄ config 좜λ ₯문을 config.log에 λ„£μ–΄μ„œ 확인

[μ‹€μŠ΅μ˜ˆ] μΌλ°˜μ‚¬μš©μžκ°€ λͺ…λ Ή μˆ˜ν–‰μ‹œ μ—λŸ¬ λ©”μ„Έμ§€λ₯Ό μ§€μš°λŠ” 경우 $ find / -name core -type f > 2>/dev/null γ„΄ μΌλ°˜μ‚¬μš©μžκ°€ λ³Ό 경우 μ—λŸ¬κ°€ 많이 뜰 수 μžˆμœΌλ‹ˆ μ—λŸ¬λŠ” λΉΌκ³  검색!

β€“νŒŒμ΄ν”„ = λͺ…λ Ήμ–΄λ₯Ό 가곡 μ‹œ μ‚¬μš©. μΆ”κ°€ λͺ…λ Ήμ–΄!-- β–  Pipe(|) κΈ°ν˜Έκ°€ 많이 μ‚¬μš©λ˜λŠ” ν˜•μ‹

CMD | more

CMD | grep rsyslogd

CMD | CMD | …

[μ‹€λ¬΄μ˜ˆ] λͺ¨λ‹ˆν„°λ§ ꡬ문 + 데이터 μˆ˜μ§‘ (cmd | tee -a httpd.cnt) while true do ps -ef | gerp httpd | wc -l | tee -a httpd.cnt sleep done

[μ‹€μŠ΅μ˜ˆ] μ—¬λŸ¬ 터미널 화면을 κ³΅μœ ν•˜λŠ” 경우 #script -a /dev/null | tee /dev/pts/1 | tee /dev/pts/2 슀크립트 곡유 터미널 1 경둜 터미널2 경둜 (tty둜 확인)

β€“λ°°μ‹œμ‰˜ κΈ°λŠ₯–

set -o /* μ‰˜ 자체의 κΈ°λŠ₯ 전체 λͺ©λ‘ 확인 */

set -o vi /* μ‰˜ 자체의 κΈ°λŠ₯ 쀑 vi κΈ°λŠ₯을 ON */

set +o vi /* μ‰˜ 자체의 κΈ°λŠ₯ 쀑 vi κΈ°λŠ₯을 OFF */

[κΉ¨μ•Œμ½”λ“œ] txt νŒŒμΌμ— 문자λ₯Ό λ°”λ‘œ λ„£μ–΄μ„œ 생성 γ„΄ echo 1111(λ‚΄μš©) > λ§Œλ“  λ¬Έμ„œμ˜ 이름

β€“λ³€μˆ˜β€“ μ§€μ—­λ³€μˆ˜ - exportλ₯Ό μ•ˆμ“°λ©΄ μ§€μ—­λ³€μˆ˜ ν™˜κ²½λ³€μˆ˜ - export둜 μ „μ—­ 섀정을 ν•΄μ£Όλ©΄ ν™˜κ²½λ³€μˆ˜ νŠΉμˆ˜λ³€μˆ˜ - $$ $? $! $1,2 $# $* λ³€μˆ˜μ˜ 선언방법 γ„΄ export VAR=5 γ„΄ echo $VAR γ„΄ unset VAR

[μ‹œμŠ€ν…œ/ μ‰˜ ν™˜κ²½λ³€μˆ˜(set/env)] PS1 λ³€μˆ˜: export PS1=’[\u@\h \w]$ ’ home/.bashrc λͺ…λ Ήμ–΄ λ§ˆμ§€λ§‰μ— \을 μ‚¬μš©ν•˜λ©΄ λ‹€μŒμ€„λ‘œ λ„˜μ–΄κ°€μ„œ μ΄μ–΄μ„œ μ“°λ©΄ 됨. 보톡 λͺ…λ Ήμ–΄κ°€ λ„ˆλ¬΄ κΈΈμ–΄μ„œ 확인이 νž˜λ“€λ•Œ λ‹€μŒμ€„λ‘œ μΆ”κ°€ λͺ…λ Ή μž…λ ₯ PATH λ³€μˆ˜: export PATH=$PATH:/root/scripts ($home/.bash_profile) HOME λ³€μˆ˜ PWD λ³€μˆ˜ USER λ³€μˆ˜ LOGNAME λ³€μˆ˜ UID λ³€μˆ˜ TERM: export TERM=vt100 LANG: export LANG=ko_LR.UTF-8

–메타캐릭터– β€œβ€ β€˜β€™ `` \ ;

–cmd νžˆμŠ€ν† λ¦¬β€“ HISTSIZE=512 크기 μ§€μ • HISTFILE=$HOME/.BASH_HISTORY = κ²½λ‘œμ§€μ • HISTFILESIZE=

β€“μ—˜λ¦¬μ–΄μŠ€β€“ = μ€„μž„λ§λ‘œ λ§Œλ“€κΈ°!***** alias aa='cd /test && rm -rf /test/*' =aaλ₯Ό ν…ŒμŠ€νŠΈν΄λ” λΉ„μš°κΈ°λ‘œ μ‚¬μš©

β€“ν™˜κ²½νŒŒμΌβ€“ /etc/profile

root user01 user02

~/.bash_profile	~/.bash_profile		~/. bash_profile	
~/.bashrc		~/.bashrc			~/.bashrc

-/etc/profile - /.bash_profile -/.bashrc

=============================== β€”---------14μž₯ ν”„λ‘œμ„Έμ„œ 관리—-------

[ν”„λ‘œμ„Έμ„œ 정보] (/proc/PID/*) 에 ν”„λ‘œμ„Έμ„œμ— λŒ€ν•œ 정보가 있음 ν”„λ‘œμ„ΈμŠ€μ˜ μ •λ³΄λŠ” /proc/*에 쑴재 μ •λ°€ 검색 μ‹œ, ps -ef |grep νŒŒμΌμ΄λ¦„ 으둜 검색

[ν”„λ‘œμ„Έμ„œ 관리] ν”„λ‘œμ„ΈμŠ€ 관리1 1.ν”„λ‘œμ„ΈμŠ€ μ‹€ν–‰ -fg) # gedit -bg) # gedit & (λ„μš΄μƒνƒœλ‘œ λͺ…λ Ήμ–΄ μž…λ ₯ κ°€λŠ₯)

  1. ν”„λ‘œμ„ΈμŠ€ 확인 -ps -f =- f(full listing)λŠ” 더 λ§Žμ€ 인자, μ˜΅μ…˜μ„ 확인 ν•  수 있게 ν•΄μ€€λ‹€. -ps -e= e(every)μ˜΅μ…˜μ€ νŠΉμ • 터미널이 μ•„λ‹Œ 데λͺ¬ ν”„λ‘œμ„Έμ„œλ„ 좜λ ₯

  2. ν”„λ‘œμ„ΈμŠ€ μ’…λ£Œ (kill pidμž…λ ₯)

kill - 1|-2|-9|-15 PID PID

1 SIGHUP ν”„λ‘œμ„ΈμŠ€ μž¬μ‹œμž‘(HangUp), ν„°λ―Έλ„μ˜ μ œμ–΄ ν”„λ‘œμ„ΈμŠ€ μ’…λ£Œλ₯Ό λ³΄κ³ ν•˜λŠ” 데 μ‚¬μš©ν•œλ‹€. λ˜ν•œ ν”„λ‘œμ„ΈμŠ€λ₯Ό μ’…λ£Œν•˜μ§€ μ•Šκ³  λ‹€μ‹œ μ΄ˆκΈ°ν™”(μ„€μ • μž¬λ‘œλ“œ)ν•˜λŠ” 데에도 μ‚¬μš©ν•œλ‹€. (EX): # kill -1 450 2 SIGINT ν‚€λ³΄λ“œ μΈν„°λŸ½νŠΈ(Interrupt, <Ctrl + C>), ν”„λ‘œκ·Έλž¨μ΄ μ’…λ£Œλœλ‹€. μ°¨λ‹¨ν•˜κ±°λ‚˜ μ²˜λ¦¬ν•  수 μžˆλ‹€. (EX): # kill -2 450 3 SIGQUIT ν‚€λ³΄λ“œ μ’…λ£Œ(CTRL + ), SIGINT와 μœ μ‚¬ν•˜μ§€λ§Œ μ’…λ£Œν•  λ•Œ ν”„λ‘œμ„ΈμŠ€ 덀프가 λ°œμƒλœλ‹€. (EX): # kill -3 450 9 SIGKILL κ°•μ œ μ’…λ£Œ(force exit signal), κ°‘μž‘μŠ€λŸ½κ²Œ ν”„λ‘œκ·Έλž¨μ΄ μ’…λ£Œλœλ‹€. 차단, λ¬΄μ‹œ λ˜λŠ” μ²˜λ¦¬ν•  수 μ—†λ‹€. 항상 치λͺ…적이닀. (EX): # kill -9 450 15 SIGTERM 정상 μ’…λ£Œ(exit), κΈ°λ³Έ μ‹œκ·Έλ„, ν”„λ‘œκ·Έλž¨μ΄ μ’…λ£Œλœλ‹€. SIGKILLκ³Ό 달리 차단, λ¬΄μ‹œ λ˜λŠ” 처리 ν•  수 μžˆλ‹€. ν”„λ‘œκ·Έλž¨ μ’…λ£Œλ₯Ό μ •μ€‘μΉ˜ μš”μ²­ν•˜λŠ” 방법이닀. 자체 클린업(cleanup)이 κ°€λŠ₯ν•˜λ‹€.
(EX): # kill -15 450) 18 SIGCONT ν”„λ‘œμ„ΈμŠ€κ°€ μ€‘μ§€λœ 경우 μž¬κ°œν•˜κΈ° μœ„ν•΄ μ „μ†‘λœλ‹€. 차단할 수 μ—†λ‹€. μ²˜λ¦¬ν•˜λ”λΌλ„ 항상 ν”„λ‘œμ„ΈμŠ€κ°€ μž¬κ°œλœλ‹€. (EX): # kill -18 450 19 SIGSTOP ν”„λ‘œμ„ΈμŠ€λ₯Ό μΌμ‹œ μ€‘μ§€ν•œλ‹€. 차단 λ˜λŠ” μ²˜λ¦¬ν•  수 μ—†λ‹€. (EX): # kill -19 450 20 SIGTSTP ν‚€λ³΄λ“œ 쀑지, SIGSTOP와 달리 차단, λ¬΄μ‹œ λ˜λŠ” μ²˜λ¦¬ν•  수 μžˆλ‹€. SUSP ν‚€ μ‘°ν•©(CTRL + Z)을 μ‚¬μš©ν•œλ‹€.

ν”„λ‘œμ„ΈμŠ€ (작, job) 관리2 β€’ 작 μ‹€ν–‰ fg) # ls bg) # ls & β€’ 작 확인

jobs

fg %1

bg %1

β€’ 작 μ’…λ£Œ

kill %1

[ν”„λ‘œμ„Έμ„œ λͺ¨λ‹ˆν„°λ§]

lsof (# lsof -P) = λ‚΄ ν”„λ‘œμ„Έμ„œκ°€ μ—΄κ³  μžˆλŠ” λͺ¨λ“  화일을 λ³΄μ—¬μ€Œ

lsof <νŒŒμΌμ΄λ¦„>

# lsof /usr/sbin/sshd
# lsof /tmp
# lsof /dev
# lsof /home/user01

lsof -c <데λͺ¬λͺ…>

# lsof /usr/sbin/sshd

lsof -c sshd (# lsof | grep '^sshd')

lsof -p <PID번호>

# lsof -p 450

lsof -i

# lsof -i 		(# netstat -antup)
# lsof -i TCP	(# netstat -antp)
# lsof -i UDP	(# netstat -anup)

=============================== β€”---------15μž₯ 원격접속과 νŒŒμΌμ „μ†‘β€”-------

[νŒŒμΌμ „μ†‘] scp cmd # scp file1 server2:file2 =보내기

scp server2:/tmp/file2 /test/file1 =κ°€μ Έμ˜€κΈ°

scp -r dir1 server2:/tmp

sftp cmd
#

[원격접속] ssh cmd

=============================== -----1μž₯ 디렉토리ꡬ쑰—-------

디렉토리 λͺ©μ  / λͺ¨λ“  λ””λ ‰ν† λ¦¬μ˜ κ°€μž₯ μƒμœ„ 디렉토리이닀. Root 파일 μ‹œμŠ€ν…œμ΄λΌκ³ λ„ λΆˆλ¦°λ‹€. λͺ¨λ“  파일 μ‹œμŠ€ν…œμ˜ 마운트 ν¬μΈνŠΈκ°€ μ‘΄μž¬ν•œλ‹€.

/usr μ„€μΉ˜λœ μ†Œν”„νŠΈμ›¨μ–΄, 곡유 라이브러리 ν¬ν•¨λœ 파일 및 읽기 μ „μš© ν”„λ‘œκ·Έλž¨ 데이터, μ€‘μš”ν•œ ν•˜μœ„ λ””λ ‰ν† λ¦¬μ—λŠ” λ‹€μŒμ΄ ν¬ν•¨λœλ‹€. β€’ /usr/bin : μ‚¬μš©μž λͺ…λ Ή β€’ /usr/sbin : μ‹œμŠ€ν…œ 관리 λͺ…λ Ή β€’ /usr/local : 둜컬 μ‚¬μš©μž μ§€μ • μ†Œν”„νŠΈμ›¨μ–΄ (EX) (Win)Program Files

/etc 섀정에 κ΄€λ ¨λœ νŒŒμΌλ“€μ΄ 쑴재, μ‹œμŠ€ν…œ 고유의 ꡬ성 파일이 μ‘΄μž¬ν•œλ‹€. β€’ OS λΆ€νŒ…μ‹œ μ„€μ • 정보 β€’ μ„œλΉ„μŠ€ μ„€μ • 파일 β€’ λ³΄μ•ˆ, 기타 μ—¬λŸ¬κ°€μ§€ μ„€μ • νŒŒμΌλ“€μ΄ 쑴재 (EX) (Win)μ œμ–΄νŒ

/var μž¬λΆ€νŒ… 후에도 μœ μ§€λŠ” μ‹œμŠ€ν…œ 고유의 κ°€λ³€ 데이터가 μ‘΄μž¬ν•œλ‹€. λ™μ μœΌλ‘œ λ³€κ²½λ˜λŠ” 파일(예: λ°μ΄ν„°λ² μ΄μŠ€, μΊμ‹œ 디렉토리, 둜그파일, ν”„λ¦°ν„°λ‘œ μ „μ†‘λœ λ¬Έμ„œ, μ›Ή μ‚¬μ΄νŠΈ μ½˜ν…μΈ )은 /var에 μ‘΄μž¬ν•  수 μžˆλ‹€. β€’ /var/log/* : 둜그 디렉토리

/run λ§ˆμ§€λ§‰ λΆ€ν‹° 이후 μ‹œμž‘λœ ν”„λ‘œμ„ΈμŠ€μ˜ λŸ°νƒ€μž„ 데이터이닀. μ—¬κΈ°μ—λŠ” ν”„λ‘œμ„ΈμŠ€ ID 파일과 잠금 파일 등이 ν¬ν•¨λœλ‹€. 디렉토리 λ‚΄μš©μ€ μž¬λΆ€νŒ…ν•˜λ©΄ λ‹€μ‹œ μƒμ„±λœλ‹€. 이 λ””λ ‰ν† λ¦¬λŠ” 이전 λ²„μ „μ˜ CentOS에 있던 /var/run, /var/lock을 ν†΅ν•©ν•œλ‹€. β€’ {/var/run|/var/lock} -> /run

/home 일반 μ‚¬μš©μžμ˜ ν™ˆ 디렉토리이닀. 일반 μ‚¬μš©μžμ˜ 개인 데이터 및 ꡬ성 νŒŒμΌμ„ μ €μž₯ν•˜λŠ” 디렉토리이닀. (EX) (Win)C:\Users\soldesk\

/root root μ‚¬μš©μž ν™ˆ 디렉토리이닀.

/tmp μ–΄λ””μ—μ„œλ‚˜ μ“Έ 수 μžˆλŠ” μž„μ‹œνŒŒμΌμš© 곡간이닀. 10μΌλ™μ•ˆ μ—‘μ„ΈμŠ€, λ³€κ²½ λ˜λŠ” μˆ˜μ •λ˜μ§€ μ•Šμ€ νŒŒμΌμ€ 이 λ””λ ‰ν† λ¦¬μ—μ„œ μžλ™μœΌλ‘œ μ‚­μ œλœλ‹€. λ‹€λ₯Έ μž„μ‹œ λ””λ ‰ν† λ¦¬λŠ” /var/tmp에 μ‘΄μž¬ν•œλ‹€. 30일 이상 μ—‘μ„ΈμŠ€, λ³€κ²½ λ˜λŠ” μˆ˜μ •λ˜μ§€ μ•Šμ€ νŒŒμΌμ€ μžλ™μœΌλ‘œ μ‚­μ œλœλ‹€. (EX) (Win)TMP=C:\Users\soldesk\AppData\Local\Temp

/boot λΆ€νŒ… ν”„λ‘œμ„ΈμŠ€λ₯Ό μ‹œμž‘ν•˜λŠ” 데 ν•„μš”ν•œ νŒŒμΌλ“€μ΄ μ‘΄μž¬ν•œλ‹€. β€’ Boot Loader(GRUB) β€’ 컀널(Kernel) β€’ λž¨νŒŒμΌμ‹œμŠ€ν…œ(initrd)

/dev μ‹œμŠ€ν…œμ—μ„œ ν•˜λ“œμ›¨μ–΄μ— μ—‘μ„ΈμŠ€ ν•˜λŠ” 데 μ‚¬μš©λ˜λŠ” 특수 μž₯치 νŒŒμΌμ„ ν¬ν•¨ν•œλ‹€. (EX) (Win)μž₯μΉ˜κ΄€λ¦¬μž

media/ usb 같은 μž„μ‹œ 마운트 포인트둜 μ‚¬μš©λ˜λŠ”κ²ƒ mnt/ ""

=============================== -----2μž₯ μž₯μΉ˜μΈμ‹κ³Ό νŒŒν‹°μ…˜μž‘μ—…β€”-------

-----------------[Git μ‚¬μš©λ²• *****]----------------- GIT μ‚¬μ΄νŠΈ : https://github.com/

  1. git 계정 생성
  2. github repository 생성
  3. 올릴 파일 μ€€λΉ„ + .gitignore = 곡개λ₯Ό ν•˜μ§€ μ•Šμ€ 파일,디렉토리λ₯Ό μ§€μ • + README.md + bin/.sh + doc/.hwp + env/*.bashrc.txt
  4. 파일 올리기: https://github.com/shb003/01_LinuxEssential.git ------------------------------------------------ echo "# 01_LinuxEssential" >> README.md git init = ν˜„μž¬ 폴더 μ•„λž˜ git와 연동할 λ‘œμ»¬ν΄λ”λ₯Ό 생성 git add README.md = νŒŒμΌμ„ git 섀정에 μΆ”κ°€ (μ €μž₯ν•΄μ€˜μ•Όν•¨) git commit -m "first commit" git branch -M main -μ΄ˆκΈ°κ΅¬μ„± git remote add origin https://github.com/shb003/01_LinuxEssential.git γ„΄ λ‚˜μ˜ 원격 μ €μž₯μ†Œμ— 이름을 뢙인닀. -μ΄ˆκΈ°κ΅¬μ„± git push -u origin main
λΈŒλŸ°μΉ˜λž‘ 리λͺ¨νŠΈ 섀정이 끝났닀면
git add README.md -νŒŒμΌμΆ”κ°€
git commit -m "first commit" - νŒŒμΌμ— λŒ€ν•œ μ„€λͺ… μΆ”κ°€ (ν•„μˆ˜)
git push -u origin main - gitμ‚¬μ΄νŠΈμ— λ‚΄κ°€ μž…λ ₯ν•œ 파일 정보듀을 μž…λ ₯

------------------------------------------------------

branch(κ°€μ§€)name : git config --global init.defaultBranch <name>
			      git config --global user.name "shb003"
				  git config --global user.email "dodoto999@gmail.com"
(*) 둜그인이 μ•ˆλœλ‹€λ©΄ ν† ν°λ°©μ‹μœΌλ‘œ λ³€κ²½ν•΄μ•Όν•œλ‹€
[token λ§Œλ“€κΈ°]
git μ‚¬μš©μž 접속 - λ””λ²¨λ‘œνΌ μ…‹νŒ… - 개인 접속 코인 - 토큰(ν΄λž˜μ‹)
γ„΄ shb003 Token = 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
 γ„΄ token push μž‘μ—…
	- git push -u origin main
-------------------------------------------------------------
[μƒˆλ‘œμš΄ 파일 μΆ”κ°€]
touch addfile.txt -ν…μŠ€νŠΈ 파일 μΆ”κ°€
git add .  - 폴더 μ•„λž˜μ— λͺ¨λ“  파일 git μž„μ‹œλ“±λ‘
git commit -m "2nd commit"	-μ„€λͺ…μΆ”κ°€
git push origin main  -github둜 연동
----------------------------------------------------------------
cd /test
git clone https://github.com/shb003/01_LinuxEssential.git

####################### 제 2μž₯ μž₯치 관리(λ””μŠ€ν¬ μž₯치 관리) #######################

# ls /
[μ°Έκ³ ] νŒŒμΌμ‹œμŠ€ν…œ ꡬ쑰/ 디렉토리 μš©λ„ 확인 CMD
# man 7 hier
# man 7 file-hierachy

μž₯μΉ˜κ΄€λ¦¬(ex: λ””μŠ€ν¬ μž₯치 관리)

λ””μŠ€ν¬ μž₯μ°©
* μž₯치 인식 μž‘μ—…
* νŒŒν‹°μ…˜ μž‘μ—…
* 파일 μ‹œμŠ€ν…œ μž‘μ—…
* 마운트 μž‘μ—…
  1. μž₯치 인식(device reconfiguration) (μ„ μˆ˜μ§€μ‹) λ””μŠ€ν¬s ꡬ쑰: sector- track - cylinder - parition - disk λ””μŠ€ν¬ μ’…λ₯˜: IDE(SATA), SCSI(SAS), SSD λ””μŠ€ν¬ 이름 체계 * IDE DISK: /dev/hda, /dev/hdb, dev/hdd * SCSI DISK: /dev/sda, /dev/sdb, /dev/sdc, /dev/sdd ..... * Virtual DISK: /dev/vda, /dev/vdb, /dev/vdc .....

    (μž₯μΉ˜μΈμ‹ μž‘μ—…) λ””μŠ€ν¬ μΆ”κ°€

    • poweroff
    • λ””μŠ€ν¬ μž₯μ°©
    • poweron
    • lsblk --fs -p
  2. νŒŒν‹°μ…˜ μž‘μ—… (1) μ„ μˆ˜ 지식 νŒŒν‹°μ…˜ μ’…λ₯˜ * BIOS F/N - MBR νŒŒν‹°μ…˜ ν˜•μ‹ * UEFI F/W - GPT νŒŒν‹°μ…˜ ν˜•μ‹ νŒŒν‹°μ…˜ 이름 체계 (MBR 체계) * primary partition(1-4) * Extended partition -Logical partition(5-15) νŒŒν‹°μ…˜ 이름 체계 (GPT νŒŒν‹°μ…˜ ν˜•μ‹) *partition(1~128)

(1) νŒŒν‹°μ…˜ μž‘μ—…

	νŒŒν‹°μ…˜ μž‘μ—… 툴
	* fdisk CMD - 2TB μ΄ν•˜ (2TB μ΄ν•˜μ˜ μž‘μ—…μ—μ„œλ§Œ μ‚¬μš©)
	---------------------
	* gdisk CMD - 2TB 초과
	* parted CMD - 2TB 초과
	
	νŒŒν‹°μ…˜ μž‘μ—… μˆœμ„œ
	1. fdisk /dev/sdb
	2. p= νŒŒν‹°μ…˜ 확인, n = νŒŒν‹°μ…˜ 생성, d = νŒŒν‹°μ…˜ 제거, w=μ €μž₯ν•˜κ³  μ’…λ£Œ
	3. μ €μž₯ μ‚­μ œ ν›„, partprobe둜 마무리
	
	fdisk ν™•μž₯ νŒŒν‹°μ…˜
	1. ν™•μž₯ νŒŒν‹°μ…˜ 생성
	γ„΄ n - p - μ›ν•˜λŠ” νŒŒν‹°μ…˜ 번호 - enter - μ›ν•˜λŠ” μš©λŸ‰
	2. 이미 ν™•μž₯ νŒŒν‹°μ…˜ μ•ˆμ—μ„œ λ§Œλ“€ 수 있음. nλ₯Ό μž…λ ₯ν•˜λ©΄ 번호 μ§€μ • 없이 λ°”λ‘œ λ‚˜λ¨Έμ§€λ₯Ό λ¬Όμ–΄λ΄„
	3. μ‹œμž‘μ  μ„€μ • κ±΄λ„ˆλ›°κ³  λ‘λ²ˆμ§Έ μš©λŸ‰λ§Œ μ›ν•˜λŠ” μš©λŸ‰μœΌλ‘œ μ„€μ •
	4. λ‚˜λ¨Έμ§€λŠ” κΈ°ν˜Έμ— 따라 μΆ”κ°€
	
	ν™•μž₯νŒŒν‹°μ…˜(Extended Partition), λ…Όλ¦¬νŒŒν‹°μ…˜(Logical partition)은 μ™œ μ‘΄μž¬ν•˜λŠ” 것인가?
	γ„΄ 1κΈ°κ°€λ₯Ό 4개의 νŒŒν‹°μ…˜μœΌλ‘œ λ‚˜λˆ μ„œ μž‘μ—…ν•œλ‹€λ©΄ primary νŒŒν‹°μ…˜μœΌλ‘œ λ‚˜λˆ μ€„ 수 μžˆμ§€λ§Œ,
	  4개 이상이라면 ν™•μž₯νŒŒν‹°μ…˜μœΌλ‘œ 논리 νŒŒν‹°μ…˜ 뢄리 μž‘μ—…μ„ ν•΄μ£ΌλŠ”κ²ƒμ΄ μ’‹λ‹€.
	  
	[gdisk μž‘μ—…]
	- gdisk partition id (Hex code) - μ™Έμ›Œλ‘¬μ•Ό ν•˜λŠ” νƒ€μž…μ˜ ν—₯슀 μ½”λ“œ
   * 8200 : Linux swapml
   * 8300 : Linux filesystem
   * 8e00 : Linux LVM
   * fd00 : Linux RAID
   
    - fdisk partition id (Hex code)
	82 : linux swap
	83 : linux
	
	[parted μž‘μ—…]
	1. parted /dev/sdc
	2. mklabel λΌλ²¨νƒ€μž…
	3. mkpart
	4. 이름은 μ•„λ¬΄κ±°λ‚˜ ex: data1
	5. μ‹œμŠ€ν…œ νƒ€μž…μ€ 보톡 ext4
	6. μ‹œμž‘μš©λŸ‰κ³Ό 끝 μš©λŸ‰ μ„€μ •. 남은 μš©λŸ‰ λ‹€μ±„μš°λŠ” κ±°λ©΄ endλ₯Ό 100%둜 μ„€μ •
	
	+ parted둜 μš©λŸ‰μ„ λ”± 맞게 μ„€μ •ν•˜μ—¬ μž‘μ—… μ‹œ, μš©λŸ‰μ„ μ–΄λŠμ •λ„ μ—¬μœ λ‘­κ²Œ μž‘μ•„μ€˜μ„œ μ‹€μ œλ‘œ 200Mλ₯Ό
	  μž‘μ•˜λ‹€λ©΄ 190M정도면 νŒŒν‹°μ…˜μ„ μž‘μ•„μ€€λ‹€.

	3. 파일 μ‹œμŠ€ν…œ μž‘μ—…
	(1) μ„ μˆ˜ 지식
		- νŒŒμΌμ‹œμŠ€ν…œ 정보 확인
		# man -k ext4|xfs
		# man 5 fs
		
		- νŒŒμΌμ‹œμŠ€ν…œ μ’…λ₯˜
		* ext3/ext4, xfs 
		
		- νŒŒμΌμ‹œμŠ€ν…œ ꡬ쑰 (ex: ext4)
		* DISK 
			--------------------(10)
			MBR
			----------(5)
			BOOT SECTOR

+--> --------------------(10)

SUPER BLOCK
			GROUP 0

ext4 *Backup super block *Gloup Descriptor table | -block bitmap, inode bitmap | -inode table, data block | | GROUP 1 | *Gloup Descriptor table | -block bitmap, inode bitmap | -inode table, data block | | GROUP 2 | *Backup super block | *Gloup Descriptor table | -block bitmap, inode bitmap | -inode table, data block | .... +--> --------------------(10) Super block ----------- GROUP 0 GROUP 1 GROUP 2 ....

		# dumpe2fs /dev/sdb1 (# tune2fs -l 
		# xfs_info /dev/sdb1
	(2) 파일 μ‹œμŠ€ν…œ μž‘μ—…
  1. 기타 마운트 관리 (1) cd/dvd 마운트 (μžλ™λ§ˆμš΄νŠΈ) γ„΄ Automount # cd /run/media/$USER/$LABEL ; ls # cd ; umount /run/media/$USER/$LABEL (μˆ˜λ™λ§ˆμš΄νŠΈ) # mkdir -p / mnt/cdrom ; mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom # cd ; umount /mnt/cdrom

####################### 제 3μž₯ νŒŒμΌμ‹œμŠ€ν…œ 점검과 λͺ¨λ‹ˆν„°λ§ ####################### νŒŒμΌμ‹œμŠ€ν…œ 점검 fsck CMD # fsck /dev/sbd1 # fsck -y /dev/sbd1

	# fsck /dev/sbd1
	# fsck ext4 /dev/sbd1
	# fsck -l ext4 /dev/sbd1
	
	(ext4) # fsck ext4 /dev/sbd1
	(xfs) xfs_repaire /dev/sbd1
	
	[μ‹€λ¬΄μ˜ˆ] "fsck -y /dev/sdb1" μ‚¬μš©ν•˜λŠ” 경우의 둜그 μƒμ„±λœλ‹€
	# fsck -y /dev/sdb1 2>&1 | tee -a tsck.log/*
	
	[μ‹€λ¬΄μ˜ˆ] μŠˆνΌλΈ”λ‘ 볡ꡬ
	(μžλ™) # fsck -y /dev/sdb1
	(μˆ˜λ™) # dumpe2fs /dev/sdb1 | grep -i superblock
		  # fsck -b 32768 /dev/sdb1
		  
	[μ‹€λ¬΄μ˜ˆ} bad block
	λ°°λ“œλΈ”λŸ­(bad block)의 μ’…λ₯˜
	- 물리적인 λ°°λ“œλΈ”λŸ­(Physical badblock)
	- 논리적인 λ°°λ“œλΈ”λŸ­(Logical  badblock)

	# badblocks -v /dev/sdb1       /* μƒλ‹Ήνžˆ 였랜 μ‹œκ°„μ΄ κ±Έλ¦Ό */
	# e2fsck -c -p -f -v /dev/sdb1 (# e2fsck -cpfv /dev/sdb)
	
	alias df='df -h -T'
	
	
5. 기타 마운트 관리
	(2) iso 이미지 파일 관리
	mkisofs -o /이름/κ°€μ Έμ˜¬ 경둜
	# mkisofs -o linux.ios /etc/sysconfig/*
	# mkdir -p /mnt/iso ; mount -t(typeμ§€μ •) iso9660 -o ro,loop /test/linux.iso /mnt/iso
	 [κΉ¨μ•Œ 상식] lsblk --fs = 파일 ꡬ쑰와 μ•ˆμ— λ‚΄μš©λ“€μ„ 트리 ν˜•μ‹μœΌλ‘œ μ €μž₯
	 
	(3) usb λ©”λͺ¨λ¦¬ 마운트
	FAT32
	(μžλ™λ§ˆμš΄νŠΈ)
	automount
		# cd /run/media/$USER/&LABEL ; ls
		# cd ; umount /run/media/$USER/&LABEL
	
	(μˆ˜λ™λ§ˆμš΄νŠΈ)
		# mkdir -p /mnt/usb ; mount -t vfat /dev/sde2 /mnt/usb	
		# cd /mnt/usb ; ls
		# cd ; umount /mnt/usb
	
	NTFS
		# yum -y install epel-release
		# yum install ntfs-3g
	(μžλ™λ§ˆμš΄νŠΈ)
	automount
	# cd /run/media/$USER/&LABEL ; ls
	# cd ; umount /run/media/$USER/&LABEL
	(μˆ˜λ™λ§ˆμš΄νŠΈ)
	# mkdir -p /mnt/ntfs ; mount.ntfs /dev/sde2 /mnt/ntfs
	# cd /mnt/ntfs
	
	-RAM λ””μŠ€ν¬ 마운트
	(μˆ˜λ™λ§ˆμš΄νŠΈ)
	# mkdir -p /mnt/ram ; mount -t tmpfs -o size=5g none /mnt/ram
	# cd /mnt/ram ; ls
	# cd ; umount /mnt/ram
	
	- NFS 원격 마운트
	  [μ „μ œμ‘°κ±΄] μ›κ²©μ„œλ²„μ— κ³΅μœ μ„€μ •μ΄ λ˜μ–΄ μžˆμ–΄μ•Όν•œλ‹€
	  
	(μˆ˜λ™λ§ˆμš΄νŠΈ)
	# mkdir -p /mnt/nfs ; mount -t nfs 
	# systemctl restart nfs-server
	# 
	
	(6) cifs 원격 마운트
	# mkdir -p /mnt/cifs
	# mount -t cifs //μžμ‹ μ˜ ip/곡유될 폴더 /mnt/cifs -o username=soldesk
	# cd /mnt/cifs = μ‚¬μš©ν•  ν΄λ”λ‘œ 이동
	# cd ; umount /mnt/cifs = μ‚¬μš© μ’…λ£Œ ν›„, 마운트 μ’…λ£Œ

####################### -----제 5μž₯ LVM 관리------ #######################

β–  LVM μž‘μ—… μˆœμ„œ

β€’ Partition System ID λ³€κ²½(fdisk CMD) -> PV 생성(pvcreate CMD) t-L-κ°€μ΄λ“œλ₯Ό 보고 μ›ν•˜λŠ” νƒ€μž…μœΌλ‘œ λ³€κ²½ : ex: 8e # pvcreate /dev/sda1 # pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1 # pvcreate /dev/sd[abc]1 # pvcreate /dev/sda /dev/sdb /dev/sdc -> PV 제거 # pvremove /dev/sda1 # pvremove /dev/sda1 /dev/sdb1 /dev/sdc1 # pvremove /dev/sd[abc]1

-> PV 생성 μ‹œ, 확인법 # fdisk -l | grep LVM # 생성 κ°€λŠ₯ν•œ PV λͺ©λ‘ 확인 # pvs # μƒμ„±λœ PV λͺ©λ‘ 확인 # pvcreate CMD # PV 생성 # pvdisplay /dev/λ””μŠ€ν¬ 선택 = μžμ„Έν•œ 확인

-> VG 생성(vgcreate CMD) # vgcreate vg1 /dev/sdc1 /dev/sdd1 /dev/sde1 # vgcreate vg1 /dev/sd[cde]1 # vgcreate vg1 /dev/sd[cde]1 -s 16M /* PE Size : 16MB */ -μ‚¬μ΄μ¦ˆ λ‹¨μœ„ μ•ˆμ£Όλ©΄ 4Mλ‹¨μœ„λ‘œ λ‚˜μ˜΄!

-> VG μ‚­μ œ # vgremove vg1 # vgremove /dev/vg1

-> VG에 λ””μŠ€ν¬ μΆ”κ°€/제거 # vgextend vg1 /dev/sdf1 # vgreduce vg1 /dev/sdf1

-> VG 이름 λ³€κ²½ # vgrename /dev/vg1 /dev/vg1_backup # vgrename vg1 vg1_backup

-> VG 정보 확인 # vgs # vgdisplay (# vgdisplay vg1) # vgscan

-> LV 생성(lvcreate CMD) # lvcreate -L 10G vg1 /* LV 이름 μžλ™ 생성 : lvol#(μš©λŸ‰ 10G) / # lvcreate -L 1500M -n lv1 vg1 # lvcreate -L 1500 -n lv1 vg1 / μš©λŸ‰ λ‹¨μœ„κ°€ μ—†μœΌλ©΄ MB */ # lvcreate -l 60%VG -n lv1 vg1 # lvcreate -l 100%FREE -n lv1 vg1

β–  LV μ‚­μ œ

lvremove /dev/vg1/lv1

-> LV 이름 λ³€κ²½ # lvrename /dev/vg1/lv1 /dev/vg1/lv2 # lvrename vg1 lv1 lv2 /* vg1(lv1 -> lv2) / -> LV 곡간 늘리기/쀄이기 # lvextend -L 12G /dev/vg1/lv1 / lv1 μš©λŸ‰μ„ 12G둜 맞좀 / # lvextend -L +1G /dev/vg1/lv1 / lv1 μš©λŸ‰μ„ 1G 만큼 μΆ”κ°€ */ # lvextend -l +100%FREE /dev/vg1/lv1

# lvreduce -L 3G /dev/vg1/lv1
# lvreduce -L -3G /dev/vg1/lv1
# lvreduce -l -3 /dev/vg1/lv1    	/* lv1 μš©λŸ‰μ„ 3 LE(Logical Extend)만큼 κ°μ†Œ */

-> LV 정보 확인 # lvs # lvdisplay (# lvdisplay /dev/vg1/lv1) # lvscan

[질문] 초기 vm ꡬ성 ν›„ λ¦¬λˆ…μŠ€ μ„€μΉ˜ μ‹œμ— / μš©λŸ‰μ„ 60G둜 늘릴 수 μžˆλŠ”κ°€? /dev/cs/root(39G) -> /dev/cs/root(60G) λ‹΅ = #lvextend -l 100%FREE /dev/cs/root

-> F/S 생성(mkfs CMD) -> 마운트(mount CMD, /etc/fstab)

[ꡬ성 μˆœμ„œ]

  1. λ””μŠ€ν¬ 8e둜 lvm μ„€μ •, κ°œμΈνŒŒν‹°μ…˜ λ””μŠ€ν¬ ꡬ성
  2. pvcreate둜 λ§Œλ“€κΈ°
  3. vg둜 λ§Œλ“€μ–΄λ‘” pvλ“€ λ‹€ λ¬ΆκΈ°

-μž‘μ—…κ³„νš 1. DISK μ€€λΉ„ (μΆ”κ°€ 및 인식) 2. νŒŒν‹°μ…˜ μž‘μ—…

parted /dev/sdc mklabel media fdisk /dev/sdc /dev/sdc1 partition id:8e ####################### -----제 6μž₯ RAID------ #######################

  • RAID 7 λ¦¬μ–Όνƒ€μž„μ„ λ”°λ‘œ μ‚¬μš©ν•΄μ„œ μ•ˆμ •μ„±μ΄ λ†’μŒ ν•˜μ§€λ§Œ μŠ€ν† λ¦¬μ§€ 가격이 λ†’μŒ

####################### -----제 7μž₯ SWAP------ #######################

-SWAP μ΄λž€? λ””μŠ€ν¬λ‚΄μ— μ‘΄μž¬ν•˜λŠ” 가상적인 λ©”λͺ¨λ¦¬ 곡간, 물리적인 λ©”λͺ¨λ¦¬(RAM) μ—°μž₯ κ³΅κ°„μ²˜λŸΌ μ“°μ΄λŠ” 곡간

β–  μŠ€μ™‘ κ΄€λ ¨ 이슈(SWAP Issue)?

  • μ–Έμ œ μŠ€μ™‘μ„ μΆ”κ°€ν•˜λŠ”κ°€?
  • μŠ€μ™‘ κ³΅κ°„μ˜ 크기? (초기 μ„€μΉ˜μ‹œ) (μš΄μ˜μ‹œ)
  • μŠ€μ™‘μ„ μΆ”κ°€ν•˜λ©΄ μ„±λŠ₯이 μ’‹μ•„μ§€λŠ”κ°€? γ„΄ κ·Έλ ‡μ§€μ•Šλ‹€. ν•˜μ§€λ§Œ μš΄μ˜μ²΄μ œκ°€ λ©ˆμΆ”λŠ”κ²ƒμ„ λ°©μ§€ν•˜κΈ° μœ„ν•΄ μΆ”κ°€ ν•˜λŠ”κ²ƒμ΄λ‹€.

-SWAP 관리 * SWAP FILE ν˜•νƒœλ‘œ μΆ”κ°€/μ‚­μ œν•˜κΈ° # mkdir -p /swap # dd -if=/dev/zero of=/swap/swapfile bs=1M count=10240 # mkswap /swap/swapfile # swapon swap/swapfile # vi /etc/fstab # rm -f /swap/swapfile

* SWAP Partition ν˜•νƒœλ‘œ μΆ”κ°€/μ‚­μ œν•˜κΈ°
	# fdisk /dev/sdb (t=82)
	# mkswap /dev/sdb1
	# swapon /dev/sdb1
	# vi /etc/fstab
	
	# swapoff /dev/sdb1
	# vi /etc/fstab
	
* swap LV ν˜•νƒœλ‘œ μΆ”κ°€/μ‚­μ œν•˜κΈ°
	#fdisk /dev/sdb (t=8e)
	#pvcreate /dev/sdb1
	#vgcreate cs /dev/sdb1
	#lvcreate cs -n swap2 -L 10G
	#mkswap /dev/cs/swap2
	#swapon /dev/cs/swap2
	#vi /etc/fstab
	
	#swapoff /dev/cs/swap2
	#vi /etc/fstab

############################ -----제 8μž₯ μ†Œν”„νŠΈμ›¨μ–΄ 관리------ ############################

rpm cmd #rpm -qa | grep openssh [μ°Έκ³ ] 인터넷 - rpm 파일 γ„΄ rmpfind.net γ„΄ rpm.pbone.net

-μ„€μΉ˜
#rpm -ivh|Fvh|Uvh [--nodeps] [force] PKG.rpm
     μ„€μΉ˜ μ—…λ°μ΄νŠΈ μ—…κ·Έλ ˆμ΄λ“œ(μ„ ν˜Έ!)
#rpm -qa | grep PKG = 전체 νŒ¨ν‚€μ§€ 확인 μ˜΅μ…˜
   
#rpm -e PKG

#rpm -qf /usr/bin/php-cli

-μ‚­μ œ
#rpm -e [--nodepes](ν˜Έν™˜μ„±λ¬΄μ‹œ) PKG

yum/dnf cmd

-μ„€μΉ˜λͺ…λ Ήμ–΄
# yum [-y] install pkg
# yum [-y] update pkg
# yum [-y] localinstall pkg.rpm
# yum download pkg

#yum list (확인λͺ…λ Ήμ–΄)
	# yum list installed  = μ„€μΉ˜λœ νŒ¨ν‚€μ§€ λͺ©λ‘ 확인
	# yum list installed [--downloadonly] = κ²½λ‘œμ•„λž˜ λ‹€μš΄λ‘œλ“œλ§Œ ν•΄λ‘ 
	# yum list avalable 
	# yum search php
	# yum list 'php-7.2.24*'
	# yum provide '*/httpd.conf'
	
	- yum history
	# yum history = μ„€μΉ˜,μ‚­μ œ λ‚΄μ—­ 확인
	# yum histoty info (번호) = κ·Έ λ²ˆν˜Έμ— λŒ€ν•œ 둜그기둝
	# yum history redo 20
	# yum history undo 43 
	# yum history rollback 41
	

# yum [-y] remove pkg =μ‚­μ œλͺ…λ Ήμ–΄

[μ°Έκ³ ] yum update
# yum check-update 2>&1 | tee rpm.log ( μ—…λ°μ΄νŠΈ ν™•μΈν•˜κ³ |κ·Έ λ‚΄μš©μ„ 둜그둜 λ”°λ‘œ μ €μž₯)
[2(였λ₯˜μΆœλ ₯)>&1(μ •μƒμΆœλ ₯)의 뜻] =file.log에 정상적인 좜λ ₯κ²°κ³Ό 외에도 λ„£λŠ”λ‹€λŠ” 뜻 
# yum update

- yum repository 관리
# yum repolist ,all
# yum-config-manager --disable epel = λͺ©λ‘μ—μ„œ μ œμ™Έ
# yum-config-manager --enable epel = λͺ©λ‘μ— μΆ”κ°€

[μ°Έκ³ ] /etc/yum.repo.d/*.repo λ§Œλ“€κΈ°
(γ„±) μžλ™μœΌλ‘œ μƒμ„±ν•˜κΈ° (yum-config-manager)
	# yum-config-manager --add-repo file:///mnt/cdrom/BaseOS
	# yum-config-manager --add-repo file:///mnt/cdrom/AppStream
(γ„΄) μˆ˜λ™μœΌλ‘œ μƒμ„±ν•˜κΈ°
	# yum /etc/yum.repo.d/CD.repo
	-----------------------------
	[MYCDBaseOS]
	name= CentOS Stream 8 -BaseOS
	baseurl=file:///mnt/cdrom/BaseOS
	enabled=1
	
	[MYCDAppStream]
	name=CentOS Linux - AppStream
	baseurl=file:///run/media/root/CentOS-8-3-2011-x86_64-dvd/AppStream
	enabled=1

-yum group cmd
	# yum group install <gpkg>
	# yum group update <gpkg>
	
	# yum group list
	# yum group list hidden | egrep -i 'security|development'
	# yum group info <GPKG>
	
	# yum group remove <gpkg>
	
	μ‚¬μš©λ¦¬λˆ…μŠ€ 컀널 버전: 4.18.0-408.el8.x86_64

source code

#cd /test ; rm -rf * = μ‚¬μš© x
#cd /test && rm -rf * = μžˆμ–΄μ•Όλ§Œ μ§€μš°κΈ° λ•Œλ¬Έμ— μ•ˆμ „!!

#cd /test && wget http://www.example.com/httpd.tar.gz
#tar xvzf http.tar.gz -C /usr/local/src
#cd /usr/local/src $$ comfigure --prefix=/usr/local/apache2 && make && make install
# /usr/local/apache2/bin/apachect1 start

[μ°Έκ³ ] 퍼블릭 ν‚€ κ°’: FE1AA336F722C534B40466F1D7F385BF5C0F4E5C
	γ„΄ ν‚€ λ³΄λŠ” λͺ…λ Ήμ–΄ # gpg --list-key

rpm μ„ ν–‰μ„€μΉ˜ ν•„μš”νŒŒμΌλ“€ rpm -Uvh php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm

크둬싀행λͺ…λ Ήμ–΄ -----chrome &--------

############################ -----제 9μž₯ λΆ€νŒ… κ³Όμ •------ ############################

[λ¦¬λˆ…μŠ€ λΆ€νŒ… κ³Όμ •] -F/W 단계 -λΆ€νŠΈ λ‘œλ“œ(Boot Loader) 단계 -컀널(Kernel) 단계 -systemd 단계

  1. λΆ€νŒ… κ³Όμ • β–  1 단계 : F/W 단계
    • post
    • λΆ€νŒ…λ§€μ²΄(floppy -> disk -> cd -> net) β–  2 단계 : λΆ€νŠΈ λ‘œλ“œ(Boot Loader) 단계
    • /boot/grub2/grub.cfg
    • kernel
    • initramfs β–  3 단계 : 컀널(Kernel) 단계 -kernel -> initramfs(systemd) β–  4 단계 : systemd 단계\

β–  μ„œλΉ„μŠ€ μ œμ–΄

systemctl start httpd.service

systemctl stop httpd.service

systemctl restart httpd.service

systemctl status httpd.service

systemctl enable httpd.service

systemctl disable httpd.service

systemctl status httpd - ν˜„μž¬ ꡬ동쀑인지 확인

systemctl is-active httpd => # systemctl status httpd

systemctl is-enabled httpd => # systemctl list-unit-files | grep httpd.service

*** # systemctl is-failed httpd => # systemctl --failed --type=service γ„΄ fail이 λ°œμƒν•œ 뢀뢄을 ν™•μΈν•œλ‹€.

  • κ·Έλž˜ν”½, λ©€ν‹°λͺ¨λ“œ μ„€μ •ν•˜κΈ°

systemctl get-default – λΆ€νŒ…μ‹œ λͺ¨λ“œ ν‘œμ‹œ

systemctl set-default graphical.target – μž¬λΆ€νŒ… μ‹œ λͺ¨λ“œ μ„€μ •

-λΆ€νŒ…κ³Όμ •μ—μ„œ text ctl λͺ¨λ“œμ—μ„œ μ„€μ •λ³€κ²½ (e둜 edit λͺ¨λ“œ λ“€μ–΄κ°€κΈ°) (γ„±) /dev/cl/root --> /sysroot(ro) ==> "rd.break" # mount -o remount,rw /sysroot # chroot /sysroot (γ„΄) /dev/cl/root --> /(ro) ==> "init=/bin/bash" # mount -o remount,rw / (γ„·) /dev/cl/root --> /(ro), μ‹œμŠ€ν…œ μ΄ˆκΈ°ν™” ==> "systemd.unit=emergency.target" # mount -o remount,rw / (γ„Ή) /dev/cl/root --> /(rw), μ‹œμŠ€ν…œ μ΄ˆκΈ°ν™”, λ‚˜λ¨Έμ§€ νŒŒμΌμ‹œμŠ€ν…œ 마운트 ==> "systemd.unit=rescue.target"

(5) μž₯μ• μ²˜λ¦¬(ex:μ•ˆμ „λͺ¨λ“œ) (γ„±) rd.break reboot -> GRUB menu -> μ λ‹Ήν•œ 컀널 선택 -> e -> linux 라인 선택 -> rd.break # mount –o remount,rw /sysroot # chroot /sysroot # passwd root # toucg /.autorelabel -> exit exit

(γ„΄) init=/bin/bash reboot -> GRUB menu -> μ λ‹Ήν•œ 컀널 선택 -> e -> linux 라인 선택 -> init=/bin/bash # mount –o remount,rw /sysroot # chroot /sysroot # passwd root # toucg /.autorelabel -> μž¬λΆ€νŒ…

(γ„·) systemd.unit=emergency.target reboot -> GRUB menu -> μ λ‹Ήν•œ 컀널 선택 -> e -> linux 라인 선택 -> systemd.unit=emergency.target # mount –o remount,rw / μž₯μ• μ²˜λ¦¬ -etc 파일 였λ₯˜ μ‹œ μ‚¬μš© # exit

(γ„Ή) systemd.unit=rescue.target reboot -> GRUB menu -> μ λ‹Ήν•œ 컀널 선택 -> e -> linux 라인 선택 -> systemd.unit=rescue.target - λ§ˆμš΄νŠΈκ°€ 이미 λ˜μ–΄μžˆμŒ μž₯μ• μ²˜λ¦¬ -etc 파일 였λ₯˜ μ‹œ μ‚¬μš© # exit

질문 – 였랜 linux vm 이미지λ₯Ό κΈ°λ™ν–ˆλŠ”λ° root μ•”ν˜Έλ₯Ό λͺ¨λ₯΄λŠ”κ²½μš°? λ‹΅λ³€ – root μ•”ν˜Έλ₯Ό λ³΅κ΅¬ν•œλ‹€. # reboot GRUB menu μ λ‹Ήν•œ 컀널 -> e -> linux μ‹œμž‘ν•˜λŠ” 라인 -> -> re.break -> <ctrl+x> # mount –o remount,rw /sysroot # chroot /sysroot # passwd root # (selinux on μ‹œ) touch /.autorelabel #exit; exit

[μ‹€μŠ΅] (systemd phase) /etc/rc.local (/etc/rc.d/rc.local) νŒŒμΌμ„ μ‚¬μš©ν•œ λΆ€νŒ…μ‹œ μ‹€ν–‰λͺ…λ Ή 등둝

vi /etc/rc.d/rc.local

chmod +x /etc/rc.d/rc.local - 둜그인 λ°”λ‘œ 직전에 μ‹€ν–‰λ˜κ²Œ 됨

[μ‹€μŠ΅2] (bootload phase) GRUB2 μ•”ν˜Έ μ„€μ •ν•˜κΈ°

grub2-setpassword

=> /boot/grub2/user.cfg

[μ‹€μŠ΅3] (systemd phase) μƒˆλ‘œμš΄ μ„œλΉ„μŠ€ 등둝

vi /usr/lib/systemd/system/new.service

systemctl daemon-reload

systemctl enable --now new

[μ‹€μŠ΅4] (grub phase) GRUBκ°€ κΉ¨μ§„ 경우 CD λΆ€νŒ…

df -h =mnt/sysrootκ°€ 마운트 λ˜μ–΄ μžˆμ–΄μ•Όν•΄μ„œ ν™•μΈν•˜λŠ”κ²ƒ! # mount -o rw /mnt/sysroot

chroot /mnt/sysroot

# lsblk --fs -p
# fdisk -l /dev/sda

grub2-install /dev/sda (#grub2-mkconfig -o /boot/grub.cfg)

exit ; exit

[μ‹€μŠ΅5] (systemd phase) /etc/fstab 파일 잘λͺ»λœ μ„€μ •μ˜ 예 root μ•”ν˜Έ μž…λ ₯

mount -o remount,rw /

vi /etc/fstab

-> μ λ‹Ήν•œ μ„€μ •

systemctl daemon-reload

exit

  • systemd 데λͺ¬ = λͺ¨λ“  μ‹œμŠ€ν…œμ˜ λΆ€λͺ¨ ν”„λ‘œμ„Έμ„œ

############################ -----제 10μž₯ μ‚¬μš©μžκ·Έλ£Ήκ΄€λ¦¬------ ############################

μš©μ–΄: 인증(authentication), 인가(Authorization), μ—­ν• (role)

μ‚¬μš©μž 관리 μ‚¬μš©μž 정보 파일 /etc/passwd /etc/shadow μ‚¬μš©μž 관리 파일 useradd cmd # useradd user01 # useradd -M /oracle oracle - ν™ˆν΄λ” 생성x( #chown -R oracle:oinstall /oracle) # passwd user01 # useradd -e 2023-03-08 user04 - 계정에 기간을 μΆ”κ°€ # useradd -D -g 10 - μœ μ € 생성 κΈ°λ³Έκ°’ λ³€κ²½ # useradd -D -b /users '' # useradd -D -s /bin/sh ''

	usermod cmd
		# usermod -u 2000 user01 - uid change
		# usermod -s /bin/sh user01 - shells 경둜 λ³€κ²½
		# usermod -c 'μ λ‹Ήν•œ λ‚΄μš©' user01
	userdel cmd
		# userdel user01 = 검색상 μ •λ³΄λ§Œ μ‚­μ œ
		# userdel -r user01 = 정보와 μžμ› λͺ¨λ‘ μ‚­μ œ

그룹관리 κ·Έλ£Ή 정보 파일 /etc/group κ·Έλ£Ή 관리 λͺ…λ Ή groupadd CMD # groupadd class1 # useradd -aG class1,class2 user01 - μœ μ €μ—κ²Œ μ„œλΈŒκ·Έλ£Ή μΆ”κ°€ groupmod CMD # groupmod -g 3000 class1 groupdel CMD #groupdel class1

μ•”ν˜Έκ΄€λ¦¬ chage CMD # chage -l user01 # chage -M 90 -W 7 user 01 # chage -E 2023-12-31 user01

	[μ‹€λ¬΄μ˜ˆ] μ‚¬μš©μž 계정에 λŒ€ν•œ exfiere date μ„€μ •ν•˜κΈ°
	μΆ”κ°€ - # useradd -e 2023-12-31 user01
	λ³€κ²½ - # usermod -e 2023-12-31 user01 (# chage -E 2023-12-31 user01)
	
	[μ‹€λ¬΄μ˜ˆ] Max Days + Warn Days
	μ „μ—­ - /etc/login.defs (PASS_MAX_DAYS=30, PASS_WARN_AGE=7)
	개인 - # chage -M 30 -W 7 user01

############################ -----제 11μž₯ μŠ€μΌ€μ€„λ§------ ############################

at CMD (atd.service) # at 1300 -μ„€μ • # at -l (#atq) -확인 # at -r N (#atrm N) -μ·¨μ†Œ

crontab CMD β–  μž‘μ—… μ„ μ–Έ # crontab -e (-e : Edit, # vi /var/spool/cron/<μ‚¬μš©μžμ΄λ¦„>)

β–  μž‘μ—… 확인 # crontab -l (-l : List, # cat /var/spool/cron/<μ‚¬μš©μžμ΄λ¦„>)

β–  μž‘μ—… μ‚­μ œ # crontab -r (주의) (-r : Remove, # rm /var/spool/cron/<μ‚¬μš©μžμ΄λ¦„>)

[반볡좜λ ₯λ¬Έ μ‹œκ°„λ§ˆλ‹€ 좜λ ₯] #!/bin/bash

ps u | awk '{print $7}' | grep pts/ | sort -u > /root/bin/pts.list cat pts.list | while read BTS do cat /etc/MESS/CoffeeTime.txt > /dev/$BTS done

[μ‹€λ¬΄μ˜ˆ] λ§€μ›” 첫번째 μ£Ό μΌμš”μΌ λ‚  /root/bin/backup.sh 슀크립트 μ‹€ν–‰ν•˜κ³  μ‹Άλ‹€
* crontab CMD + script.sh
# crontab -e(edit)
0	3	*	*	0	/root/bin/script.sh	
# vi script.sh
------------------------------------------
#!/bin/bash

DAY=$(date +%d)
if [ &DAY -le 7 ] ; then
	/root/bin/backup.sh
fi
-------------------------------------------

[μ‹€λ¬΄μ˜ˆ] wasuser, oracle μ‚¬μš©μžλ§Œ crontab λͺ…λ Ήμ–΄λ₯Ό μˆ˜ν–‰ν•˜λ„λ‘ ν•˜κ³  μ‹Άλ‹€. # cd /var/spool/cron # ls backupuser user01

# vi /etc/cron.allow 
	backupuser 
	user01
	wasuser
	oracle

[μ‹€λ¬΄μ˜ˆ] 고객의 물음(?) [고객의 질문] 일반적인 μ„œλΉ„μŠ€(EX: httpd)λŠ” μ„€μ • 파일(EX: httpd.conf)을 μˆ˜μ •ν•˜κ³  λ‚˜λ©΄ 데λͺ¬μ„ μž¬κΈ°λ™ν•˜λŠ”λ°, crontab μ„œλΉ„μŠ€λŠ” μ„€μ • νŒŒμΌμ„ μˆ˜μ •ν•œ λ‹€μŒμ— 데λͺ¬μ„ μž¬κΈ°λ™ν•˜λŠ”κ°€?

(볡원) /etc/cron.allow νŒŒμΌμ„ μ‚­μ œν•˜κ³  /etc/cron.deny 파일 νŽΈμ§‘ν•œλ‹€. # rm -f /etc/cron.allow # > /etc/cron.deny -> user01 μ‚­μ œ

[μ‹€λ¬΄μ˜ˆ] κ΄€λ¦¬μž μŠ€μΌ€μ€„λ§ μ„€μ •
(γ„±) crontab -e => /var/spool/cron/root/$USER
(γ„΄) # vi /etc/crontab
(γ„·) # vi /etc/cron..{hourly,daily,weekly,monthly}/*

############################ -----제 12μž₯ λ°±μ—…κ³Ό 볡ꡬ------ ############################

둜컬 λ°±μ—…/볡ꡬ tar CMD [μ°Έκ³ ] μƒλŒ€κ²½λ‘œ/μ ˆλŒ€κ²½λ‘œ (λ˜λ„λ‘ μƒλŒ€κ²½λ‘œ) γ„΄ μƒλŒ€κ²½λ‘œλŠ” 경둜둜 직업 λ“€μ–΄κ°€μ„œ μΉ΄ν”Όλ₯Ό ν•΄μ€˜μ•Όν•˜μ§€λ§Œ μ ˆλŒ€κ²½λ‘œλŠ” 뒀에 .이 μ•„λ‹ˆλΌ /home 으둜 μ ˆλŒ€ 경둜λ₯Ό μ •ν•΄μ€˜μ„œ 직접 μ•ˆν•΄λ„ λœλ‹€. # cd /home # tar cvzf /backup/home.tar.gz . # tar tvzf /backup/home.tar.gz # cd /home ; tar xvzf /backup/home.tar.gz

	 γ„΄ ν•œλ²ˆμ— 볡ꡬ가 λ˜μ–΄μ„œ νŽΈν•˜μ§€λ§Œ 데이터가 λ„˜ 많이 μŒ“μΈλ‹€
	 
	 Full Backup + Difference Backup
	 # cd /home
	 # tar -g /backup/backup.time -czf /backup/home_full.tar.gz .
	 # tar -g /backup/backup.time -czf /backup/home_inc1.tar.gz .
	 
	 - ν’€λ•Œ
	 # cd /hoem
	 # tar -g /backup/backup.time -xzf /backup/home_full.tar.gz
	 # tar -g /backup/backup.time -xzf /backup/home_inc1.tar.gz
	 
	 
-----------------------μ€‘μš”!!!----------------------------
***** cp -r /test1/* /test2 = cp둜 볡사 μ‹œ, 문제 점
γ„΄ *λŠ” .으둜 μ‹œμž‘ν•˜λŠ” μ„€μ •νŒŒμΌμ€ cp ν•˜μ§€μ•Šκ³ , μ‹œκ°„ λ˜ν•œ λ‹€λ₯΄κ²Œ μ €μž₯λœλ‹€
  그리고 μ˜€λ„ˆμ™€ 그룹도 λͺ¨λ‘ μ‹€ν–‰μžμ˜ μ˜€λ„ˆκ·Έλ£ΉμœΌλ‘œ λ³€κ²½λœλ‹€. κΆŒν•œλ“€ λ˜ν•œ 
  μƒˆλ‘œ λ§Œλ“€μ–΄μ Έ λ³΄μ•ˆμ„€μ • λ˜ν•œ λ‹€λ₯΄κ²Œ μ„€μ •λœλ‹€.
  
[해결법] 
# cd /test1
	   cf(vλŠ” 보여주기 좜λ ₯μ΄κΈ°λ•Œλ¬Έμ— 빼도 됨)
# tar cvf - . | (cd /test2 ; tar xvf -)
     file.tar둜 받아라           file.tarλ₯Ό 풀어라
- 에 file.tar둜 지정해두면 μ•ˆλ˜λŠ” 이유
γ„΄ -λŠ” λ°”λ‘œ μ••μΆ•νŒŒμΌμ„ λ„˜κΈ°λŠ”κ²ƒμ΄μ§€λ§Œ, file.tar둜 μ§€μ •ν•˜λ©΄ μ••μΆ•ν•œκ²ƒμ„ 
	κ²½λ‘œμ— λ†”μ•Όν•˜λŠ”λ° μš©λŸ‰μ΄ λ‘λ°°λ‘œ λ“ λ‹€. λ§Œμ•½ μ••μΆ•κ²½λ‘œμ— μš©λŸ‰μ΄ μ—†λ‹€λ©΄ -둜
	λ°”λ‘œ μ••μΆ•ν•΄μ œ κ²½λ‘œμ— 풀어버릴 수 μžˆλ‹€.
---------------------------------------------------------

- ν•΄μ œν•œ νŒŒμΌμ„ μ„œλ‘œ λΉ„κ΅ν•΄μ„œ λ‹€λ₯Έ 점을 μ°ΎλŠ”λ‹€.
(λ‹¨μˆœλΉ„κ΅)
# find /test1 | wc -l 
# find /test2 | wc -l 
(정밀비ꡐ) 
# diff --recursive /test1 /test2 

--λ‘œμ»¬λ°±μ—…--
[EX] 운영체제 전체백업 - λ‹€λ₯Έ μš©λ„λ‘œλ„ μ‚¬μš©κ°€λŠ₯( --exclude)
- μ „μ²΄μ˜ 백업은 μ‰½μ§€λ§Œ , μ„ νƒν•œ λΆ€λΆ„λ§Œ ν•œλ²ˆμ— λ°±μ—… λ°›λŠ”κ²ƒμ€ μ–΄λ ΅λ‹€.
  κ·Έλ ‡κΈ° λ•Œλ¬Έμ— 이 방법을 μ‚¬μš©ν•˜μ—¬ μ œμ™Έ 디렉토리λ₯Ό μ§€μ •ν•˜μ—¬ 선택받기가 κ°€λŠ₯ν•˜λ‹€
 # tar cvzf /backup/test.tar.gz \
	> --exclude=/test/dir1 \
	> --exclude=/test/dir6 \
	> --absolute-name /test
	- μ ˆλŒ€κ²½λ‘œ ν˜•μ‹μ΄λΌ μ΅œμƒμœ„ ν΄λ”λ‘œ κ°€μ„œ ν’€μ–΄μ€˜μ•Όν•œλ‹€
		[운영체제 λ°±μ—…λ³Έ λ§Œλ“€κΈ°]
		# mkdir -p /RootBackup 
		# time tar cvzf /RootBackup/full.tar.gz \
			--exclude=/proc \
			--exclude=/tmp \
			--exclude=/media \
			--exclude=/sys \
			--exclude=/run \
			--exclude=/mnt \
			--exclude=/RootBackup \ - 이거 μ•ˆν•΄μ£Όλ©΄ μ••μΆ•νŒŒμΌμ„ κ³„μ†λ§Œλ“€μ–΄μ„œ fullλ‚œλ‹€.
			--absolute-name /

[Ex5] 일뢀 볡원/ 전체 볡원

-λ³΅μ›μœ„μΉ˜  λ°±μ—… (μ ˆλŒ€κ²½λ‘œ) -> 볡원 (cd /)  λ°±μ—… (μƒλŒ€κ²½λ‘œ) -> 볡원 (cd /home) -볡원데이터

  • (전체 볡원) # tar xvzf /backup/backup.tar
  • (일뢀 볡원) # tar xvzf /backup/backup.tar user01 user02/ .bashrc -- (1) λ°±μ—… 데이터 생성 β”œβ”€β”€ dir1 β”‚ β”œβ”€β”€ dir2 β”‚ β”‚ β”œβ”€β”€ dir3 β”‚ β”‚ β”‚ └── file1 β”‚ β”‚ └── file2 β”‚ └── file3 β”œβ”€β”€ dir4 β”‚ └── file4 β”œβ”€β”€ dir5 β”‚ └── file5 β”œβ”€β”€ dir6 β”‚ β”œβ”€β”€ dir7 β”‚ β”‚ └── file6 β”‚ └── file7 └── file8

cd /test

tar cvf /backup/test.tar .

2-전체볡원

rm –rf /test/*

tar tvf /backup/test.tar | head –확인

tar -xvf /backup/test.tar - ./으둜 μ‹œμž‘ν•˜λŠ” μƒλŒ€κ²°λ‘œμ—¬μ„œ test둜 λ“€μ–΄κ°€μ„œ ν•΄μ€Œ

3-일뢀볡원

cd /test && rm –rf dir1

tar -tvf /backup/test.tar | grep dir1

tar -tvf /backup/test.tar | head === μ ˆλŒ€κ²½λ‘œμΈμ§€ μƒλŒ€κ²½λ‘œμΈμ§€ 확인!! (.으둜 μ‹œμž‘ν•˜λ©΄ μƒλŒ€)

cd /test

tar -xvf /backup/test.tar ./dir1 ./file8 -- ./볡원할 디렉토리, 파일 이름

원격 λ°±μ—…/볡ꡬ
rsync CMD
	L /backup1 -> L /backup2
		#rsync -a --delete /backup1/ /backup2
	L /backup  -> R main:/backup/server1
		#rsync -az --delete -e ssh /backup/ main:/backup/server1
	R main:/backup/server1 -> L /backup
		#rsync -az --delete -e ssh main:/backup/server1/ /backup
	
	[μ°Έκ³ ] $HOME/ .bashrc
	alias RS='rsync -az --delete -e ssh'
	alias LS='rsync -a --delete'


rsync μ„œλ²„/ν΄λΌμ΄μ–ΈνŠΈ

[λ„€νŠΈμ›Œν¬ 확인]
# netstat -a(all)n(new)tup(proc,pid) | grep :κ²€μƒ‰λ²ˆν˜Έ

(rsync server)
# yum install rsync-daemon rsync
# vi /etc/rsyncd.conf 
----------------------------------------
uid=nobody 			/* μ‚¬μš©μž 아이디 */
gid=nobody 			/* κ·Έλ£Ή 아이디 */
use chroot=no 			/* yes : μ§€μ •λœ 경둜 이외에 λ‹€λ₯Έ 경둜둜 접속 λͺ»ν•˜κ²Œ 함 */ 
max connections=5 		/* μ΅œλŒ€ μ ‘μ†μž 수 : 0은 λ¬΄μ œν•œμ„ λ‚˜νƒ€λƒ„ */
timeout=60 			/* Client의 접속이 idleμƒνƒœμΌ λ•Œ 접속을 λŠμ–΄λ²„λ¦΄ 초 λ‹¨μœ„ μ‹œκ°„ */ 

[Backup] 			/* rsync μ„œλΉ„μŠ€λͺ… */
comment=Rsync Backup Server 	/* rsync μ„œλΉ„μŠ€μ— λŒ€ν•œ μ„€λͺ… */
path=/backup1 			/* 미러링될 λ°μ΄ν„°μ˜ 경둜 (λŒ€μƒνŒŒμΌκ²½λ‘œ) */
read only=no 
----------------------------------------
# systemctl enable --now rsyncd.socket

(rsync client)
# rsync -avz --delete -e ssh server::Backup /mirror

λ¦¬λˆ…μŠ€ λ„€νŠΈμ›Œν¬ /μ„œλΉ„μŠ€/λ³΄μ•ˆ κ³Όμ •


------------1μž₯ λ„€νŠΈμ›Œν¬ μ„€μ •----------------


μ£Όμ†Œμ’…λ₯˜

  • MAC (Media Access Control Address) λ„€νŠΈμ›Œν¬ μ„Έκ·Έλ¨ΌνŠΈμ˜ 데이터 링크 κ³„μΈ΅μ—μ„œ 톡신을 μœ„ν•œ λ„€νŠΈμ›Œν¬ μΈν„°νŽ˜μ΄μŠ€μ— ν• λ‹Ήλœ 고유 μ‹λ³„μžμ΄λ‹€.
  • 이더넷 μƒμ—μ„œ 톡신 ν•  λ•Œ μ‚¬μš©ν•˜λŠ” μ£Όμ†Œ

ip link == 00:0c:29:45:93:63

  • IP Address 컴퓨터 λ„€νŠΈμ›Œν¬μ—μ„œ μž₯μΉ˜λ“€μ΄ μ„œλ‘œλ₯Ό μΈμ‹ν•˜κ³  톡신을 ν•˜κΈ° μœ„ν•΄μ„œ μ‚¬μš©ν•˜λŠ” νŠΉμˆ˜ν•œ λ²ˆν˜Έμ΄λ‹€. -ipv4: 32bit 4byte 4octet 10μ§„μˆ˜ - 192.168.10.10 -ipv6: 128bit 16byte 8octet 16μ§„μˆ˜ - fe80::20c29ff:fea5:1263
  • Port Address 포트 μ£Όμ†ŒλŠ” μ†Œν”„νŠΈμ›¨μ–΄μ—μ„œλŠ” λ„€νŠΈμ›Œν¬ μ„œλΉ„μŠ€λ‚˜ νŠΉμ • ν”„λ‘œμ„ΈμŠ€λ₯Ό μ‹λ³„ν•˜λŠ” 논리 λ‹¨μœ„μ΄λ‹€. ν¬νŠΈλŠ” 번호둜 κ΅¬λ³„λ˜λ©° 이 번호λ₯Ό 포트 번호라고 ν•œλ‹€. 포트 λ²ˆν˜ΈλŠ” IP μ£Όμ†Œμ™€ ν•¨κ»˜ μ“°μ—¬ ν•΄λ‹Ήν•˜λŠ” ν”„λ‘œν† μ½œμ— μ˜ν•΄ μ‚¬μš©λœλ‹€. 예λ₯Ό λ“€μ–΄, ftp://000.000.000.000:21 λΌλŠ” URL μ—μ„œ 맨 λ§ˆμ§€λ§‰μ— μžˆλŠ” 21이 포트 번호

NetworkManager?

  • ens33(λ³€κ²½κ°€λŠ₯)= λ„€νŠΈμ›Œν¬ 컀λ„₯μ…˜ 번호 = μ•ˆμ— λ„€νŠΈμ›Œν¬ 정보듀이 λ“€μ–΄μžˆλ‹€.
  • Network interface
  • connection/profile

λ„€νŠΈμ›Œν¬ κ΄€λ ¨ μ„€μ • νŒŒμΌλ“€ * /etc/hosts 아이피(IP)와 호슀트 이름(hostname) λ˜λŠ” 도메인 이름(Domain Name)을 λ§΅ν•‘(Mapping)ν•˜λŠ” 역할을 κ°€μ§„λ‹€. * /etc/hosts.conf 이름 μš”μ²­(도메인 μš”μ²­, Naming Service Request)μ‹œ 도메인/이름 검색 μˆœμ„œλ₯Ό λ‚˜νƒ€λ‚Έλ‹€. * /etc/resolv.conf * /etc/sysconfig/network-scripts/ifcfg-* λ„€νŠΈμ›Œν¬ κ΄€λ ¨ λͺ…λ Ήμ–΄λ“€ * cthtool ens33 * ip addr * ip route * cat /etc/resolv.conf * netstat -nr == ip κ²Œμ΄νŠΈμ›¨μ΄ 확인 λ„€νŠΈμ›Œν¬ μ„€μ • κ΄€λ ¨ 툴 * nmcli CMD * nmcli 툴 nm-connection-editor 툴 nmcli general permissions : λ„€νŠΈμ›Œν¬ κΆŒν•œμ„ μ΄κ΄„μ μœΌλ‘œ λ΄„

λ„€νŠΈμ›Œν¬ μ‹œλ‚˜λ¦¬μ˜€ μž‘μ—…
	* ip λ³€κ²½ μž‘μ—…
	* nic μΆ”κ°€ μž‘μ—…
	* 호슀트 이름 λ³€κ²½
	* νŒ€ ꡬ성, λ³Έλ”© ꡬ성
		(γ„±) team0
			# nmcli connection add \
			type team 
			ifname team0 
			con-name team0 
			team.runner activebackup
		(γ„΄) team0 (team0-portl, team0-port2)
			nmcli connection add \
			type etherner \
			slave-type team \
			ifname ens33 \
			con-name team-port1 \
		master team0
		(γ„·) team0
			nmcli connection modify team0 \
			ipv4.method manual \
			ipv4.addresses 192.168.10.100/24 \
			ipv4.gateway 192.168.10.2 \
			ipv4.dns 168.126.63.1 \
			ipv4.dns-search example.com 
		(γ„Ή) team0
			nmcli connection up team0
		
		(κ·Έλ°–)
		# nmcli connection add \
		type team \
		ifname team0 \
		con-name team0 \
		config'{"runner": {"name": "activebackup"}}'

		nmcli connection add \
		type etherner \
		slave-type team \
		ifname ens36 \
		con-name team-port1 \
		master team0
		
	[λ„€νŠΈμ›Œν¬ 볡원] network 섀정을 μž‘μ—…ν•˜κΈ° μ „ μƒνƒœλ‘œ 돌리기(ens33,36)
	* ens33 : ip(192.168.19.20/24), gw(192.168.10.2), dns(168.126.63.1)
	* ens36 : connection/profile => x
		
	COMMON_OPTIONS:
        type <type>
        ifname <interface name> | "*"
        [con-name <connection name>]
        [autoconnect yes|no]
        [save yes|no]
        [master <master (ifname, or connection UUID or name)>]
        [slave-type <master connection type>]
	
	team:[config <file>|<raw JSON data>]

	team-slave:master <master (ifname, or connection UUID or name)>
              [config <file>|<raw JSON data>]
			  
	IP_OPTIONS:
              [ip4 <IPv4 address>] [gw4 <IPv4 gateway>]
              [ip6 <IPv6 address>] [gw6 <IPv6 gateway>]

------------2μž₯ SELinux관리----------------


SELINUX? SELINUX λͺ¨λ“œ * enforcing * permissive * disabled

disabled <-> permissive,enforcing * disabled -> enforcing # vi /etc/selinux/config SELINUX=enforcing # reboot * enforcing -> disabled # vi /etc/selinux/config SELINUX=disabled # reboot * enforcing -> permissive # setenforce 0 # vi /etc/selinux/config SELINUX=permissive

SELINUX Context # semanage fcontext -l # semanage fcontext -a -t http_sys_contene_t '/virtual(/.*)?' # restorecon -Rv /virtual SELINUX Boolean # semanage boolean -l # semanage boolean -l -C = 초기 κ΅¬μ„±μƒνƒœμ™€ 비ꡐ해 λ‹€λ₯Έ 점을 μ•Œλ €μ€Œ # setsebool -P httpd_enable_httpd on SELINUX port # semanage port -l = 확인 # semanage port -a -t http_port_t -p tcp 8888 = μΆ”κ°€ SELINUX Troubleshooting (γ„±) 문제 원인 νŒŒμ•… # cat /var/log/messages | grep -i preventing # sealert -l UUID == μ•ˆμ— ν•΄κ²° 방법이 있음 or # cat /var/log/audit/audit.log | grep -i 'avc: denied' # sealert -a /var/log/audit/audit.log (γ„΄) λ¬Έμ œν•΄κ²° 방법 - 이 μ€‘μ—μ„œ λ¬Έμ œκ°€ μžˆμ„ 수 μžˆλ‹€. * SELINUX context 문제 ν•΄κ²° * SELINUX boolean 문제 ν•΄κ²° * SELINUX port 문제 ν•΄κ²°


-------------3μž₯ λ°©ν™”λ²½ 관리----------------


[firewalld?(nftables)] firewalldλŠ” 동적 λ°©ν™”λ²½ κ΄€λ¦¬μžλ‘œ nft λͺ…령을 μ‚¬μš©ν•˜λŠ” nftables ν”„λ ˆμž„μ›Œν¬μ— λŒ€ν•œ ν”„λ‘ νŠΈμ—”νŠΈμ΄λ‹€.

(CLI) firewall-cmd CMD (alias fwcmd)
(GUI) firewall-config (firewall-config νŒ¨ν‚€μ§€(λ‹€μš΄λ‘œλ“œ))

firewall-cmd CMD
	# firewall-cmd --permanent --add-service=http --add-service=https
	# firewall-cmd --permanent --add-port=1521/tcp
	# firewall-cmd --reload (alias fwreload)

[리치 κ·œμΉ™]
κ°„λ‹¨ν•œ λ°©ν™”λ²½ 섀정은 μ•žμ— fwcmd 둜 λ“±λ‘ν•˜λ©΄ λ˜μ§€λ§Œ μ—¬λŸ¬κ°€μ§€ 섀정이 ν•„μš”ν•˜λ‹€λ©΄
리치 κ·œμΉ™μ„ μ‚¬μš©ν•˜μ—¬ μ„€μ •ν•˜λŠ”κ²ƒμ΄ μœ λ¦¬ν•˜λ‹€.
# firewall-config 둜 μ„€μ •ν•˜λŠ”κ²ƒμ΄ μ’‹λ‹€.

-------------4μž₯ DNS Server--------------


  • dns μ„œλ²„μ˜ μ—­ν•  = 이름과 ipλ₯Ό λ§€μΉ­μ‹œμΌœμ£ΌλŠ” 역할을 μˆ˜ν–‰ν•œλ‹€.
  • λ‹€μ΄λ‚˜λ―Ή dns = μ›κ²©μ„œλ²„μ—μ„œ nsupdateλ₯Ό 톡해 dns 섀정을 μ›κ²©μœΌλ‘œ λ°”κΎΈλŠ”κ²ƒ
  • 캐싱= 정보λ₯Ό μž„μ‹œλ‘œ λ³΄κ΄€ν•˜λŠ”κ²ƒ
  • ν”„λ‘œκ·Έλž¨: bind. bind-urills
  • 데λͺ¬ & 포트.ν”„λ‘œν† μ½œ: named(53/tdp, 53/tcp)
  • μ„€μ •νŒŒμΌ: /etc/named,conf/ (/etc/named.rfc1912.zones)
  • μ„œλΉ„μŠ€ μ„€μ •νŒŒμΌ : /var/named*

[μ‹€μŠ΅] 초기 도메인 관리 -/etc/hosts

도메인 μ„€μ •μ‹œ 문제 확인

cat /etc/resolv.conf 의 ipμ£Όμ†Œ 확인 1. nameserver의 ipκ°€ λ‹€λ₯Έκ²½μš° nmtui둜 eth0의 dns ipμ£Όμ†Œλ₯Ό λ°”κΎΌλ‹€ λ°©ν™”λ²½ 리슀트둜 확인 systemctl status named둜 확인

dnssec : λ°μ΄ν„°μ˜ μœ„λ³€μ‘°λ₯Ό λ°©μ§€ν•˜κΈ° μœ„ν•œ μˆ˜λ‹¨μœΌλ‘œ μ‚¬μš©λ˜λŠ”κ²ƒ γ„΄ μ‚¬μš©ν•˜λŠ” 기술: κ³΅κ°œν‚€ μ•”ν˜Έν™” , μ„œλͺ…방식

λˆ„λ½

[관리] DNS λͺ¨λ‹ˆν„°λ§ * dnsgraph


----------5μž₯ Apache web Server----------


  • μ›Ήμ„œλ²„: 정적 컨텐츠λ₯Ό 제곡 (jpg,ntw) ex= apache httpd
  • Web Application Server: 동적 컨텐츠 제곡 ( .jsp , .asp) =tomcat

β–  ν”„λ‘œκ·Έλž¨: httpd, mod_ssl
β–  데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ: httpd(80/tcp, 443/tcp)
β–  μ„€μ • 파일: /etc/httpd/conf/httpd.conf
β–  ν•˜μœ„ μ„€μ • 파일: /etc/httpd/conf.d/*.conf
β–  μ„œλΉ„μŠ€: httpd.service

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install httpd mod_ssl

  2. μ„œλΉ„μŠ€ ꡬ섀

    vi /etc/httpd/conf/httpd.conf

    vi /etc/httpd/conf.d/*.conf

    echo 'MyServer' > /var/www/html/index.html

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now http.service 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-service={http,https} # fwreload --------------------μ›Ήμ„œλ²„ μ‚¬μš©--------------------- [μ‹€μŠ΅] 초기 μ›Ήμ„œλ²„ μ„€μ • 점검 # firefox https://www.example.com = https둜 λΆˆλŸ¬μ™€μ„œ μΈμ¦μ„œ 과정을 κ±°μΉ¨ # curl -k http://www.example.com = ν„°λ―Έλ„λ‘œ λΆˆλŸ¬μ™€μ„œ 확인 -kλŠ” μΈμ¦μ„œκ°€ μ—†μ–΄ λ°œμƒν•˜λŠ” μœ„ν—˜μ„ κ°μˆ˜ν•˜κ³  μ‹€ν–‰ν•œλ‹€λŠ” λͺ…λ Ήλ¬Έ # curl -I http://www.example.com = ν—€λ”μ •λ³΄λ§Œ ν™•μΈν•˜κΈ° μœ„ν•œ λͺ…λ Ήμ–΄

[μ‹€μŠ΅] κ΄€λ¦¬μž μ›Ήμ„œλ²„ ꡬ좕(www.example.com) * /etc/httpd/conf/httpd.conf{ServerAdmin, ServerName}

[μ‹€μŠ΅] ν΄λΌμ΄μ–ΈνŠΈ ν”„λ‘œκ·Έλž¨ μ‚¬μš© *curl, firefox 링크둜 μ‚¬μš©

[μ‹€μŠ΅] CGI μ‚¬μš© =β€’ μ›Ήμ„œλ²„μ™€ ν΄λΌμ΄μ–ΈνŠΈκ°„μ— ν•„μš”ν•œ 정보 κ΅ν™˜μ„ κ°€λŠ₯ν•˜κ²Œ ν•΄μ£ΌλŠ” μ›ΉμΈν„°νŽ˜μ΄μŠ€.

[μ‹€μŠ΅] μ‚¬μš©μž μ›Ήμ„œλ²„ ꡬ좕(www.example.com/~user01) # vi /etc/httpd/conf.d/userdir.conf(UserDir public_html) $ chmod 711 /home/user01/ = user01에 κΆŒν•œμ„ λ³€κ²½ν•΄μ€˜μ•Ό λ°–μ—μ„œ λ΄„ $ mkdir /home/user01/public_html $ echo 'User01WebPage' > /home/user01/public_html/index.html

[μ‹€μŠ΅] μ‚¬μš©μž μ›Ήμ„œλ²„ ꡬ좕2(www.example.com/~user01) # /etc/httpd/conf/http.conf(Alias /user01 /home/user01/public_html)

(*) Apache Web Server μ‹€ν–‰ (ν˜„μž¬) # systemctl start|stop|restart|status httpd.service (λΆ€νŒ…) # systemctl enable|disable httpd.service

[μ‹€μŠ΅] CGI μ„€μ • - bash shell μ‚¬μš© * /etc/httpd/conf.d/vhost.conf(scriptAlias /cgi-bin/ /vhost.conf)

[μ‹€μŠ΅] CGI μ„€μ • - perl μ‚¬μš© # yum install mod_perl(epel-release) * /etc/httpd/conf.d/perl.conf

[μ‹€μŠ΅] PHP μ‚¬μš© # yum -y install php * /etc/httpd/conf.d/php.conf

[μ‹€μŠ΅] .htaccess - μ›ΉνŽ˜μ΄μ§€ 보호 * /etc/httpd/conf.d/vhost.conf(AllowOverride AuthConfig * /www1/cgi-bin/.htaccess * htpasswd -c /etc/httpd/passwd webmaster

[μ‹€μŠ΅] κ°€μƒν˜ΈμŠ€νŠΈ (virtual Hosting) -ν•˜λ‚˜μ˜ μ›Ήμ„œλ²„μ— μ—¬λŸ¬κ°œμ˜ μ›Ήμ„œλ²„λ₯Ό λ§Œλ“œλŠ”κ²ƒ (γ„±) 이름 기반 가상 ν˜ΈμŠ€νŒ…(Name-based Virtual Hosting) (γ„΄) 포트 기반 가상 ν˜ΈμŠ€νŒ…(port-based Virtual Hosting) (γ„·) IP 기반 가상 ν˜ΈμŠ€νŒ… (IP-based Virtual Hosting)

[μ‹€μŠ΅] μ›Ήμ„œλ²„ 정보/μƒνƒœ/톡계 λͺ¨λ‹ˆν„°λ§ * 1) 정보 => http://www.example.com/server-info * 2) μƒνƒœ => http://www.example.com/server-status * 3) 톡계 => http://www.example.com/usage * webalizer (/etc/webalizer.conf) * /etc/httpd/conf.d/webalizer.conf

[μ‹€μŠ΅] μ›Ή 슀트레슀 툴 = webstress tool

μ›Ήμ„œλ²„μ˜ 정보λ₯Ό ν™•μΈν•˜λŠ” μ‚¬μ΄νŠΈ : https://sitereport.netcraft.com/

[μ‹€μŠ΅] 버전 μž₯버/OS 정보 숨기기 * /etc/httpd/conf.d/default.conf(servertoken prod)

[μ‹€μŠ΅] ATJM(Apache + tomcat + hsp +MariaDB) Apache|nginnx|IIS - Tomcat|JBoss - MYSQL/MariaDB/PostgreSQL

[λ³΄μ•ˆ] * μ›Ή λ°©ν™”λ²½ (WAF) * modsecurity # yum install mod_security # yum install mod_security_crs # systemctl restart httpd * μ›Ή 취약점 무료 점검 μ„œλΉ„μŠ€

[μ°Έκ³ ] Apache - Tomcat μ™œ μ—°λ™ν•˜λŠ”κ°€? (γ„±) λΆ€ν•˜ λΆ„μ‚° (γ„΄) ν΄λŸ¬μŠ€ν„°(μ„Έμ…˜ ν΄λŸ¬μŠ€ν„°) - μž₯μ• μ²˜λ¦¬ (γ„·) μ•„νŒŒμΉ˜ μ›Ήμ„œλ²„μ˜ λ³΄μ•ˆ κΈ°λŠ₯ 및 μΆ”κ°€ κΈ°λŠ₯ μ‚¬μš©

-------------------[μ°Έκ³ ] ν΄λΌμ΄μ–ΈνŠΈ μͺ½μ—μ„œ 확인 방법 -------------------- # ping 192.168.10.30 -c 1 -> server2 alive 확인 # nmap -p 80,443 192.168.10.30 -> server2 firewall μ„€μ • # firefox http://192.168.10.30 -> httpd.service 기동/μ„€μ • # curl http://www.example.com -> dns μ„€μ •

μ•„νŒŒμΉ˜ HTTP μ›Ήμ„œλ²„ μ„€μ • 및 λ³€κ²½κ³Ό NGINX μ„€μ • 및 ꡬ성 https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/deploying_different_types_of_servers/setting-apache-http-server_deploying-different-types-of-servers


----------6μž₯ FTP Server----------



β–  ν”„λ‘œκ·Έλž¨: vsftpd, ftp
β–  데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ: /usr/sbin/vsftpd, 21/tcp, 20/tcp, 1024/tcp 이상
β–  μ£Ό μ„€μ • 파일: /etc/vsftpd/vsftpd.conf
β–  ν•˜μœ„ μ„€μ • 파일: /etc/vsftpd/{user_list, ftpusers}
β–  μ„œλΉ„μŠ€: vsftpd.service

β–  vsftpd κ΄€λ ¨ νŒŒμΌλ“€

파일 μ’…λ₯˜ μ„€λͺ… /etc/vsftpd/vsftpd.conf = vsftpd ν”„λ‘œκ·Έλž¨μ˜ μ£Ό μ„€μ • 파일 /etc/vsftpd/ftpusers = vsftpd μ„œλ²„μ— 접속할 수 μ—†λŠ” μ‚¬μš©μž μ •μ˜ /etc/vsftpd/user_list = vsftpd μ„œλ²„μ— 접속할 수 μ—†λŠ” μ‚¬μš©μž μ •μ˜ /var/ftp = Anonymous FTP μ‚¬μš©μžλ₯Ό μœ„ν•œ 디렉토리

--------------ftp μ„œλ²„κ΅¬μ„±μ ˆμ°¨--------------------------

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install vsftpd ftp

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/vsftpd/vsftpd/conf

    vi /etc/vsftpd/(ftpusers,user_list)

    echo 'MyServer' > /var/www/html/index.html

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now vsftpd.service 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-service=ftp # fwreload

[μ‹€μŠ΅] 초기 ftp μ„œλ²„ μ„€μ • 점검 [μ‹€μŠ΅] vsftpd FTP server ꡬ좕 [μ‹€μŠ΅] ftp μ„œλ²„ μ‚¬μš©μž μ ‘κ·Ό μ œμ–΄ */etc/vsftpd/{ftpusers,user_list} [μ‹€μŠ΅] ν΄λΌμ΄μ–ΈνŠΈ ν”„λ‘œκ·Έλž¨ [μ‹€μŠ΅] μ„Έμ…˜ νƒ€μž„ 아웃 μ„€μ • * idle_session_timeout=9000 * data_connection_timeout=9000 [μ‹€μŠ΅] 일반 μ‚¬μš©μž chroot ꡬ성 * chroot_local_user=YES * allow_writeable_chroot=YES * chroot_list_enable=YES * chroot_list_file=/etc/vsfrpd/chroot list * echo 'root' >> /etc/vsfrpd/chroot list [μ‹€μŠ΅] 읡λͺ… ftx enable=YES anonymos enable=YES

[μ‹€μŠ΅] 읡λͺ… ftp μ—…λ‘œλ“œ κΈ°λŠ₯ μ„€μ • * /var/ftp/pub/incoming(603) 3 --- μ‘Έμ•„μ„œ 이 λΆ€λΆ„ ν•„κΈ° λͺ»ν•¨---

[λ³΄μ•ˆ] FTP λ³΄μ•ˆ * μ ‘κ·Ό μ œμ–΄ * 호슀트 μ ‘κ·Ό μ œμ–΄ -> firewalld * μ‚¬μš©μž μ ‘κ·Ό μ œμ–΄ -> /etc/vsfrpd/{user_list. ftpusers} *userlist_deny=NO, /etc/vsfrpd/user_list * μžμ› μ œμ–΄ * max_clients, max_per_ip * idle_session_timeout , data_connection_timeout * νŒ¨ν‚€μ§€ μ—…λ°μ΄νŠΈ/패치 * yum update vsfrpd * chroot ꡬ성 * ftp -> sftp/ftps * ftp 포트

  • ftp 포트 -active mode -Passive Mode
  • ftp 둜그 확인 λͺ…λ Ήμ–΄: tail -f /var/log/xferlog -λ‹€μš΄λ‘œλ“œμ— λŒ€ν•΄ tail -f /var/log/secure - 인증에 λŒ€ν•΄

----------7μž₯ Mail Server----------


  • μš©μ–΄:
    • MTA , MUA
    • SMTP/ESMTP(메일 λ³΄λ‚Όλ•Œ) / POP3, IMAP4 (메일 λ°›μ„λ•Œ)

MAIL(sendmail) Server β–  νŒ¨ν‚€μ§€: sendmail β–  데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ: /usr/sbin/sendmail, 25/tcp, 465/tcp β–  μ£Ό μ„€μ • 파일: /etc/mail/sendmail.cf β–  μ„œλΈŒ μ„€μ • 파일: /etc/mail/*, /etc/aliases β–  μ„œλΉ„μŠ€: sendmail.service

POP3/IMAP4(dovecot) Server
β–  νŒ¨ν‚€μ§€: dovecot
β–  데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ: /usr/sbin/dovecot, 110/tcp, 143/tcp, 995/tcp, 993/tcp
β–  μ„€μ • 파일: /etc/dovecot/dovecot.conf
β–  슀크립트: dovecot.service

--------------POP3/IMAP(postfix) Mail(sendmail) μ„œλ²„κ΅¬μ„±μ ˆμ°¨-------------------------- ------Mail(sendmail)------

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install sendmail mailx

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/mail/sendmail.cf

    vi /etc/mail/*

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now sendmail.service 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-service={smtp,smtps} # fwreload

---POP3/IMAP(postfix)------

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install sendmail dovecot

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/dovecot.conf

    vi /etc/dovecot/conf.t

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now dovecot 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-service={pop3,pop3s,imap,imaps} # fwreload

[μ‹€μŠ΅] 초기 mail (sendmail) μ„œλ²„ μ„€μ • 점검 [μ‹€μŠ΅] 초기 POP3/IMAP(dovecot) μ„œλ²„ μ„€μ • 점검

(1) (main) example.com 메일 ν΄λΌμ΄μ–ΈνŠΈ ν”„λ‘œκ·Έλž¨(EX: evolution μ‚¬μš©) β€’ 192.168.10.10μ—μ„œ μ„€μ •ν•œλ‹€. β€’ (주의) root μ‚¬μš©μžλ‘œ ν…ŒμŠ€νŠΈ ν•˜μ§€ μ•Šκ³ , 일반 μ‚¬μš©μž(EX: user01)둜 ν…ŒμŠ€νŠΈ ν•œλ‹€. -> Evolution ν”„λ‘œκ·Έλž¨μ„ 톡해 μ„€μ •ν•œλ‹€.

β‘  ν”„λ‘œκ·Έλž¨ μ„€μΉ˜

yum install evolution

β‘‘ ν”„λ‘œκ·Έλž¨ μ‹€ν–‰ Linux Pannel > Application > Office > Email or

export LANG=ko_KR.UTF-8

evolution &

β‘’ evolution μ„€μ • μž‘μ—… (GUI)

Evolution Setup Assistant user01 μ‚¬μš©μž μ„€μ • 방법

β–  Welcome ν™”λ©΄ -> Next β–  Restore from backup ν™”λ©΄ -> Next β–  Identity ν™”λ©΄ -> Required Information Full Name : user01 Email Address : user01@example.com -> Next β–  Receiving Email ν™”λ©΄ -> Server Type: POP -> Configuration Server: mail.example.com Username: user01 -> Next β–  Receiving Options ν™”λ©΄ -> Next β–  Sending Email ν™”λ©΄ -> Server Type: SMTP -> Server : mail.example.com -> Next β–  Account Summary ν™”λ©΄ -> Next β–  Done ν™”λ©΄ -> Apply

μ—λ³Όλ£¨μ…˜(evolution) > νŽΈμ§‘(Edit) > κΈ°λ³Έ μ„€μ •(Preferences) > 메일 계정(Mail Account) μ‚¬μš©μž μˆœμ„œ λ³€κ²½: [v] user01@example.com [v]κΈ°λ³Έκ°’ [v] 이 컴퓨터 [v] 검색폴더

[μ‹€μŠ΅] Squirrelmail (λ‹€λžŒμ₯ 메일) μ›Ήμ„œλ²„μ˜ ν˜•μ‹μœΌλ‘œ 메일을 보내고 받을 수 있게 λ³΄μ—¬μ£ΌλŠ”κ²ƒμ΄μ§€ 직접 λ™μž‘ν•˜λŠ”κ²ƒμ΄ μ•„λ‹ˆλ‹€.

  • [μ‹€μŠ΅x] Anti-SPAM(spamassessin)
  • [μ‹€μŠ΅x] Anti-Virus

파일 λ°”μ΄λŸ¬μŠ€ 확인: https://www.virustotal.com/gui/home/upload


----------8μž₯ NFS Service----------



NFS 버전: NFSnv, NFSv4(4/0, 4.2) NFS 데λͺ¬: nfs, mountd NFS 파일: (server) /etc/exports / (client) /etc/fatab NFS λͺ…λ Ή (server) exportfs CMD / (Client)showmount ,CMD mount CMD

-------------------NFS V4 server-------------------------------------- β–  ν”„λ‘œκ·Έλž¨: nfs-utils β–  데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ:nfs(2049/tcp) β–  μ£Ό μ„€μ • 파일: /etc/exports β–  ν•˜μœ„ μ„€μ • 파일: /etc/exports.d/*.exports β–  μ„œλΉ„μŠ€: nfs-server.service

-NFS server

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install nfs-utils

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/exports

    vi /etc/exports.d/*.exportfs

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now nfs-server 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-service={nfs,rpc-bind,mountd} # fwreload

[μ‹€μŠ΅] 초기 NFS μ„œλ²„ μ„€μ • 점검 [μ‹€μŠ΅]


-------9μž₯ SMB/CIFS Server------


  • CIFS = SMB + NetBIOS
  • SMB κ΄€λ ¨ λͺ…λ Ή: (Server) (Client) SMB client CMD

β–  ν”„λ‘œκ·Έλž¨: samba, samba-clinet, cifs-utils β–  데λͺ¬ & 포트 : smbd(139/tcp, 445/tcp), nmbd(137/udp, 138/udp) β–  μ£Ό μ„€μ • 파일: /etc/samba/smb.conf β–  μ„œλΉ„μŠ€: smb.service, nmb.service, winbind.service

-samba μ„œλ²„ ꡬ성 절차

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install samba samba-client cifs-utils

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/samba/smb.conf

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now smb nmb 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-service=samba # fwreload

testparm = μ‚Όλ°”μ˜ conf μ„€μ •νŒŒμΌμ„ 보여쀀닀 (/etc/smb/smb.conf)

# testparm -v = μ’€ 더 μžμ„Ένžˆ 좜λ ₯! 기본값을 확인 ν•  λ•Œ μ‚¬μš©ν•œλ‹€.   
	# testparm -s -v = -sλŠ” 쀑간에 μ—”ν„°λ₯Ό μΉ˜λŠ” 과정을 μƒλž΅ν•¨! 주둜 이거 씀!!
	# testparm -sv | sed '/homes/,$d'
	# testparm -sv | sed '/homes/,$d'| grep -i 'read only'

β€’ valid users = κ³΅μœ λ””λ ‰ν† λ¦¬μ— μ ‘κ·Ό ν•  수 μžˆλŠ” μ‚¬μš©μž λͺ©λ‘ β€’ write list = 곡유 디렉토리에 rw κΆŒν•œμ΄ κ°€λŠ₯ν•œ μ‚¬μš©μž λͺ©λ‘

mount.cifs

umount.cifs

----------------------smb μ‚¬μš©μž λ§Œλ“€κΈ°--------------------------- # useradd -M -s /sbin/nologin smbuser1 # useradd -M -s /sbin/nolgoin smbuser2

(SMB μ‚¬μš©μž μΆ”κ°€/μ‚­μ œ)  # smbpasswd -a|-x smbuser1
(SMB μ‚¬μš©μž ν™œμ„±/λΉ„ν™œμ„±)# smbpasswd -e|-d smbuser1

--------------------λ¦¬λˆ…μŠ€μ—μ„œ μœˆλ„μš°λ‘œ 파일 곡유 확인---------------------------- (λ‘λ²ˆμ§Έ 방법) λ°”νƒ•ν™”λ©΄μ—μ„œ ν™•μΈν•˜κΈ° -> "root's Home" μ•„μ΄μ½˜ 더블클릭 -> μƒˆλ‘œ 뜬 'root' μ°½μ—μ„œ 'Other Locations' λΆ€λΆ„ 선택 -> "Connect to Server" λΆ€λΆ„μ˜ 'Enter server address...' λ‹€μŒμ„ μž…λ ₯ smb://192.168.10.202/ -> 곡유된 μžμ›μ΄ 보일것이닀. 곡유된 μžμ› 쀑 samba_share μ„ νƒν•˜κ³  우클릭 ν•˜κ³  mount 선택

[정리] (γ„±) λ¦¬λˆ…μŠ€ 곡유(/samba) οƒŸ------mount------οƒ  μœˆλ„μš° 마운트 *μž„μ‹œλ§ˆμš΄νŠΈ: <win + E> 파일 탐색기 μ—΄μ–΄μ„œ μœ„ μ£Όμ†Œμ°½μ— \μƒλŒ€μ£Όμ†Œ λ₯Ό μž…λ ₯ν•˜λ©΄ 접속 됨. γ„΄ μ΄λŠ” μž¬λΆ€νŒ… ν•˜λ©΄ λ‚ λΌκ°€λŠ” μž„μ‹œμ μΈ 방편 *영ꡬ마운트: μƒλŒ€ μ£Όμ†Œλ‘œ μ ‘μ†ν•˜μ—¬ 곡유 폴더λ₯Ό 우클릭 ν•˜μ—¬ λ„€νŠΈμ›Œν¬ 파일 곡유λ₯Ό 선택해쀀닀

(γ„΄) μœˆλ„μš° 곡유(/samba) οƒŸ------mount------οƒ  λ¦¬λˆ…μŠ€ 마운트 *μž„μ‹œλ§ˆμš΄νŠΈ:

smbclient //192.168.10.20/share –U smbuser1

Or

mount –p /mnt/server ; mount.cifs //μƒλŒ€μ£Όμ†Œ/share /mnt/server –o user=soldesk

	*영ꡬ마운트:
	# mkdir –p /mnt/share
	# vi /etc/fstab
	# //192.168.10.202/samba_share     /mnt/server     cifs    credentials=/root/cred  0  0
	# mount a

β‘‘ κ·Έλ£Ή μΆ”κ°€ 및 곡유 디렉토리 μ„€μ •

groupadd -r marketing

mkdir -p /smbshare

chgrp marketing /smbshare

chmod 2775 /smbshare

ls -ld /smbshare

(μ„ ν–‰ μž‘μ—…) β‘  νŒ¨ν‚€μ§€ μ„€μΉ˜

yum install samba-client cifs-utils

&& smbclient -L 192.168.10.20 -U smbuser4 γ„΄ 마운트 확인! Test1이 μžˆμ–΄μ•Όν•œλ‹€!

[μ‹€μŠ΅] 초기 smb/cifs μ„œλ²„ μ„€μ • 점검 [μ‹€μŠ΅] λ¦¬λˆ…μŠ€ 곡유 μ„œλ²„μ— μœˆλ„μš° ν΄λΌμ΄μ–ΈνŠΈ μ ‘κ·Ό [μ‹€μŠ΅] μœˆλ„μš° κ³΅μœ μ„œλ²„μ— λ¦¬λˆ…μŠ€ ν΄λΌμ΄μ–ΈνŠΈ μ ‘κ·Ό [μ‹€μŠ΅] λ¦¬λˆ…μŠ€ 곡유 μ„œλ²„μ— λ¦¬λˆ…μŠ€ ν΄λΌμ΄μ–ΈνŠΈ μ ‘κ·Ό


-------10μž₯ Log server------



  • μžμ› / 둜그 λͺ¨λ‹ˆν„°λ§

  • μ‹œμŠ€ν…œ κΈ°λ³Έ 둜그 νŒŒμΌλ“€

    • OS 기둝: /var/log/messages /var/log/secure, /var/log/boot.log /var/log/{wtmp,btmp}
    • μ„œλΉ„μŠ€ 기둝 : dns /var/log/messages web /var/log/httpd/* ftp /var/log/xferlog
  • rsyslog 체계 (/etc/rsyslog.conf) - λ¦¬λˆ…μŠ€κ°€ 기둝을 λ‚¨κΈ°λŠ” 체계


-Log server β–  rsyslog μ„œλ²„μ— λŒ€ν•΄μ„œ ● νŒ¨ν‚€μ§€: rsyslog ● 데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ: rsyslogd(514/tcp, 514/udp) ● μ£Ό μ„€μ • 파일: /etc/rsyslog.conf ● λΆ€ μ„€μ • 파일: /etc/rsyslog.d/*.conf ● μ„œλΉ„μŠ€: rsyslog.service

-log server μ„œλ²„ ꡬ성 절차

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install rsyslog

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/rsyslog.conf

    vi /etc/rsyslog.d/*.conf

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now rsyslog 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-port={514/tcp,514/udp} # firewall-cmd --permanent --add-service=syslog-tls # fwreload

[μ‹€μŠ΅] 초기 둜그 μ„œλ²„ μ„€μ • 점검 [μ‹€μŠ΅] κΈ°λ³Έ 둜그 파일(인증둜그 기둝, /var/log/secure) [μ‹€μŠ΅] κΈ°λ³Έ 둜그 파일(λ©”μΌλ‘œκ·Έ 기둝, /var/log/maillog) [μ‹€μŠ΅] κΈ°λ³Έ 둜그 파일(μŠ€μΌ€μ€„λŸ¬ 기둝, /var/log/cron) [μ‹€μŠ΅] μƒˆλ‘œμš΄ 둜그 파일(/var/log/file.log) * μ‰˜ 슀크립트λ₯Ό μ‚¬μš©ν•œ 둜그 생성 * rsyslog 체계λ₯Ό μ‚¬μš©ν•œ 둜그 생성 (logger CMD) [μ‹€μŠ΅] 둜그 μ„œλ²„ ꡬ좕 1/2 [μ‹€μŠ΅] visutl syslog μ„œλ²„ μ„€μΉ˜ [μ‹€μŠ΅] evenrlog-to-syslog μ„€μΉ˜ [μ‹€μŠ΅] graylog server μ„€μΉ˜ * graylog server * Elasticsearch * mongoDB [μ‹€μŠ΅] 둜그 파일 관리 * OS 기둝 (둜그 νŒŒμΌμ΄λ¦„μ΄ κ³ μ •λ˜μ–΄ μžˆλŠ” 경우) -> logrotate * μ„œλΉ„μŠ€ 기둝 (둜그 νŒŒμΌμ΄λ¦„μ΄ κ³ μ •λ˜μ–΄ μžˆμ§€ μ•Šμ€ 경우) -> find + crontab [μ‹€μŠ΅] 둜그 파일 뢄석 * λ©”μ„Έμ§€μ˜ λ‚œμ΄λ„ λ³„λ‘œ 확인이 κ°€λŠ₯ν•˜λ‹€. γ„΄ cat file.log | egrep -i '(warn|error|fail|crit|alert|emerg) * λ©”μ‹œμ§€ μ‹œκ°„ ( cat file.log | egrep 'Feb 21 1[0-2]:') * λ©”μ‹œμ§€ 생성 주체 * λ©”μ‹œμ§€ 생성 μ„œλ²„ * 단어 검사 .... [μ‹€μŠ΅] system journal /etc/systemd/journald.conf -> /run/log/journal -> /var/log/journal journalctl CMD # journalctl -p warning # journalctl --since ... until ... # journalctl -u named -f # journalctl -o verbose * 저널 영ꡬ μ €μž₯ μ„€μ • # vi /etc/systemd/journal.conf Storage=p


29νŽ˜μ΄μ§€ ν•˜λ‹€ 맘 Enter Password: admin 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918

[root@main ~]# pwgen -N 1 -s 96 5OPoSXI9YoyzGWAez7kXa4ud3uKPpFAhWQa9e2jmLY8qnlSS8qtC4V4ENcJNo3looiaLFAPfwakvz4xmeBIJt9PWq4uR3sAX


-------11μž₯ DHCP Server------



dhcp λ™μž‘ 원리: DORA (Discover , offer , request, ack)

DHCP Server ● νŒ¨ν‚€μ§€: dhcp-server , dhcp-client ● 데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ: dhcpd(67/udp) ● μ£Ό μ„€μ • 파일: /etc/dhcp/dhcpd.conf ● μ„œλΉ„μŠ€: dhcpd.service

-dhcp server μ„œλ²„ ꡬ성 절차

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum -y install dhcp-server dhcp-client

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/dhcpd.conf

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now dhcpd 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-port={dhcp,dhcp-client,dhcpv6} # fwreload

[μ‹€μŠ΅] 초기 μ„œλ²„ μ„€μ • 점검 [μ‹€μŠ΅] DHCP μ„œλ²„ ꡬ성 [μ‹€μŠ΅] DHCP ν΄λΌμ΄μ–ΈνŠΈ λ¦¬λˆ…μŠ€ (동적 ip) [μ‹€μŠ΅] DHCP ν΄λΌμ΄μ–ΈνŠΈ μœˆλ„μš° (동적 ip) [μ‹€μŠ΅] DHCP ν΄λΌμ΄μ–ΈνŠΈ λ¦¬λˆ…μŠ€ (κ³ μ • ip)


-------12μž₯ OpenSSH Server------



SSH Server β–  ν”„λ‘œκ·Έλž¨: openssh, openssh-clients, openssh-askpass, openssh-server β–  데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ: sshd(22/tcp) β–  μ£Όμ„€μ • 파일: /etc/ssh/sshd_config(sshd), /etc/ssh/ssh_config(ssh CMD) β–  μ„œλΉ„μŠ€: sshd.service β–  sshd(22) : ssh/scp/sftp

-dhcp server μ„œλ²„ ꡬ성 절차

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum -y install openssh openssh-server

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/sshd_config

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now sshd.service 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-port=ssh # fwreload

[μ‹€μŠ΅] root μ‚¬μš©μžμ— λŒ€ν•œ password authentication * /etc/ssh/sshd_config -permitRootLogin yes -passwordAuthentication yes [μ‹€μŠ΅]

λˆ„λ½


-------13μž₯ OpenSSH Server------



NTP Server ● νŒ¨ν‚€μ§€: chrony ● 데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ: chronyd(123/udp) ● μ£Όμ„€μ • 파일: /etc/chrony.conf ● μ„œλΉ„μŠ€: chronyd.service

-dhcp server μ„œλ²„ ꡬ성 절차

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum -y install chrony

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/chrony.conf

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now chronyd.service 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-port=ntp # fwreload

[μ‹€μŠ΅] 초기 μ„œλ²„ μ„€μ • 점검 [μ‹€μŠ΅] NTP μ„œλ²„ ꡬ성 - main [μ‹€μŠ΅] NTP ν΄λΌμ΄μ–ΈνŠΈ ꡬ성 -server1 [μ‹€μŠ΅] NTP ν΄λΌμ΄μ–ΈνŠΈ ꡬ성 -server2 [μ‹€μŠ΅] μ‹œκ°„ 동기화 μ‹€μŠ΅


-------14μž₯ MariaDB λ°μ΄ν„°λ² μ΄μŠ€------



MariaDB Server ● νŒ¨ν‚€μ§€: mariaDB, mariaDB-server ● 데λͺ¬ & 포트 & ν”„λ‘œν† μ½œ: mtsqld(3306/tcp) ● μ£Όμ„€μ • 파일: /etc/my.cnf ● μ„œλΈŒ μ„€μ • 파일: /etc/my.cnf.d/*.cnf ● μ„œλΉ„μŠ€: mariadb.service

-dhcp server μ„œλ²„ ꡬ성 절차

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install mariadb-server mariadb

  2. μ„œλΉ„μŠ€ ꡬ성

    vi /etc/my.cnf

3.μ„œλΉ„μŠ€ 기동 #systemctl enable --now mariadb.service 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-service=mysql # fwreload 5. 초기 λ³΄μ•ˆ μ„€μ • # mysql_secure_installation # mysql -u root -p 6. SELinux(?)

[μ‹€μŠ΅] 초기 μ„œλ²„ μ„€μ • 점검 [μ‹€μŠ΅] DB 관리 [μ‹€μŠ΅] Table 관리 [μ‹€μŠ΅] DB TABLE 관리


----ISCSI Target/Initiator-------


-------------------------μš©μ–΄ μ •μ˜---------------------------- ● (질문1) κ°œλ³„ iSCSI λŒ€μƒ(target) 및 μ΄λ‹ˆμ‹œμ—μ΄ν„°(initiator)λ₯Ό μ‹λ³„ν•˜κΈ° μœ„ν•œ κ³ μœ ν•œ 이름은 무엇인가? IQN

● (질문2) κ°œλ³„ νŒŒμ΄λ²„ 채널(Fibre Channel) 포트 및 λ…Έλ“œλ₯Ό μ‹λ³„ν•˜κΈ° μœ„ν•œ κ³ μœ ν•œ λ²ˆν˜ΈλŠ” 무엇인가? WWN

● (질문3) iSCSI μ„œλ²„μ˜ μŠ€ν† λ¦¬μ§€ λ¦¬μ†ŒμŠ€λŠ” 무엇인가? νƒ€κ²Ÿ

● (질문4) iSCSI μ„œλ²„μ˜ μŠ€ν† λ¦¬μ§€ λ¦¬μ†ŒμŠ€ 블둝 μž₯μΉ˜λŠ” 무엇인가? LUN

● (질문5) μ†Œν”„νŠΈμ›¨μ–΄ λ˜λŠ” ν•˜λ“œμ›¨μ–΄μ— κ΅¬ν˜„λœ iSCSI ν΄λΌμ΄μ–ΈνŠΈλŠ” 무엇인가? Initiator

● (질문6) 단일 iSCSI μ΄λ‹ˆμ‹œμ—μ΄ν„° λ˜λŠ” λŒ€μƒμ€ 무엇인가? node

● (질문7) μ΄λ‹ˆμ‹œμ—μ΄ν„°μ™€ λŒ€μƒμ˜ 단일 IP μ—°κ²° μ£Όμ†ŒλŠ” 무엇인가? ν¬νƒˆ

ISCSI Target ● νŒ¨ν‚€μ§€: targetcli ● 데λͺ¬ & 포트: iscsid(3260/tcp) ● μ£Όμ„€μ • 파일: /etc/target/saveconfig.json ● μ„œλΈŒ μ„€μ • 파일: /etc/iscsi/initiatorname.iscsi (μ΄λ‹ˆμ‹œμ—μ΄ν„°μ˜ 이름듀) ● μ„œλΉ„μŠ€: target.service

ISCSI Initiator ● νŒ¨ν‚€μ§€: iscsi-initiator-utils ● 데λͺ¬ & 포트: iscsid ● μ£Όμ„€μ • 파일: /etc/iscsi/iscsi.conf ● μ„œλΈŒ μ„€μ • 파일: /etc/iscsi/initiatorname.iscsi (μ΄λ‹ˆμ‹œμ—μ΄ν„°μ˜ 이름듀) ● μ„œλΉ„μŠ€: iscsid.service

**ISCSI Target Configuration

-ISCSI Targe μ„œλ²„ ꡬ성 절차

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install targetcli

2.μ„œλΉ„μŠ€ 기동 #systemctl enable --now targetcli.service 3. μ„œλΉ„μŠ€ ꡬ성 μžμ›μƒμ„± #targetcli >exit 4. λ°©ν™”λ²½ 등둝 # firewall-cmd --permanent --add-service=iscsi-target # fwreload 5. SELinux(?)

**ISCSI Initiator Configuration

-ISCSI Initiator μ„œλ²„ ꡬ성 절차

  1. νŒ¨ν‚€μ§€ μ„€μΉ˜

    yum install iscsi-initiator-utils

2.μ„œλΉ„μŠ€ 기동 # vi /etc/iscsi/initiatorname.iscsi # systemctl enable --now iscsid.service 3. 검색 # iscsiadm -m discovery -t st -p 192.168.10.20 4. 둜그인 # iscsiadm -m node -T IQN -p PORTAL -l 5. μž‘μ—… # lsblk μ λ‹Ήν•œ μž‘μ—… 6. SELinux(?)

-targetcli을 ν†΅ν•œ 마운트 ꡬ성 ꡬ쑰 /dev/sdf νŒŒν‹°μ…˜ νŒŒμΌμ‹œμŠ€ν…œ 마운트

/dev/sdg, /dev/sdh νŒŒν‹°μ…˜ PV->VG->LV νŒŒμΌμ‹œμŠ€ν…œ 마운트

-------μ‰˜μŠ€ν¬λ¦½νŠΈ μ‹€μŠ΅ν™˜κ²½ ꡬ좕----------


---------λ°°μ‹œ μ‰˜ ν”„λ‘œκ·Έλž˜λ°-----------


  1. μ„ μˆ˜ 지식

  2. λͺ…λ Ήμ–΄ grep CMD # grep OPTIONS PARRERNS file1 OPTIONS: -i, -v ,-l , -n, -r, -w PARRERNS: * . ^root root$ [abc] .... sed CMD p cmd) # sed -n '1,3p' /etc/host d cmd) # sed ;'1,3d' /etc/host s cmd) # sed -i '/main/s/192.168.10.10/192.168.10.20/' /etc/host

    awk CMD # awk 'statement {action}' νŒŒμΌμ΄λ¦„ # awk -F: '$3 >= 1000 && $3 <= 60000 {print $1}' /etc/passwd # df -h / | tail -1 | awk '{print $6}' | awk -F% '{print $1}' # ifconfig eth0 | grep inet | grep -v inet6 | awk '{print $2}' | awk -F: '{print $2}' # ps -elf | awk '$2 == "Z" {print $0}' + CMD(cut cmd ...) μ •μ—΄(sort) μ •μ—΄ - μ€‘λ³΅λœκ²ƒμ„ ν•˜λ‚˜λ‘œλ§Œ ν‘œμ‹œ # sort -u file1
    μ •μ—΄ - μ€‘λ³΅λ˜λŠ” κ²ƒλ§Œ ν‘œμ‹œ # sort file1 | uniq -d μ •μ—΄ - μ€‘λ³΅λ˜ μ•ŠλŠ”κ²ƒλ§Œ ν‘œμ‹œ # sort file1 | uniq -u

    cut λͺ…λ Ήμ–΄ - ν•„λ“œλ₯Ό μž˜λΌλ‚΄λŠ” μ—­ν• λ‘œ 많이 μ‚¬μš© # cut -c1-5 /etc/hosts - λ¬Έμ„œ 각 μ€„μ˜ μ•ž 1~5자리만 ν‘œν˜„ # cat /etc/hosts | tr '[a-z]' '[A-Z]' γ„΄ μ†Œλ¬Έμžλ₯Ό λŒ€λ¬Έμžλ‘œ λ°”κΏ”μ„œ 좜λ ₯ # cat /etc/hosts | egrep -v '(^$|^#)' | cut -f 1 # cut -d ":" -f 1 /etc/passwd (# awk -F: '{print $1}' /etc/passwd) # ifconfig eth0 | grep 'inet addr:' | awk '{print $2}' | cut -d":" -f2

    paste λͺ…λ Ήμ–΄ - λ‹€μˆ˜μ˜ νŒŒμΌμ„ ν•œλ²ˆμ— λ³Όλ•Œ μ˜†μœΌλ‘œ μ •λ ¬ν•΄μ„œ 좜λ ₯ # paste file1 file2

    wc λͺ…λ Ήμ–΄ # wc /etc/passwd

  3. μ‰˜μ˜ νŠΉμ„± ● λ¦¬λ‹€μ΄λ ‰μ…˜(Redirection) : < << > >> 2> 2>> # cat < /etc/passwd - λ‚΄μš©μ„ 좜λ ₯ # cat > file1 - 파일의 λ‚΄μš©μ„ 직접 μž…λ ₯ν•˜μ—¬ 생성 (λ§ˆμ§€λ§‰ ctl+d)

    ● νŒŒμ΄ν”„(pipe) : | νŒŒμ΄ν”„ λͺ…λ Ήμ–΄ ν˜•μ‹ # CMD | more # CMD | grep rsyslogd # CMD | CMD ● μ…€ 자체의 κΈ°λŠ₯(bash function) : set -o vi ● λ³€μˆ˜(Variable) : export VAR=5 λ³€μˆ˜μ˜ μ’…λ₯˜ - μ§€μ—­λ³€μˆ˜(# VAR=5) - ν™˜κ²½λ³€μˆ˜(# export VAR=5) - νŠΉμˆ˜λ³€μˆ˜($$, $?, $!, $*, $1, $2, ....)

     λ³€μˆ˜ μ„ μ–Έ 방법(env/set)
     (μ„ μ–Έ) # VAR=5     (# export VAR=hello)
     	 # export VAR 
     (확인) # echo $VAR (# printf $VAR)
     	
     $$ : ν˜„μž¬ μ‰˜μ˜ PID 번호 μ €μž₯(EX: μž„μ‹œ 파일 생성, /tmp/.tmp.$$)
     $! : λ°”λ‘œ 이전 μˆ˜ν–‰λœ λ°±κ·ΈλΌμš΄λ“œ ν”„λ‘œμ„ΈμŠ€μ˜ PID 번호 μ €μž₯
     $? : λ°”λ‘œ 이전 μˆ˜ν–‰λœ λͺ…λ Ήμ–΄μ˜ return value μ €μž₯(0 ~ 255)
     $* : λͺ¨λ“  인자($* == $@)
     $# : 인자의 개수
     $0 : ν”„λ‘œκ·Έλž¨ 이름
     $1 : ν”„λ‘œκ·Έλž¨μ— λŒ€ν•œ 첫번째 인자
     $2 : ν”„λ‘œκ·Έλž¨μ— λŒ€ν•œ λ‘λ²ˆμ§Έ 인자
     $3 : ν”„λ‘œκ·Έλž¨μ— λŒ€ν•œ μ„Έλ²ˆμ§Έ 인자
     	(ν•΄μ œ) # unset VAR 
    

    ● ν•¨μˆ˜ - alias와 같이 μ„ μ–Έν•˜μ—¬ λͺ…λ Ήμ–΄ 처럼 μ‚¬μš©ν•¨! (μ„ μ–Έ) # a() { ls; date; cal; } or function a { ls; date; cal; } (μ‹€ν–‰) # a (확인) # typeset -f (ν•΄μ œ) # unset -f a [μ°Έκ³ ] CMD -> alias -> function -> script ● κ·Έλ£Ήν™”(Grouping) ( ls ; pwd ; date ) > outputfile ● 쑰건 μ—°μ‚°μž ( && , || ) ● 메타캐릭터(Metacharacter) : '' "" `` ; ● νžˆμŠ€ν† λ¦¬(History) : history ● ν™˜κ²½νŒŒμΌ(Environment Files) : /etc/profile, ~/.bash_profile, ~/.bashrc

  4. μ‰˜ 슀크립트 μž‘μ„±

    1. ν”„λ‘œκ·Έλž¨ μž‘μ„±κ³Ό μ‹€ν–‰

      bash -x script.sh

      . ~/.bashrc

      vi script.sh ' chmod +x script.sh ; ./script.sh

    2. 주석관리

      • ν•œμ€„ 처리 - #
      • μ—¬λŸ¬ 쀄 처리 - : << EOF ~ EOF
    3. μž…λ ₯κ³Ό 좜λ ₯ 좜λ ₯ : echo CMD, printf CMD μž…λ ₯ : read CMD

#!/bin/bash

#svc.sh start sshd

-> systemctl enable sshd

-> systemctl restart sshd

-> systemctl status sshd

#svc.sh stop sshd

-> systemctl disable sshd

-> systemctl stop sshd

-> systemctl status sshd

-------------continueλ₯Ό μ‚¬μš©ν•˜μ—¬ 문제λ₯Ό ν™•μΈν•˜λŠ” 예제----------------

#!/bin/bash

egrep -i '(warn|fail|error|crit|alert|emerg)' /var/log/messages > /tmp/.tmp1 γ„΄ μ•ˆμ’‹μ€ 단어λ₯Ό 검색함 (30초 μ „ 파일)

while true - μ°ΈμΌλ•Œ do sleep 30 - 30초 쉬고 egrep -i '(warn|fail|error|crit|alert|emerg)' /var/log/messages > /tmp/.tmp2 γ„΄ 30초 뒀에 νŒŒμΌμ„ λ‹€μ‹œ κ²€μ‚¬ν•˜μ—¬ tmp1 κ³Ό 2의 차이점을 비ꡐ함 diff /tmp/.tmp1 /tmp/.tmp2 > /tmp/.tmp3 && continue γ„΄ 결과값이 μ €μž₯된 tmp νŒŒμΌλ“€μ„ μ„œλ‘œ 비ꡐ해 κ°™μœΌλ©΄ continue! mailx -s "[WARN] Log Mail Check" root < /tmp/.tmp3 γ„΄ 결과값이 달라 μ•„λž˜λ‘œ λ‚΄λ €μ™€μ„œ κ΄€λ¦¬μžμ—κ²Œ 메일을 λ³΄λ‚΄κ²Œ 함 egrep -i '(warn|error|crit|alert|emerg)' /var/log/messages > /tmp/.tmp1 γ„΄ λ‹€μ‹œ λ°˜λ³΅ν•΄μ„œ κ²€μ‚¬ν•˜μ—¬ λ‚΄μš©μ„ tmp1에 λ„£μŒ done

(κΈ°λŠ₯) λͺ©μ : 둜그 νŒŒμΌμ„ λͺ¨λ‹ˆν„°λ§ ν•˜λŠ” ν”„λ‘œκ·Έλž¨ μž‘μ„± κΈ°λŠ₯: ● 둜그 파일의 μΆ”κ°€λœ λ‚΄μš©μ„ 확인 ● 둜그 파일의 μΆ”κ°€λœ λ‚΄μš©μ΄ μ‘΄μž¬ν•œλ‹€λ©΄ λ©”μΌλ‘œ 전솑(To: root) ● 이 ν”„λ‘œκ·Έλž¨μ€ μ’…λ£Œλ˜λ©΄ μ•ˆλœλ‹€.(EX: Daemon) ● μ‚¬μš©ν•˜λŠ” λͺ…λ Ήμ–΄: egrep -i '(warn|fail|err|crit|alert|emerg)' /var/log/messages ● 30μ΄ˆμ— ν•œλ²ˆμ”© 둜그 파일의 λ‚΄μš©μ— μΆ”κ°€λœ λ‚΄μš©μ„ ν™•μΈν•œλ‹€.

  • diff λͺ…λ Ήμ–΄ μ‚¬μš©: diff file1 file2 = 파일1κ³Ό 파일2의 차이점 비ꡐ

---------------FTP μ‚¬μš© 예제------------------------ #!/bin/bash HELP(){ cat << EOF Commands may be abbreviated. Commands are:

! debug mdir sendport site $ dir mget put size account disconnect mkdir pwd status append exit mls quit struct EOF }

ERROR(){ [ "$CMD" ] && echo "[WARN]Invalid command" }

while true do echo -n "ftp> " read CMD case $CMD in 'quit'|'bye') break ;; 'help') HELP ;; *) ERROR ;; esac

*) IO λ¦¬λ‹€μ΄λ ‰μ…˜ μžμ‹ ν”„λ‘œμ„ΈμŠ€ for LINE in $(cat file1) do echo $LINE done > file2 ----방법2(ꢌμž₯)--- cat file1 | while read LINE do echo $LINE done > file2

*) μ‹œκ·Έλ„ μ œμ–΄ *μ‹œκ·Έλ„λ¬΄μ‹œ *μ‹œκ·Έλ„ λ°›μœΌλ©΄ κ°œλ°œμžκ°€ μ›ν•˜λŠ” λ™μž‘

*) 디버깅 * bash -x script.sh * bash -xv script.sh *) μ˜΅μ…˜ 처리 getopts CMD + while CMD + case CMD (예) # ssh.sh -p 80 192.168.10.20 while getopts p: options do case $options in p ) P_ACTION ;; ?) Usage ;; * ) Usage ;; esac done

-----------μ„œλ²„ 체크 파일-------------------- #!/bin/bash

# ./check_service.sh 192.168.10.10 192.168.10.20

------------------

192.168.10.10

------------------

svc1 active

svc2 active

------------------

192.168.10.20

------------------

svc3 active

svc4 active

....

if [ $# -ne 2 ] ; then echo "Usage: $0 " exit 1 fi export FIRST_IP=$1 export SECOND_IP=$2 export BASEDIR=/root/bin

ServiceList() {

input: str # ServiceList main

output: file # ServiceList main -> main.txt

functions:

SERVER=$1
ssh $SERVER systemctl -t service | sed -n '1,/^LOAD/p'
| sed '$d'
| awk '{print $1, $3}' > $BASEDIR/$SERVER.txt }

ServiceList $FIRST_IP ServiceList $SECOND_IP

FSERVER=$BASEDIR/$FIRST_IP.txt SSERVER=$BASEDIR/$SECOND_IP.txt

cat << EOF ############################## "$FIRST_IP" ############################## $(diff $FSERVER $SSERVER | fgrep '<' | cut -c3-)

############################## "$SECOND_IP" ############################## $(diff $FSERVER $SSERVER | fgrep '>' | cut -c3-)

EOF

----vscode μžλ™μœΌλ‘œ μΌœμ§€λ„λ‘ μ„€μ •------

  • crontab + vskill.sh

kill $(ps -ef | grep -w code
| grep -v 'grep --color'
| awk '{print $2}'
| sort
| head -1)

fdisk -l | grep LVM | awk '{print $1}' > pv1.txt pvs | tail -n +2 | awk '{print $1}' > pv2.txt

ENV1.sh : ν™˜κ²½μ„€μ • * $HOME/.bashrc ENV2.sh : ν•„μš”ν•œ νŒ¨ν‚€μ§€ μ„€μΉ˜ * νŒ¨ν‚€μ§€ μ„€μΉ˜ (gcc, php, vscode) ENV3.sh : μ„œλ²„ μ„ΈνŒ… ν…”λ„· μ„œλ²„ - telnet-server ftp μ„œλ²„ - vsftpd ftp ssh μ„œλ²„ - openssh-server openssh-clients openssh-clients nginx μ›Ή μ„œλ²„ - yum -y install nginx echo "Nginx webserver > /usr/share/nginx/html/index.html systemctl enable --now nginx.server

cat << EOF > /etc/yum.repos.d/vscode.repo [code] name=Visual Studio Code baseurl=https://packages.microsoft.com/yumrepos/vscode enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" EOF

yum install code sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo' yum install code

https://www.google.co.kr/chrome/thank-you.html?brand=YTUH&statcb=0&installdataindex=empty&defaultbrowser=0#

wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm -O /root/bin/

yum localinstall google-chrome-stable_current_x86_64

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors