Unit7 - [Linux/Git] ๊ธฐ์ดˆ

๊ฐ•์„ฑ์ผยท2023๋…„ 4์›” 24์ผ
0
post-thumbnail

โœ… TIL


์˜ค๋Š˜ ๋ฐฐ์šด ๊ฒƒ์„ ํ‚ค์›Œ๋“œ๋กœ ๋‚˜์—ดํ•˜์ž๋ฉด,

CLI, brew, node, nvm, npm, nano, git ์ •๋„๊ฐ€ ๋˜๊ฒ ๋‹ค.

ํ•˜๋‚˜์”ฉ ์ฐจ๊ทผ์ฐจ๊ทผ ๊ฐœ๋… ์ •๋ฆฌ๋ฅผ ํ•˜๊ฒ ๋‹ค.


โš™๏ธ CLI


GUI : Graphic User Interface
CLI : Command-Line Interface (Terminal)

CLI๋Š” ๋Œ€๋Ÿ‰์˜ ์ปดํ“จํ„ฐ๊ฐ€ ์žˆ๋Š” ํ™˜๊ฒฝ์—์„œ ์œ ๋ฆฌํ•˜๋‹ค.

GUI๋Š” I/O ์†Œ์Šค(ํ‚ค๋ณด๋“œ, ๋งˆ์šฐ์Šค, ๋ชจ๋‹ˆํ„ฐ)๊ฐ€ ํ•„์š”ํ•œ๋ฐ, ์ด๋ฅผ ์ˆ˜๋งŽ์€ ์ปดํ“จํ„ฐ์— ์ผ์ผ์ด ๋ถ€์ฐฉํ•˜๊ธฐ ํž˜๋“ค๋‹ค.

CLI๋ฅผ ์ด์šฉํ•ด ์„œ๋ฒ„ ์ปดํ“จํ„ฐ๋กœ ์ ‘์†์„ ์š”์ฒญํ•˜๋ฉด, ์„œ๋ฒ„ ์ปดํ“จํ„ฐ๋Š” ์š”์ฒญํ•œ ์ปดํ“จํ„ฐ์˜ ์ถœ๋ ฅ์†Œ์Šค(๋ชจ๋‹ˆํ„ฐ)๋ฅผ ์ด์šฉ
-> ์„œ๋ฒ„ ์ปดํ“จํ„ฐ๋กœ ์ง์ ‘ ์ฐพ์•„๊ฐˆ ํ•„์š”์—†์ด, ์ž์‹ ์˜ ๋ชจ๋‹ˆํ„ฐ๋กœ ์„œ๋ฒ„ ์ปดํ“จํ„ฐ์™€ ์†Œํ†ต

๋Œ€ํ‘œ์ ์œผ๋กœ ์•„๋งˆ์กด ์›น ์„œ๋น„์Šค(AWS, Amazon Web Service) ์˜ ํด๋ผ์šฐ๋“œ ์ปดํ“จํŒ…์ฒ˜๋Ÿผ,
๋Œ€๋Ÿ‰์˜ ์„œ๋ฒ„ ์ปดํ“จํ„ฐ๋ฅผ ์„ค์น˜ํ•ด์•ผ ํ•˜๋Š” ์„œ๋น„์Šค๊ฐ€ ์˜ˆ์‹œ์ด๋‹ค.

AWS๋Š” 4์ฒœ ํ‰์ด ๋„˜๋Š” ๊ทœ๋ชจ์˜ ๋ฐ์ดํ„ฐ ์„ผํ„ฐ๋ฅผ 29๊ฐœ ์ด์ƒ ๊ฐ€์ง€๊ณ  ์žˆ๊ณ , ๊ณ„์†ํ•ด์„œ ํ™•์žฅํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
ํ•˜๋‚˜์˜ ๋ฐ์ดํ„ฐ ์„ผํ„ฐ์—๋Š” ์ตœ์†Œ 5๋งŒ ๊ฐœ ์ด์ƒ์˜ ์„œ๋ฒ„ ์ปดํ“จํ„ฐ๊ฐ€ ์„ค์น˜๋ฉ๋‹ˆ๋‹ค.

