๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ–ฅ๏ธ Linux

ls ๋ช…๋ น์–ด/ํŒŒ์ผ๋ชฉ๋ก/linux ls

์งค๋ง‰ํ•œ ls ๋ช…๋ น์–ด๋ฅผ ์ •๋ฆฌํ•˜๋ ค๊ณ  ํ•œ๋‹ค

์›”๋ฃจ ํ•˜๊ณ  ์žˆ์—ˆ๋Š”๋ฐ ์‹œ๊ฐ„์ด ๋„ˆ๋ฌด ์•„๊นŒ์›Œ์„œ ๋ญ๋ผ๋„ ๋‚จ๊ฒจ์•ผ๊ฒ ๋‹ค

 


 

1. ls ๋ช…๋ น์–ด (list)

 

๋‚˜๋Š” ์‰˜์ฐฝ์„ ํ‚ค๋ฉด ๊ทธ๋ƒฅ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ls ๋ช…๋ น์–ด๋ฅผ ์นœ๋‹ค

ํŒŒ์ผ ๋ชฉ๋ก์ด๋ผ๋„ ์ผœ๋†“์•„์•ผ ๋  ๊ฒƒ ๊ฐ™์•„์„œ

 

ls๋Š” list์˜ ์ค„์ž„๋ง๋กœ, ๋ง ๊ทธ๋Œ€๋กœ ํŒŒ์ผ ๋ชฉ๋ก์„ ๋ณด์—ฌ์ค€๋‹ค

์‚ฌ์šฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค

 

CLI> ls [<์˜ต์…˜>]... [<ํŒŒ์ผ>]...

 

์˜ˆ๋ฅผ๋“ค์–ด์„œ, ์•„๋ž˜์™€ ๊ฐ™์€ ํŒŒ์ผ๊ตฌ์กฐ๊ฐ€ ์žˆ๋‹ค๋ฉด

 

 

ls ๋ช…๋ น์–ด๋ฅผ ์ณค์„ ๋•Œ ๋‚˜์˜ค๋Š” ํ•ญ๋ชฉ์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค

 

CLI> ls
Makefile  main.cpp  release  test.cpp

 

์š”๋ ‡๊ฒŒ ํ˜„์žฌ ๋””๋ ‰ํ† ๋ฆฌ์— ์žˆ๋Š” ํŒŒ์ผ ๋ชฉ๋ก์„ ๋ณด์—ฌ์ค€๋‹คใ…‹

ls ๋ช…๋ น์–ด๋Š” ๋งŽ์€ ์˜ต์…˜๋“ค์„ ๊ฐ–๊ณ  ์žˆ๋‹ค

ํŒŒ์ผ ๋ชฉ๋ก๋“ค์˜ ์ •๋ณด๋ฅผ ๋‹ค ๋ณด์—ฌ์ฃผ๋Š” ๋ช…๋ น์–ด๋ผ์„œ,

ํŒŒ์ผ์˜ ๊ถŒํ•œ/ํŒŒ์ผ ํฌ๊ธฐ/์‚ฌ์šฉ์ž/์ˆ˜์ • ๋‚ ์งœ ๋“ฑ๋“ฑ ๋˜ํ•œ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค

 

์ž์„ธํ•œ ์˜ต์…˜๋“ค์— ๋Œ€ํ•œ๊ฑด man page๋ฅผ ํ†ตํ•ด์„œ ๋ณด๋ฉด ๋  ๊ฒƒ ๊ฐ™๊ณ ,

๋‚ด๊ฐ€ ์ž์ฃผ ์“ฐ๋Š” ์˜ต์…˜๋งŒ ์ •๋ฆฌ ํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค

 

 

2. ls Options

 

