๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • Welcome.

:: Linux ๐Ÿšฉ29

[๋ฆฌ๋ˆ…์Šค] [AWK ๋ช…๋ น์–ด] : echo -e 'no\ttitle\n1\tsubject1' | awk '{ print }' # action ์„ ์ƒ๋žตํ•˜๋ฉด ๊ธฐ๋ณธ ์•ก์…˜์ธ print ๊ฐ€ ์‹คํ–‰ ๋จ => echo -e 'no\ttitle\n1\tsubject1' | awk '/sub/' # ์ง€์ •๋œ ๋ฌธ์ž์—ด์„ ํฌํ•จํ•˜๋Š” ๋ ˆ์ฝ”๋“œ๋งŒ ์ถœ๋ ฅ echo -e 'no\ttitle\n1\tsubject1' | awk '/sub/ { print }' # ํŒŒ์ผ์˜ ์ „์ฒด ๋‚ด์šฉ ์ถœ๋ ฅ echo -e "a b c\nd e f" | awk '{ print }' # ํ•„๋“œ ๊ฐ’ ์ถœ๋ ฅ echo -e "a b c\nd e f" | awk '{ print $1 }' # ํ•„๋“œ ๊ฐ’์— ์ž„์˜ ๋ฌธ์ž์—ด์„ ๊ฐ™์ด ์ถœ๋ ฅ echo -e "a b c\nd e f" | awk '{print "FIRST : .. 2021. 5. 27.
[๋ฆฌ๋ˆ…์Šค] [์นผ๋ฆฌ ๋ฆฌ๋ˆ…์Šค(KALI LINUX)] # password ์„ค์ • sudo passwd su # ์žฌ๋ถ€ํŒ… ํ—ˆ์šฉ ์ฐฝ์ด ๋‚˜์˜ฌ๊ฒฝ์šฐ YES ํด๋ฆญ apt-get update && apt-get upgrade -y # ํ•œ๊ธ€ ํฐํŠธ ์„ค์น˜ apt-get install -y fcitx-lib* apt-get install -y fcitx hangul* apt-get install -y fonts-nanum* reboot service postgresql start #db ์ดˆ๊ธฐํ™” msfdb init msfconsole # ํ•ด๋‹น ip์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์„œ๋น„์Šค ์ถœ๋ ฅ nmap 192.168.108.134 # ํ•ด๋‹น ip์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์„œ๋น„์Šค ์ž์„ธํžˆ ์ถœ๋ ฅ nmap -sV 192.168.108.134 # msfadmin / msfadmin ftp 192.168.108.134 cd /.. 2021. 5. 26.
[๋ฆฌ๋ˆ…์Šค] [Raid 1] # raid 1 ์ƒ์„ฑ mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdd1 /dev/sde1 # yes y # Resync Status ๊ฐ€ 100% ๊ฐ€ ๋ ๋•Œ๊นŒ์ง€ ๋Œ€๊ธฐ mdadm --detail /dev/md1 # ์ž˜ ์ƒ์„ฑ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ cat /proc/mdstat # ํฌ๋ฉงํŒ… mkfs.ext4 /dev/md1 # mount ํ•  ํด๋” ์ƒ์„ฑ mkdir /data2 # raid 1 ๋””์Šคํฌ mount mount /dev/md1 /data2 # ๋งˆ์šดํŠธ ๋‚ด์šฉ ํ™•์ธ df -Th #lost+found ๊ฐ€ ์žˆ๋Š”๊ฒƒ์œผ๋กœ mount๊ฐ€ ๋˜์–ด์žˆ๋‹ค๋Š” ๊ฒƒ์„ ํ™•์ธ. cd /data2 # ํŒŒ์ผ ์ฝ๊ณ  ์“ฐ๊ธฐ ์ž˜ ๋˜๋Š”๊ฒƒ ํ™•์ธ touch aa;ls;rm -rf aa;ls; 2021. 5. 19.
[๋ฆฌ๋ˆ…์Šค] [Raid 0] : Hard Disk -> SCSI -> # Create a new virtual disk -> 10GB(Store vitual disk as a single file # ์ฒซ ๋ฒˆ์งธ 10GB ์™ธ 5GB # ์„œ๋ฒ„์šฉ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” SCSI ๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ตฌ์„ฑ # ํ˜„์žฌ ๋””์Šคํฌ ๋ฐ ํŒŒํ‹ฐ์…˜ ๋ณด๊ธฐ ๋ช…๋ น์–ด fdisk -l # ํ•˜๋“œ๋””์Šคํฌ ์ง€์ •ํ•˜์—ฌ ๋ณด๊ธฐ fdisk -l /dev/sda # ls ๋ฅผ ํ†ตํ•ด ๋ณด๊ธฐ ls -la /dev/sd* # ํ•˜๋“œ๋””์Šคํฌ ์„ค์ • fdisk /dev/sdb # ํŒŒํ‹ฐ์…˜ ํ™•์ธ(์ฒ˜์Œ์—” ์•„๋ฌด๊ฒƒ๋„ ์—†์–ด์•ผ ํ•จ) p # ํŒŒํ‹ฐ์…˜ ์ƒ์„ฑ n # ์ฃผ ํŒŒํ‹ฐ์…˜์œผ๋กœ ์ƒ์„ฑ p # ํŒŒํ‹ฐ์…˜ ๋ฒˆํ˜ธ ์ง€์ •(๊ทธ๋ƒฅ ์—”ํ„ฐ์‹œ 1๋กœ ๋จ) 1 # ์„นํ„ฐ ํฌ๊ธฐ ์ง€์ •(๊ทธ๋ƒฅ ์—”ํ„ฐํ•˜๋ฉด 2048) # ์„นํ„ฐ๋ž€ ํŒŒ์ผ์ด ์ €์žฅ๋  ์ˆ˜ ์žˆ๋Š” ์ตœ์†Œ ํฌ๊ธฐ(ํ•˜๋‚˜์˜ ์„นํ„ฐ์— .. 2021. 5. 19.
[๋ฆฌ๋ˆ…์Šค] [at , cron] #1. at # ntp ์„œ๋ฒ„ ์ค‘์ง€ systemctl stop ntpd systemctl stop chronyd yum -y install at # at ์‹คํ–‰ /usr/sbin/atd # at ์‹คํ–‰ 2 systemctl restart atd # at ์„œ๋น„์Šค ํ™•์ธ ps -ef | at # ์˜ˆ์•ฝ์ž‘์—… ํ™•์ธ at -l # ์˜ˆ์•ฝ์ž‘์—… ํ™•์ธ 2 atq # ์‹œ๊ฐ„ ๋ณ€๊ฒฝ date -s '2021-05-16 14:10' # at HH:mm MMddyyyy at 14:11 05162021 #> touch /tmp/at #> [ Ctrl + D ] ๋กœ ๋น ์ ธ๋‚˜๊ฐˆ ์ˆ˜ ์žˆ๋‹ค. # job ํ™•์ธ at -l # job ์‚ญ์ œ at -d [job ๋ฒˆํ˜ธ] watch -n 1 ls -ld /tmp/at echo "touch /tmp/at" | a.. 2021. 5. 18.
[๋ฆฌ๋ˆ…์Šค] [6์ผ์ฐจ] [์…ธ ์Šคํฌ๋ฆฝํŠธ - etc / ๋‚˜๋จธ์ง€ ์…ธ๋“ค.] ใ…กใ…กใ…กใ…กใ…ก #!/bin/bash var1=100.5 var2="funny linux" printf "%5.2f \n\n \t %s \n" $var1 "$var2" ใ…กใ…กใ…กใ…กใ…ก 2021. 5. 7.
[๋ฆฌ๋ˆ…์Šค] [6์ผ์ฐจ] [์…ธ ์Šคํฌ๋ฆฝํŠธ - ํ•จ์ˆ˜] ใ…กใ…กใ…กใ…กใ…ก #!/bin/bash myfunction () { echo "this is my function" return } myfunction ใ…กใ…กใ…กใ…กใ…ก ใ…กใ…กใ…กใ…กใ…ก #!/bin/bash myfunction () { echo "this is my function" return } myfunction myfunction myfunction ใ…กใ…กใ…กใ…กใ…ก 2021. 5. 7.
[๋ฆฌ๋ˆ…์Šค] [์…ธ ์Šคํฌ๋ฆฝํŠธ] [while ๋ฌธ] vi while.sh : while.sh ์ƒ์„ฑ ํ›„ vi์—๋””ํ„ฐ๋กœ ์ˆ˜์ •. ใ…กใ…กใ…กใ…กใ…กwhile.sh ๋‚ด์šฉใ…กใ…กใ…ก #!/bin/bash while [ true ] # ๋ฌดํ•œ๋ฃจํ”„ ์ƒ์„ฑ. do echo helo # helo์ถœ๋ ฅ sleep 1 # 1์ดˆ ๋™์•ˆ ์ง€์—ฐ. done ใ…กใ…กใ…กใ…กใ…ก chmod 755 while.sh : while.sh ์— ๊ถŒํ•œ 755๋ถ€์—ฌ. cat while.sh : while.sh ์ฝ๊ธฐ. ./while.sh : ํ˜„์žฌ ํด๋”์— ์žˆ๋Š” while.sh์‹คํ–‰. ls | while read result # ls์˜ ์ถœ๋ ฅ ๊ฐ’์„ result ๋กœ. (ํŒŒ์ดํ”„ ์‚ฌ์šฉ.) do echo $result # result ์ถœ๋ ฅ. done 2021. 5. 7.
[๋ฆฌ๋ˆ…์Šค1] [6์ผ์ฐจ] [ #03 ์…ธ์Šคํฌ๋ฆฝํŠธ for๋ฌธ ] vi for.sh : for.sh ์ƒ์„ฑ ํ›„ vi ์—๋””ํ„ฐ๋กœ ์ˆ˜์ •. chmod 755 for.sh : for.sh ์— ๊ถŒํ•œ 755 ๋ถ€์—ฌ. ./for.sh : ํ˜„์žฌ ํด๋”์— ์žˆ๋Š” for.sh ์‹คํ–‰. cat for.sh : for.sh ์ฝ๊ธฐ. ใ…กใ…กใ…กใ…กใ…กfor.sh ๋‚ด์šฉ ใ…กใ…กใ…ก #!/bin/bash for var in 1 2 3 4 5 #๋ณ€์ˆ˜ var ๊ฐ€ 1, 2, 3, 4, 5์ธ ๋™์•ˆ ์ข…์†๋œ ๋ฌธ์žฅ ์‹คํ–‰. #var์€ ๊ทธ๋ƒฅ ๋ณ€์ˆ˜๋ช…. do echo $var done ใ…กใ…กใ…กใ…กใ…ก ์œ„์ฒ˜๋Ÿผ list ๋ฅผ ์ •์˜ํ•ด์ฃผ๊ณ  for๋ฌธ์„ ํ†ตํ•ด ๊ฐ™์€ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•  ์ˆ˜ ๋„ ์žˆ๋‹ค. ใ…กใ…กใ…กใ…กใ…กfor.sh๋‚ด์šฉใ…กใ…กใ…ก #!/bin/bash list="1 2 3 4 5" #list ์ •์˜ for var in $list do echo $var done ใ…กใ…กใ…ก.. 2021. 5. 3.
[๋ฆฌ๋ˆ…์Šค1] [6์ผ์ฐจ] [ #02 ์…ธ์Šคํฌ๋ฆฝํŠธ case๋ฌธ ] ์…ธ์Šคํฌ๋ฆฝํŠธ #02 case ๋ฌธ - ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๊ฒฝ์šฐ์˜ ์ˆ˜๊ฐ€ ์žˆ๋‹ค๋ฉด case ๋ฌธ - c์–ธ์–ด์˜ switch ๋ฌธ๊ณผ ๋น„์Šทํ•˜๋‹ค. ใ…กใ…กใ…กใ…กใ…ก 01 #!/bin/bash 02 case "$1" in 03 start) 04 echo "์‹œ์ž‘~~";; 05 stop) 06 echo "์ค‘์ง€~~";; 07 restart) 08 echo "๋‹ค์‹œ ์‹œ์ž‘~~";; 09 *) 10 echo ๏ผ‚๋ช…๋ น์–ด๊ฐ€ ํ‹€๋ ธ์Šต๋‹ˆ๋‹ค.";; # ์œ„ ๊ฒฝ์šฐ ์ค‘ ํ•ด๋‹นํ•˜๋Š” ๊ฒƒ์ด ์—†๋Š” ๊ฒฝ์šฐ. 11 esac ใ…กใ…กใ…กใ…กใ…ก vi case.sh : case.sh ์ƒ์„ฑ ํ›„ vi ์—๋””ํ„ฐ๋กœ ์ˆ˜์ •. case.sh ๋‚ด์šฉ : ใ…กใ…กใ…กใ…กใ…ก #!/bin/bash echo "Linux is fun? (yes/no)" #๋ฌธ์žฅ ์ถœ๋ ฅ. read answer # ์ž…๋ ฅ๋ฐ›์€ ๊ฐ’์„ answer์— ์ถœ๋ ฅ. c.. 2021. 5. 3.
[๋ฆฌ๋ˆ…์Šค1] [6์ผ์ฐจ] [#01 ์…ธ ์Šคํฌ๋ฆฝํŠธ - if๋ฌธ] #1 ์…ธ ์Šคํฌ๋ฆฝํŠธ ๋จผ์ €, ์…ธ ์Šคํฌ๋ฆฝํŠธ๋Š” ๊ทธ ๋‚ด์šฉ์˜ ์ฒซ์ค„์ด #!/bin/bash ๋กœ ์‹œ์ž‘๋˜๋Š” ๊ฒƒ์ด ์›์น™์ด๋‹ค. if ๋ฌธ if.sh ๋‚ด์šฉ : ใ…กใ…กใ…กใ…กใ…ก #!/bin/bash if [ -d $1 ] then echo this is folder else echo this is not folder fi ใ…กใ…กใ…กใ…กใ…ก vi if.sh : sh ํ˜•์‹์ด๊ณ  ํŒŒ์ผ์ด๋ฆ„์ด if ์ธ ํŒŒ์ผ ์ƒ์„ฑ ํ›„, ๋‚ด์šฉ์„ vi ์—๋””ํ„ฐ๋กœ ์ž…๋ ฅํ•˜๋Š” ์ƒํƒœ๋กœ ์ด๋™. cd /app/ws/script : /app/ws/script ์œ„์น˜๋กœ ์ด๋™. vi if.sh : if.sh ์ด๋ผ๋Š” ์…ธ ์Šคํฌ์ž…ํŠธ ์ƒ์„ฑ ํ›„ vi ์—๋””ํ„ฐ๋กœ ์ˆ˜์ •. chmod 755 if.sh : 755 ๊ถŒํ•œ ๋ถ€์—ฌ. ls -al : ํ˜„์žฌ ํด๋”์—์„œ ๋ชจ๋“  ํŒŒ์ผ์„ ๋ฆฌ์ŠคํŠธํ˜•์‹์œผ๋กœ ํ™•์ธ. ./if.sh : i.. 2021. 5. 3.
[๋ฆฌ๋ˆ…์Šค1] [bandit์˜ˆ์ œ] #bandit1 ํŒจ์Šค์›Œ๋“œ๋Š” home ๋””๋ ‰ํ† ๋ฆฌ์— - ๋ผ๋Š” ํŒŒ์ผ์— ์ €์žฅ๋˜์–ด์žˆ๋‹ค. pwd # ํ˜„์žฌ ๊ฒฝ๋กœ ํ™•์ธ ls -al # ํ˜„์žฌ ์œ„์น˜์—์„œ ๋ชจ๋“  ํŒŒ์ผ๋“ค์„ ๋ฆฌ์ŠคํŠธํ˜•์‹์œผ๋กœ ํ™•์ธ cat - # - ๋ผ๋Š” ํŒŒ์ผ์„ ์ฝ์œผ๋ ค๊ณ  ํ–ˆ์œผ๋‚˜ ์ฝ์–ด์ง€์ง€ ์•Š์•„์„œ crtl + c ๋กœ ๊ฐ•์ œ ์ข…๋ฃŒ. cat /home/bandit1/- # ์ด์ฒ˜๋Ÿผ - ํŒŒ์ผ์€ ๋ชจ๋“  ๊ฒฝ๋กœ๋ฅผ ์ ์–ด์ค˜์•ผ ์ฝ์„ ์ˆ˜ ์žˆ๋‹ค. (์ ˆ๋Œ€ ๊ฒฝ๋กœ ์‚ฌ์šฉ) cat ./- # ์ƒ๋Œ€ ๊ฒฝ๋กœ ์‚ฌ์šฉ - ์™€ ๊ฐ™์€ ํŒŒ์ผ์€ ์™œ ๊ฒฝ๋กœ๋ฅผ ํ‘œ์‹œํ•˜์—ฌ ์ฝ์–ด์ค˜์•ผํ•˜๋Š”์ง€๋Š” ๋‹ค์Œ์— ์•Œ์•„๋ณด์ž. ๋”ฐ๋ผ์„œ level1 -> level2 password : CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9 2021. 4. 27.
[๋ฆฌ๋ˆ…์Šค1] 5์ผ์ฐจ [grep, -E ์˜ต์…˜, ์˜ต์…˜๋“ค] # grep ๋ฌธ์ž '\-.,' ์— ๋Œ€ํ•œ ํ•˜์ด๋ผ์ดํŒ…์ด ํ‘œ์‹œ๋˜์ง€ ์•Š์Œ grep --help | grep -E '\-.,' | head -10 # grep ์„ always๋กœ ์„ค์ • alias grep='grep --color=always' # grep --help | grep -E '\-.,' | head -10 # -E ์˜ต์…˜ # grep ๋Œ€์ƒ ๋ฌธ์ž์—ด์ด ์ •๊ทœํ‘œํ˜„์‹์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ # ์ •๊ทœ์‹ # ^ : ํ–‰์˜ ์‹œ์ž‘ ์ง€์‹œ์ž => '^test' : test๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋ชจ๋“  ํ–‰๊ณผ ๋Œ€์‘ํ•จ. # $ : ํ–‰์˜ ๋ ์ง€์‹œ์ž => 'test$' : test๋กœ ๋๋‚˜๋Š” ๋ชจ๋“  ํ–‰๊ณผ ๋Œ€์‘ํ•จ. # . : ํ•˜๋‚˜์˜ ๋ฌธ์ž์™€ ๋Œ€์‘ => 't.s.' : ์ด 4๊ฐœ์˜ ๋ฌธ์ž๋กœ ์ด๋ฃจ์–ด์ง„ ๋ฌธ์ž์—ด์„ ๊ฒ€์ƒ‰ํ•˜๋Š” ๋ฐ, ์ฒซ ๋ฒˆ์งธ๋Š” 't' ์„ธ ๋ฒˆ์งธ๋Š” 's'์ธ .. 2021. 4. 27.
[๋ฆฌ๋ˆ…์Šค1] 5์ผ์ฐจ ์ฐธ๊ณ  ํŒŒ์ผ 2021. 4. 26.
[๋ฆฌ๋ˆ…์Šค1] 4์ผ์ฐจ ์ฐธ๊ณ  ํŒŒ์ผ :: Sublime Text ์„ค์น˜ :: Preferences -> Color Scheme... -> Celeste ์„ ํƒ :: [ Ctrl + Shift + P ] -> [ Package Control: Install Package ] -> :: -> [ IMESupport ] ํด๋ฆญ :: [ Ctrl + [+] ] ๋กœ ์‚ฌ์ด์ฆˆ ์—… :: ConEmu ์„ค์น˜ :: ์„ค์น˜ํ›„ ๋ฐ”๋กœ๊ฐ€๊ธฐ ์ƒ์„ฑ ํ›„ C:\App\Run\ ํด๋” ์ด๋™ :: ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ๋“ฑ๋ก ํ›„ ์ด๋ฆ„์„ cmd2๋กœ ๋ณ€๊ฒฝ :: VirtualBox ์„ค์น˜ :: Docker Tool Box๋Š” Vista ์ด์ „ ๋ฒ„์ „์—์„œ ์ง€์›ํ•˜๋Š” NDIS5๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— :: VirtualBox ๋„ ๋งž์ถ”์–ด ์„ค์น˜ํ•˜์—ฌ ์ฃผ์–ด์•ผ ํ•œ๋‹ค. :: NDIS : [ Network Driver Interfa.. 2021. 4. 26.
728x90