๋Œ€๋ถ€๋ถ„์˜ ์„œ๋ฒ„ ์ปดํ“จํ„ฐ๋Š” ๋ฌด๋ฃŒ๋กœ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋Š” Linux ์šด์˜์ฒด์ œ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.


Linux CLI Commands


prompt : ํ„ฐ๋ฏธ๋„์—์„œ ํŽธ์ง‘ํ•˜๋Š” ํ•œ ์ค„์˜ ๊ณต๊ฐ„
pwd: print working directory - ํ˜„์žฌ ์œ„์น˜ ํ™•์ธํ•˜๊ธฐ
mkdir: make directory - ์ƒˆ๋กœ์šด ํด๋” ์ƒ์„ฑํ•˜๊ธฐ
ls: list - ํŠน์ • ํด๋”์— ํฌํ•จ๋œ ํŒŒ์ผ์ด๋‚˜ ํด๋” ํ™•์ธํ•˜๊ธฐ

  • -l: ํฌ๋งท๊นŒ์ง€ ์ถœ๋ ฅ
  • a: ์ˆจ๊ฒจ์ ธ ์žˆ๋Š” ํŒŒ์ผ/ํด๋”๊นŒ์ง€ ์ถœ๋ ฅ

open(macOS): open current folder with finder
cd: change directory - ํด๋”์— ์ง„์ž…ํ•˜๊ธฐ
touch: create new file - ํŒŒ์ผ ์ƒ์„ฑํ•˜๊ธฐ
cat: display contents of a file - ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ํ„ฐ๋ฏธ๋„์— ์ถœ๋ ฅํ•˜๊ธฐ
rm, rf: remove, recursive - ํด๋”๋‚˜ ํŒŒ์ผ ์‚ญ์ œํ•˜๊ธฐ
mv: move - ํด๋”๋‚˜ ํŒŒ์ผ์˜ ์ด๋ฆ„์„ ๋ณ€๊ฒฝ, ๋˜๋Š” ํด๋”๋‚˜ ํŒŒ์ผ์˜ ์œ„์น˜ ์˜ฎ๊ธฐ๊ธฐ
cp: copy - ํด๋”๋‚˜ ํŒŒ์ผ์„ ๋ณต์‚ฌํ•˜๊ธฐ
sudo: ๊ด€๋ฆฌ์ž ๊ถŒํ•œ ํš๋“
whoami: ํ˜„์žฌ ๋กœ๊ทธ์ธ๋œ ์‚ฌ์šฉ์ž ํ™•์ธ
clear: clear CLI window
exit: exit CLI window
code: open in VScode
nano: edit on nano editor - ๊ฐ€์žฅ ์‚ฌ์šฉํ•˜๊ธฐ ์‰ฌ์šด ์—๋””ํ„ฐ

์ ˆ๋Œ€๊ฒฝ๋กœ: /Users/[username]/helloWorld/hello/ - ๋ฃจํŠธํด๋”๋ถ€ํ„ฐ ํ˜„์žฌ ์œ„์น˜๊นŒ์ง€์˜ ๊ฒฝ๋กœ

์ƒ๋Œ€๊ฒฝ๋กœ: ํ˜„์žฌ ์œ„์น˜๋ฅผ ๊ณณ์„ ๊ธฐ์ค€์œผ๋กœ ํ•œ ๊ทธ๊ณณ์˜ ๊ฒฝ๋กœ

/: ๋ฃจํŠธํด๋” (์ ˆ๋Œ€๊ฒฝ๋กœ์˜ ์‹œ์ž‘)
.: ํ˜„์žฌ ์œ„์น˜ํ•œ ํด๋” (์ƒ๋Œ€๊ฒฝ๋กœ์˜ ์‹œ์ž‘)
..: ์ƒ์œ„ ํด๋”
./: ํ˜„์žฌ ํด๋” ์•„๋ž˜์˜ (ํด๋”)
../: ํ˜„์žฌ ํด๋” ์œ„์˜ (ํด๋”)
~/: ๋ฃจํŠธํด๋”๋กœ๋ถ€ํ„ฐ ์‚ฌ์šฉ์ž ํด๋”(username)๊นŒ์ง€์˜ ๊ฒฝ๋กœ