์˜ต์…˜ ์„ค๋ช… ์‚ฌ์šฉ ์˜ˆ์‹œ
-a ๋˜๋Š” --all .์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” ํŒŒ์ผ๋„ ๋ชจ๋‘ ์ถœ๋ ฅํ•˜๊ธฐ ls -a
-l (์†Œ๋ฌธ์ž L) long format์œผ๋กœ ์ถœ๋ ฅํ•˜๊ธฐ
(ํŒŒ์ผ ๊ถŒํ•œ+ํฌ๊ธฐ+์‹œ๊ฐ„ ๋“ฑ๋“ฑ)
ls -l
-h ๋˜๋Š”
--human-readable
-l ์˜ต์…˜๊ณผ ๊ฐ™์ด ์‚ฌ์šฉํ•  ๋•Œ, ํŒŒ์ผ ํฌ๊ธฐ๋ฅผ ์‚ฌ๋žŒ์ด ๋ณด๊ธฐ ์‰ฌ์šด ํฌ๊ธฐ๋กœ ๋ฐ”๊ฟ”์„œ ์ถœ๋ ฅํ•˜๊ธฐ
ex) ํŒŒ์ผํฌ๊ธฐ๊ฐ€ 21600์ผ ๋•Œ 22K๋กœ ํ‘œํ˜„
ls -lh

 

 

์ด๋ ‡๊ฒŒ 3๊ฐœ ์˜ต์…˜๋งŒ ์ฃผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค

๊ฐ€๋” ํŒŒ์ผ ํฌ๊ธฐ ์ •ํ™•ํžˆ ์•Œ๋ ค๊ณ  -al๋งŒ ์‚ฌ์šฉํ•˜๋Š” ์ •๋„?

 

๊ทธ๋Ÿผ ๋งˆ์ง€๋ง‰์œผ๋กœ -alh ์˜ต์…˜ 3๊ฐœ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ ์–ด๋–ป๊ฒŒ ๋‚˜์˜ค๋Š”์ง€๋งŒ

์ฒจ๋ถ€ํ•˜๊ณ  ๋๋‚ด๊ฒ ๋‹ค

 

 

(1) ls ๋งŒ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ

 

CLI> ls
Makefile  main.cpp  release  test.cpp

 

(2) ls -al ์‚ฌ์šฉํ–ˆ์„ ๋•Œ

 

CLI> ls -al
ํ•ฉ๊ณ„ 16
drwxr-xr-x. 3 {USER ID} {USER ID}   85  6์›” 14 14:38 .
drwxr-xr-x. 8 {USER ID} {USER ID} 4096  6์›” 16 10:12 ..
-rw-r--r--. 1 {USER ID} {USER ID}    0  6์›” 14 14:29 .dependencies
-rw-r--r--. 1 {USER ID} {USER ID} 1119  6์›” 14 14:25 Makefile
-rw-r--r--. 1 {USER ID} {USER ID}  664  6์›”  7 16:06 main.cpp
drwxr-xr-x. 2 {USER ID} {USER ID}   36  6์›” 14 14:29 release
-rw-r--r--. 1 {USER ID} {USER ID} 2049  6์›” 14 14:29 test.cpp

 

(3) ls -alh ์‚ฌ์šฉํ–ˆ์„ ๋•Œ

 

CLI> ls -alh
ํ•ฉ๊ณ„ 16K
drwxr-xr-x. 3 {USER ID} {USER ID}   85  6์›” 14 14:38 .
drwxr-xr-x. 8 {USER ID} {USER ID} 4.0K  6์›” 16 10:12 ..
-rw-r--r--. 1 {USER ID} {USER ID}    0  6์›” 14 14:29 .dependencies
-rw-r--r--. 1 {USER ID} {USER ID} 1.1K  6์›” 14 14:25 Makefile
-rw-r--r--. 1 {USER ID} {USER ID}  664  6์›”  7 16:06 main.cpp
drwxr-xr-x. 2 {USER ID} {USER ID}   36  6์›” 14 14:29 release
-rw-r--r--. 1 {USER ID} {USER ID} 2.1K  6์›” 14 14:29 test.cpp