00. Linuxs - yojulab/learn_DevOps GitHub Wiki

์ฃผ์š” ๋ช…๋ น์–ด

  1. ls: ๋””๋ ‰ํ„ฐ๋ฆฌ์˜ ํŒŒ์ผ๊ณผ ํด๋” ๋ชฉ๋ก์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
# ํ˜„์žฌ ๋””๋ ‰ํ„ฐ๋ฆฌ์˜ ํŒŒ์ผ๊ณผ ํด๋” ๋ชฉ๋ก ๋ณด๊ธฐ
ls

# ๋ชจ๋“  ํŒŒ์ผ(์ˆจ๊น€ ํŒŒ์ผ ํฌํ•จ)๊ณผ ์ž์„ธํ•œ ์ •๋ณด(๊ถŒํ•œ, ์†Œ์œ ์ž, ํฌ๊ธฐ ๋“ฑ) ๋ณด๊ธฐ
ls -la

2. pwd: ํ˜„์žฌ ๊ฒฝ๋กœ ํ™•์ธ

pwd
  • ํ˜„์žฌ ์ž‘์—… ์ค‘์ธ ๋””๋ ‰ํ† ๋ฆฌ์˜ ์ ˆ๋Œ€ ๊ฒฝ๋กœ๋ฅผ ํ™•์ธ.
  1. cd: ํ˜„์žฌ ์ž‘์—… ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.
# ํ™ˆ ๋””๋ ‰ํ„ฐ๋ฆฌ๋กœ ์ด๋™
cd ~

# ์ƒ์œ„ ๋””๋ ‰ํ„ฐ๋ฆฌ๋กœ ์ด๋™
cd ..

# ํŠน์ • ๋””๋ ‰ํ„ฐ๋ฆฌ๋กœ ์ด๋™
cd /usr/local/bin

4. mkdir: ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ

mkdir new_directory
  • ์ƒˆ๋กœ์šด ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•˜๋ ค๋ฉด mkdir ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉ.

5. cat: ํŒŒ์ผ ๋‚ด์šฉ ์ถœ๋ ฅ

cat file.txt
  • ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ์ถœ๋ ฅํ•˜๋ ค๋ฉด cat ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉ.

6. cp: ํŒŒ์ผ ๋ณต์‚ฌ

cp file.txt /path/to/destination
  • ํŒŒ์ผ์„ ๋‹ค๋ฅธ ์œ„์น˜๋กœ ๋ณต์‚ฌํ•˜๋ ค๋ฉด cp ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉ.
cp -r dir/ /path/to/destination
  • ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋ณต์‚ฌํ•˜๋ ค๋ฉด -r ์˜ต์…˜์„ ์‚ฌ์šฉ.

7. mv: ํŒŒ์ผ ์ด๋™ ๋˜๋Š” ์ด๋ฆ„ ๋ณ€๊ฒฝ

mv file.txt /path/to/destination
  • ํŒŒ์ผ์„ ์ด๋™ํ•˜๋ ค๋ฉด mv ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉ.
mv old_name.txt new_name.txt
  • ํŒŒ์ผ์˜ ์ด๋ฆ„์„ ๋ณ€๊ฒฝํ•˜๋ ค๋ฉด mv ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉ.

์‹œ์Šคํ…œ ๊ด€๋ฆฌ ๋ช…๋ น์–ด

  1. sudo: ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ๋ช…๋ น์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
# ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ํŒจํ‚ค์ง€ ์„ค์น˜
sudo apt install git

# ์‹œ์Šคํ…œ ํŒŒ์ผ ์ˆ˜์ • (๊ด€๋ฆฌ์ž ๊ถŒํ•œ์ด ํ•„์š”)
sudo nano /etc/hosts
  1. apt: ํŒจํ‚ค์ง€ ์„ค์น˜, ์—…๋ฐ์ดํŠธ, ์‚ญ์ œ ๋“ฑ ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
# ํŒจํ‚ค์ง€ ๋ชฉ๋ก ์—…๋ฐ์ดํŠธ
sudo apt update

# ํŒจํ‚ค์ง€ ์„ค์น˜
sudo apt install vim

# ํŒจํ‚ค์ง€ ์‚ญ์ œ
sudo apt remove vim

์ฃผ์š” ํŽธ์ง‘๊ธฐ : nano, vim, emacs

  1. nano
# ํŒŒ์ผ ์ƒ์„ฑ ๋ฐ ์—ด๊ธฐ:
   nano example.txt

# ํŒŒ์ผ์— ํ…์ŠคํŠธ ์ž…๋ ฅ:
   This is a test file.
   Nano is easy to use!

# ํŒŒ์ผ ์ €์žฅ: Ctrl + O, Enter๋ฅผ ๋ˆŒ๋Ÿฌ `example.txt`๋กœ ์ €์žฅ.

# Nano ์ข…๋ฃŒ:Ctrl + X

# ํŒŒ์ผ ๋‚ด์šฉ ํ™•์ธ
   cat example.txt
   This is a test file.
   Nano is easy to use!
  1. vim
# ํŒŒ์ผ ์ƒ์„ฑ ๋ฐ ์—ด๊ธฐ:
vim example.txt
# ์ž…๋ ฅ ๋ชจ๋“œ ์ง„์ž… (ํŽธ์ง‘ ๋ชจ๋“œ):
i
# ํŒŒ์ผ์— ํ…์ŠคํŠธ ์ž…๋ ฅ:
This is a test file.
Vim is powerful!
# ์ž…๋ ฅ ๋ชจ๋“œ ์ข…๋ฃŒ (๋ช…๋ น ๋ชจ๋“œ๋กœ ๋ณต๊ท€):
Esc
# ํŒŒ์ผ ์ €์žฅ ๋ฐ ์ข…๋ฃŒ:
:wq
# ํŒŒ์ผ ๋‚ด์šฉ ํ™•์ธ:
cat example.txt
This is a test file.
Vim is powerful!
  1. emacs
# ํŒŒ์ผ ์ƒ์„ฑ ๋ฐ ์—ด๊ธฐ:
emacs example.txt
# ํŒŒ์ผ์— ํ…์ŠคํŠธ ์ž…๋ ฅ:
This is a test file.
Emacs is versatile!
# ํŒŒ์ผ ์ €์žฅ: 
Ctrl + X, Ctrl + S
# Emacs ์ข…๋ฃŒ:
Ctrl + X, Ctrl + C
# ํŒŒ์ผ ๋‚ด์šฉ ํ™•์ธ:
cat example.txt
This is a test file.
Emacs is versatile!