โš™๏ธ Package, Package Manager

๋ฆฌ๋ˆ…์Šค ์šด์˜์ฒด์ œ์˜ "Package"๋Š”:

  • ํ”„๋กœ๊ทธ๋žจ ํŒŒ์ผ
  • ํ”„๋กœ๊ทธ๋žจ ์„ค์น˜ ํŒŒ์ผ
  • ํ”„๋กœ๊ทธ๋žจ ์„ค์น˜ ์„ค๋ช…์„œ
  • ํ”„๋กœ๊ทธ๋žจ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋‹ด์€ ํŒŒ์ผ

์„ ๋‹ด๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค.

Package Manager - ์•ฑ์Šคํ† ์–ด ๊ฐ™์€ ์—ญํ• 

๋ชจ๋“  ํŒจํ‚ค์ง€์˜ ์ €์žฅ์†Œ ์œ„์น˜๋ฅผ ์ €์žฅํ•˜๊ณ  ์žˆ๋‹ค. (๊ฐ ํŒจํ‚ค์ง€์˜ ์ €์žฅ์†Œ๋ฅผ ์ผ์ผ์ด ์ฐพ์•„๊ฐˆ ํ•„์š”๊ฐ€ ์—†๋‹ค)

์„ค์น˜๋œ ๋ชจ๋“  ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ(์„ค์น˜, ์‚ญ์ œ, ๋ณ€๊ฒฝ, ์—…๋ฐ์ดํŠธ ๋“ฑ)


โš™๏ธ brew (macOS ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €)

brew update - brew ์ž์ฒด ์—…๋ฐ์ดํŠธ
berw outdated - ์—…๋ฐ์ดํŠธ ํ•„์š”ํ•œ ํŒŒ์ผ ์กฐํšŒ
brew upgrade ํ”„๋กœ๊ทธ๋žจ์ด๋ฆ„ - ํ”„๋กœ๊ทธ๋žจ ์—…๊ทธ๋ ˆ์ด๋“œ(์—…๋ฐ์ดํŠธ)
brew search ๊ฒ€์ƒ‰์–ด - ํ”„๋กœ๊ทธ๋žจ ๊ฒ€์ƒ‰
brew info ํ”„๋กœ๊ทธ๋žจ์ด๋ฆ„ - ํ”„๋กœ๊ทธ๋žจ ์ •๋ณด ํ™•์ธ
brew install ํ”„๋กœ๊ทธ๋žจ์ด๋ฆ„ - ํ”„๋กœ๊ทธ๋žจ ์„ค์น˜
brew uninstall ํ”„๋กœ๊ทธ๋žจ์ด๋ฆ„ - ํ”„๋กœ๊ทธ๋žจ ์‚ญ์ œ
brew list - ์„ค์น˜๋œ ํ”„๋กœ๊ทธ๋žจ ๋ณด๊ธฐ

// ํ„ฐ๋ฏธ๋„์—์„œ

1. xcode-select --install // ์„ค์น˜ ์ „ Xcode Command Line Tools ๋จผ์ € ์„ค์น˜

2. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" // brew ์„ค์น˜
	
2-1. PATH ์ง€์ • (Next Steps๋กœ ํ‘œ๊ธฐ๋จ)
>> echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/"์‚ฌ์šฉ์ž ์ด๋ฆ„"/.zprofile 
>> eval "$(/opt/homebrew/bin/brew shellenv)"

3. brew install wget // wget ์„ค์น˜

4. wget -O goodjob.txt https://bit.ly/37sJqCo //goodjob.txt ๋ผ๋Š” ๋‹ค์šด๋กœ๋“œ๋œ ํŒŒ์ผ ํ™•์ธ

5. brew install neofetch
   neofetch // neofetch ์‹คํ–‰ํ•ด๋ณด๊ธฐ

โš™๏ธ Node.js

Runtime: ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๊ฐ€ ๊ตฌ๋™๋˜๋Š” ํ™˜๊ฒฝ
JavaScript Runtime - ๋ธŒ๋ผ์šฐ์ €, node.js ๋“ฑ

Node.js๋ผ๋Š” ์ƒˆ๋กœ์šด JavaScript ๋Ÿฐํƒ€์ž„์ด ๋“ฑ์žฅํ•˜๊ฒŒ ๋˜๋ฉด์„œ,
์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ๋งŒ ์ž‘๋™ํ–ˆ๋˜ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ํ„ฐ๋ฏธ๋„์—์„œ๋„ ์‹คํ–‰์ด ๊ฐ€๋Šฅํ•˜๊ฒŒ ๋๋‹ค.

JavaScript๋ฅผ ํ†ตํ•ด ์›น ํŽ˜์ด์ง€๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๊ฒƒ์„ ๋„˜์–ด ์„œ๋ฒ„๋ฅผ ๊ตฌ์ถ•ํ•˜๋Š” ๋“ฑ ํ™œ์šฉํญ์ด ํฌ๊ฒŒ ํ™•์žฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

node helloWorld.js // jsํŒŒ์ผ์„ nodeํ™˜๊ฒฝ์—์„œ ์‹คํ–‰ํ•œ๋‹ค.

nvm

nvm(Node Version Manager)์€ node.js์˜ ๋‹ค์–‘ํ•œ ๋ฒ„์ „์„ ๊ด€๋ฆฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค.

nvm์„ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ :

๊ฐœ๋ฐœ์„ ํ•˜๋‹ค ๋ณด๋ฉด ๋‹ค์–‘ํ•œ ๋ฒ„์ „์— ๋Œ€์‘ํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด ๊ธฐ์กด ๋ฒ„์ „์„ ์‚ญ์ œํ•˜๊ณ  ๋‹ค๋ฅธ ๋ฒ„์ „์„ ์„ค์น˜ํ•˜๋Š” ๊ณผ์ • ํ•„์š” ์—†์ด, nvm์„ ์‚ฌ์šฉํ•ด ๊ฐ„๋‹จํ•œ ๋ช…๋ น์–ด๋กœ node version ์„ ์†์‰ฝ๊ฒŒ ์˜ฎ๊ฒจ๋‹ค๋‹ ์ˆ˜ ์žˆ๋‹ค.

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash // nvm ์„ค์น˜
nvm --version // nvm ๋ฒ„์ „ ํ™•์ธ์œผ๋กœ nvm ์„ค์น˜ ์—ฌ๋ถ€ ํ™•์ธ

nvm install --lts //Node.js ์„ค์น˜
node -v //Node ๋ฒ„์ „ ํ™•์ธ์œผ๋กœ nvm ์„ค์น˜ ์—ฌ๋ถ€ ํ™•์ธ

nvm ls // nvm์„ ํ†ตํ•ด ์„ค์น˜ํ•œ Node.js version ํ™•์ธ
nvm install 12.18.3 // ์›ํ•˜๋Š” ๋ฒ„์ „์„ ์„ค์น˜
nvm use ๋ฒ„์ „ ๋„˜๋ฒ„ // ์›ํ•˜๋Š” ๋ฒ„์ „์œผ๋กœ ์ „ํ™˜

npm & package.json

npm์ด๋ž€?

npm ์€ node.js ์˜ ์•ฑ์Šคํ† ์–ด์ด๋‹ค.
npm (node package manager) ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋‚จ์ด ๋งŒ๋“ค์–ด๋†“์€ ๋ชจ๋“ˆ(node ์—์„œ๋Š” "npm ๋ชจ๋“ˆ") ์„ ์ด์šฉํ•œ๋‹ค.

package.json

๋ชจ๋“ˆ์˜ ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋‹ด์€ ํŒŒ์ผ

package.json ์„ ์ด์šฉํ•ด ๋ชจ๋“  ๋ชจ๋“ˆ์„ ์ง์ ‘ ์ „๋‹ฌํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ํ•„์š”ํ•œ ๋ชจ๋“ˆ์„ ์ ์–ด์ฃผ๊ณ  npm์„ ํ†ตํ•ด ๋‹ค์šด๋กœ๋“œ ๋ฐ›๊ฒŒ ํ•จ์œผ๋กœ์จ ๋ชจ๋“ˆ์˜ ํฌ๊ธฐ๋ฅผ ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค.

scripts - CLI ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ช…๋ น์–ด
dependencies - ํ”„๋กœ๊ทธ๋žจ ๊ตฌ๋™์— ํ•„์š”ํ•œ ๋ชจ๋“ˆ
devDependencies - ํ”„๋กœ๊ทธ๋žจ ๊ฐœ๋ฐœ์— ํ•„์š”ํ•œ ๋ชจ๋“ˆ

npm init //package.js ์ƒ์„ฑํ•˜๊ธฐ

ls
cat package.json // ๋‚ด์šฉ ํ™•์ธ ๊ฐ€๋Šฅ

โš™๏ธ Git

Git์„ ์‚ฌ์šฉ ์ด์œ  - ๋ฒ„์ „ ๊ด€๋ฆฌ

1. ํŒŒ์ผ์ด ๋ณ€๊ฒฝ๋˜๋ฉด ๋ณ€๊ฒฝ ์ด๋ ฅ์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค.
2. ์ด์ „ ๋ฒ„์ „์œผ๋กœ ๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ๋‹ค.
3. ์–ด๋–ค ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ์•Œ์•„๋ณด๊ธฐ ์‰ฝ๋‹ค.
4. ํ˜‘์—…ํ•˜๊ธฐ์— ์ข‹๋‹ค.
5. ๋ฐฑ์—…์šฉ

Git repository

Git์œผ๋กœ ๊ด€๋ฆฌ๋˜๋Š” ํด๋”๋ฅผ Git repository ๋ผ๊ณ  ํ•œ๋‹ค.

Git repository: Remote Repository & Local Repository

๊ฐœ์ธ ์ž‘์—…: Local Repository
์ž‘์—…ํ•œ ์ฝ”๋“œ๋ฅผ ๊ณต์œ ํ•˜๊ธฐ ์œ„ํ•ด ์—…๋กœ๋“œ: Remote Repository

๋‹ค๋ฅธ ์‚ฌ๋žŒ์ด Remote Repository์— ์˜ฌ๋ ค๋†“์€ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๋‚ด Local Repository๋กœ ๊ฐ€์ง€๊ณ  ์˜ฌ ์ˆ˜๋„ ์žˆ๋‹ค.

์˜คํ”ˆ ์†Œ์Šค์ธ React ํ”„๋กœ์ ํŠธ์— contribute์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”
๋จผ์ € React ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ๋‚ด ์›๊ฒฉ ์ €์žฅ์†Œ๋กœ ๊ฐ€์ง€๊ณ  ์˜ค๋Š” ์ž‘์—…์ด ํ•„์š”ํ•˜๋‹ค.

๊ทธ ๊ณผ์ •์„ Fork ๋ผ๊ณ  ํ•œ๋‹ค.

Fork ๋ฅผ ํ•˜๊ณ ๋‚˜๋ฉด ๋‚˜์˜ Remote Repository์— React ์ฝ”๋“œ๋ฅผ ์˜ฎ๊ฒจ์˜จ ์ƒํƒœ์ด๋‹ค.
์ด ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋‚ด ์ปดํ“จํ„ฐ๋กœ ๊ฐ€์ ธ์˜ค๋Š” ์ž‘์—…์ด ๋˜ ํ•„์š”ํ•˜๋‹ค.

๊ทธ ๊ณผ์ •์„ Clone ์ด๋ผ๊ณ  ํ•œ๋‹ค.

Remote Repository์— ์žˆ๋Š” ์ฝ”๋“œ๋ฅผ Clone ํ•ด์„œ ๋‚ด ์ปดํ“จํ„ฐ๋กœ ๊ฐ€์ง€๊ณ  ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.

๋‚ด ์ปดํ“จํ„ฐ์—์„œ React ์†Œ์Šค์ฝ”๋“œ ๋ณ€๊ฒฝ ์ž‘์—…์„ ํ–ˆ๋‹ค๋ฉด,
๋ณ€๊ฒฝ๋œ ๋‚ด์šฉ์„ commit์„ ํ†ตํ•ด ์ €์žฅํ•ด ์ค€ ๋’ค, Remote Repository์— ๋ฐ˜๋Œ€๋กœ ์˜ฌ๋ ค์ฃผ๋Š” ์ž‘์—…์ด ํ•„์š”ํ•˜๋‹ค.

์ด ๊ณผ์ •์„ Push ๋ผ๊ณ  ํ•œ๋‹ค.

Local Repository์— ๊ธฐ๋กํ•ด ๋†“์€ commit์„ Remote Repository๋กœ ์—…๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด๋ ‡๊ฒŒ Push๋ฅผ ์™„๋ฃŒํ•˜๊ณ  ๋‚˜๋ฉด GitHub์—๋Š” Pull request๋ผ๋Š” ๊ธฐ๋Šฅ์ด ์žˆ์–ด์„œ,
๋‚ด๊ฐ€ ์ œ์•ˆํ•œ ์ฝ”๋“œ ๋ณ€๊ฒฝ์‚ฌํ•ญ์— ๋Œ€ํ•ด ๋ฐ˜์˜ ์—ฌ๋ถ€๋ฅผ ์š”์ฒญํ•  ์ˆ˜ ์žˆ๋‹ค.

git // ํ„ฐ๋ฏธ๋„์—์„œ git ์„ค์น˜
git config --global user.name "๋‚˜์˜ ์‚ฌ์šฉ์ž ์ด๋ฆ„"
git config --global user.email "๋‚ด ์ด๋ฉ”์ผ ์ฃผ์†Œ" // ์„ค์ • ๊ฐ’

SSH (Secure shell)


๋ณด์•ˆ์ด ๊ฐ•ํ™”๋œ shell ์ ‘์†์„ ๋œปํ•œ๋‹ค.

CLI ํ™˜๊ฒฝ(ํ„ฐ๋ฏธ๋„)์—์„œ ๋‹ค๋ฅธ PC์— ์ ‘์†ํ•˜๊ฑฐ๋‚˜ ์š”์ฒญํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋ฉฐ, ๋น„๋Œ€์นญํ‚ค๋ฅผ ์ด์šฉํ•ด ์‚ฌ์šฉ์ž๋ฅผ ์ธ์ฆํ•ฉ๋‹ˆ๋‹ค.

๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์—์„œ Git์„ ๋‹จ๋…์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด SSH๊ฐ€ ์—†์–ด๋„ ๋ฌด๋ฐฉํ•˜์ง€๋งŒ,
์•ˆ์ „ํ•˜๊ฒŒ ์™ธ๋ถ€ Git ์„œ๋ฒ„์—์„œ ์ฝ”๋“œ๋ฅผ Cloneํ•˜๊ฑฐ๋‚˜ Pushํ•˜๋ ค๋ฉด SSH ํ”„๋กœํ† ์ฝœ์„ ์‚ฌ์šฉํ•œ๋‹ค.

๋”ฐ๋ผ์„œ github์— ssh ๊ณต๊ฐœํ‚ค(๋น„๋Œ€์นญํ‚ค ์ค‘ ํ•˜๋‚˜)๋ฅผ ๋“ฑ๋กํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ssh๋ฅผ ์ด์šฉํ•ด git cloneํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋‹ค๋ค„๋ณด๊ฒ ๋‹ค.

ssh-keygen // SSH ํ‚ค ์ƒ์„ฑ

ssh-keygen ๋ช…๋ น์–ด๋Š” ๊ฒฝ๋กœ ~/.ssh./ ์— ๋‘ ํŒŒ์ผ id_rsa์™€ id_rsa.pub๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

์ด ๋‘ ํŒŒ์ผ์€ ssh ํ‚ค ํŽ˜์–ด๋ผ๊ณ  ํ•˜๋ฉฐ,
id_rsa.pub๋Š” ๋ˆ„๊ตฌ์—๊ฒŒ๋‚˜ ๊ณต๊ฐœํ•ด๋„ ๋˜๋Š” ๊ณต๊ฐœํ‚ค(Public Key)๋ผ๊ณ  ํ•œ๋‹ค.
id_rsa๋Š” ๊ณต๊ฐœ๋˜๋ฉด ์•ˆ ๋˜๊ณ  ๋‚˜๋งŒ ๋ณด๊ด€ํ•ด์•ผ ํ•˜๋Š” ํ‚ค๋ผ๊ณ  ํ•˜์—ฌ, ๊ฐœ์ธํ‚ค(Private Key) ๋˜๋Š” ๋น„๋ฐ€ํ‚ค(Secret Key)๋ผ๊ณ  ํ•œ๋‹ค.

์—”ํ„ฐ๋ฅผ ๋ช‡ ๋ฒˆ ๋ˆ„๋ฅด๋ฉด, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ™”๋ฉด์ด ๋‚˜์˜ค๊ฒŒ ๋œ๋‹ค.

SSH ํ‚ค ํŽ˜์–ด๋ฅผ ์ƒ์„ฑํ•˜์˜€์œผ๋ฏ€๋กœ, ์ƒ์„ฑ๋œ ํ‚ค ํŽ˜์–ด ์ค‘ ๊ณต๊ฐœํ‚ค๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ gitub์— ๋“ฑ๋กํ•œ๋‹ค.

cat ~/.ssh/id_rsa.pub // ๊ณต๊ฐœํ‚ค ๋ณต์‚ฌ

์ด์ œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ˆœ์œผ๋กœ ์ง„ํ–‰ํ•ด์ค€๋‹ค.

Github ๋กœ๊ทธ์ธ > settings > SSH and GPG keys > New SSH Key > key ์•ˆ์— ๋ณต์‚ฌํ•œ ํ‚ค ๊ฐ’ ์ž…๋ ฅ

์„ฑ๊ณตํ–ˆ๋‹ค๋ฉด, repositories > codes > SSH ๋ฌธ์ž์—ด ๋ณต์‚ฌ > ํ„ฐ๋ฏธ๋„์—์„œ git clone ๋ณต์‚ฌํ•œ ๋ฌธ์ž์—ด

๊ณผ์ •์„ ๋๋งˆ์น˜๊ณ  ls๋กœ ํ™•์ธํ•˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ํด๋”๊ฐ€ clone ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค!!




โœ… ToDo


์ด๋ฒˆ ๊ณผ์ œ๋Š” (๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์•„๋‹Œ) node.js ํ™˜๊ฒฝ์—์„œ JavaScript ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•œ๋‹ค.
์ฝ”๋“œ์Šคํ…Œ์ด์ธ  ๊ณผ์ œ ์ œ์ถœ ์‹œ์Šคํ…œ์€ CLI ํ”„๋กœ๊ทธ๋žจ์ด๋ฉด์„œ, ๋™์‹œ์— npm ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค.


๋จผ์ € node index.js ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ ๋ฉ”์„ธ์ง€๊ฐ€ ๋‚˜์˜จ๋‹ค.

# '$' ํ‘œ์‹œ๋Š” ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'range'
Require stack:
- /Users/hongshik/Desktop/fe-sprint-cli-practice-main/getListMultiplesOfTwo.js
- /Users/hongshik/Desktop/fe-sprint-cli-practice-main/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/hongshik/Desktop/fe-sprint-cli-practice-main/getListMultiplesOfTwo.js:1:19)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/hongshik/Desktop/fe-sprint-cli-practice-main/getListMultiplesOfTwo.js',
    '/Users/hongshik/Desktop/fe-sprint-cli-practice-main/index.js'
  ]
}

์ž์„ธํžˆ ์—๋Ÿฌ ๋ฉ”์„ธ์ง€๋ฅผ ์‚ดํŽด๋ณด๋ฉด Error: Cannot find module 'range' ๋ผ๊ณ  ๋˜์–ด์žˆ๋Š”๋ฐ
๋”ฑ ๋ด๋„ range ๋ชจ๋“ˆ์ด ๊น”๋ฆฌ์ง€ ์•Š์•˜๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

๋”ฐ๋ผ์„œ npm install range ๋ฅผ ์ด์šฉํ•˜์—ฌ range ๋ชจ๋“ˆ์„ ๊น”์•„์ค€๋‹ค.

๊ทธ๋Ÿผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์น˜๊ฐ€ ๋˜๋Š” ๋ชจ์Šต์„ ๋ณผ ์ˆ˜ ์žˆ๊ณ ,

๋‹ค์‹œ node index.js ์‹œ, ์˜ค๋Š˜์˜ ๊ณผ์ œ์ธ ๋ฏธ์…˜์„ ๋ณผ ์ˆ˜ ์žˆ์—ˆ๋‹ค.


์ด์ œ nano getListMultiplesOfTwo.js ๋กœ ํŒŒ์ผ ํŽธ์ง‘์„ ์‹œ์ž‘ํ•˜์ž.

๊ทธ๋ฆฌ๊ณ  nano index.js ๋กœ getListMultiplesOfTwo ๋ฅผ ๋ถˆ๋Ÿฌ์˜จ๋‹ค ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

element๊ฐ€ upTo ์ธ ๊ฒƒ์ด ํฌ์ธํŠธ์ด๋‹ค.


๋‹คํ–‰์ด๊ฒŒ๋„ https://npm.runkit.com/range?t=1652067135454 ๋ฅผ ์ฐธ๊ณ ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

var range = require("range")
range.range(0, 100, 2);

์›๋ž˜๋Œ€๋กœ๋ฉด ์ด๊ฒŒ ๋งž๊ฒ ์ง€๋งŒ, index.js ๋Š” upto๋ฅผ ์ธ์ž๋กœ ํ•˜๋ฏ€๋กœ ์ด ์ฝ”๋“œ๊ฐ€ ๋งž๊ฒ ๋‹ค.

var range = require("range")
range.range(2, upTo+2, 2);


ctrl + x ์„ ๋ˆ„๋ฅด๊ณ  y๋กœ ์ €์žฅ์„ ํ•œ ํ›„, ์ฐฝ์„ ๋‚˜์™€์„œ node index.js๋กœ ๋‹ค์‹œ ๋“ค์–ด๊ฐ€๋ณด์ž.

๊ทธ๋Ÿผ ์šฐ๋ฆฌ๊ฐ€ ์ž…๋ ฅํ–ˆ๋˜ function์ด ์ œ๋Œ€๋กœ ์ „๋‹ฌ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

npm run test ๋„ ํ†ต๊ณผํ–ˆ์œผ๋‹ˆ, npm run submit ์œผ๋กœ ์ œ์ถœํ•˜๋ฉด ๊ณผ์ œ Done.
์ถ”๊ฐ€๋กœ npm run submit ls ๋กœ ์ด๋•Œ๊นŒ์ง€ ์ œ์ถœํ•œ ๊ณผ์ œ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

profile
์•„์ด๋””์–ด๊ฐ€ ๋„˜์น˜๋Š” ํ”„๋ก ํŠธ์—”๋“œ๋ฅผ ๊ฟˆ๊ฟ‰๋‹ˆ๋‹ค ๐Ÿ”ฅ

0๊ฐœ์˜ ๋Œ“๊ธ€