Computer-Science

Basic Linux Commands (http://linux.die.net/Linux-CLI/)


Linux command classification

display information

manipulate information

file tree

relative path, absolute path

If the path starts with /, it is an absolute path; otherwise it is a relative path.

   cd  /home/linuxer1/12345   -- go to /home/linuxer1/12345
   cd  12345                  -- go to directory 12345 in the current directory
                                 if the current location is /home/linuxer1,
                                     go to /home/linuxer1/12345
                                 if the current location is /bin
                                     go to /bin/12345

If the destination directory does not exist, the system issues an error.

special symbols


cat

cat ๋ช…๋ น์–ด๋Š” concatenate ๋˜๋Š” catenate์—์„œ ๋”ฐ์˜จ ์ด๋ฆ„์œผ๋กœ, file์˜ contents๋ฅผ ๋ณด์—ฌ์ค€๋‹ค.

$ cat f1
hello
$ cat f1 >f2
$ cat f2
hello
$ cat > f3
hihihi
$ cat f3
hihihi

cd

cd ๋ช…๋ น์–ด๋Š” โ€œChange Directoryโ€์˜ ์ค„์ž„๋ง๋กœ์„œ, ํ˜„์žฌ ๋””๋ ‰ํ† ๋ฆฌ์˜ ์œ„์น˜๋ฅผ ๋ณ€๊ฒฝํ•œ๋‹ค.

chmod

chmod๋Š” change mode์˜ ์ค„์ž„๋ง๋กœ, ๋ฆฌ๋ˆ…์Šค ํผ๋ฏธ์…˜ ๋ณ€๊ฒฝ ๋ช…๋ น์–ด์ด๋‹ค. ํŒŒ์ผ ๋˜๋Š” ํด๋”์˜ ์‚ฌ์šฉ๊ถŒํ•œ์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

image

clear

ํ„ฐ๋ฏธ๋„ ํ™”๋ฉด ๋น„์šฐ๊ธฐ ๋ช…๋ น์–ด์ด๋‹ค.

image

cp

cp ๋ช…๋ น์–ด๋Š” copy์˜ ์ค„์ž„๋ง๋กœ์„œ, ํŒŒ์ผ๊ณผ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋ณต์‚ฌํ•˜๋Š” ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•œ๋‹ค.

$ mkdir d1
$
$ cp f1 f2
$ ls
d1 f1 f2
$
$ cp f1 d1
$ cd d1
$ ls
$ f1
$
$ cd ..
$ cp f1 d1/f2
$ cd d2
$ ls
f1 f2

date

date ๋ช…๋ น์–ด๋Š” ํ˜„์žฌ ๋‚ ์งœ์™€ ์‹œ๊ฐ„์„ ํ‘œ์‹œํ•˜๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

image

dd

dd ๋ช…๋ น์–ด๋Š” Disk Dump์˜ ์•ฝ์ž๋กœ, ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜, ๋””์Šคํฌ๋ฅผ ๋ณต์‚ฌํ•  ๋•Œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. image

df

df ๋ช…๋ น์–ด๋Š” ํŒŒ์ผ์‹œ์Šคํ…œ ์‚ฌ์šฉ๋Ÿ‰์„ ์•Œ๋ ค์ฃผ๋Š” ๋ช…๋ น์–ด์ด๋‹ค. -h ์˜ต์…˜(human-readable)์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ฉ”๊ฐ€๋ฐ”์ดํŠธ(M) ๊ธฐ๊ฐ€๋ฐ”์ดํŠธ(G) ๋“ฑ ์šฉ๋Ÿ‰๋‹จ์œ„๋ฅผ ์ ์ ˆํžˆ ๋งž์ถ”์–ด ์ฝ๊ธฐ ์‰ฌ์šด ๋‹จ์œ„๋กœ ํ‘œํ˜„๋œ๋‹ค.

image

diff

diff ๋ช…๋ น์–ด๋Š” differences์˜ ์•ฝ์ž๋กœ ๋‘ ํŒŒ์ผ ์‚ฌ์ด์˜ ๋‚ด์šฉ์„ ๋น„๊ตํ•˜๋Š” ๋ช…๋ น์–ด์ด๋‹ค. ` diff [์˜ต์…˜][๋น„๊ตํŒŒ์ผ1][๋น„๊ตํŒŒ์ผ2]`์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์˜ต์…˜์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

-c	๋‘ ํŒŒ์ผ๊ฐ„์˜ ์ฐจ์ด์  ์ถœ๋ ฅ
-d	๋‘ ํŒŒ์ผ๊ฐ„์˜ ์ฐจ์ด์ ์„ ์ƒ์„ธํ•˜๊ฒŒ ์ถœ๋ ฅ
-r	๋‘ ๋””๋ ‰ํ† ๋ฆฌ๊ฐ„์˜ ์ฐจ์ด์  ์ถœ๋ ฅ, ์„œ๋ธŒ๋””๋ ‰ํ† ๋ฆฌ ๊นŒ์ง€ ๋น„๊ต
-i	๋Œ€์†Œ๋ฌธ์ž์˜ ์ฐจ์ด ๋ฌด์‹œ
-w	๋ชจ๋“  ๊ณต๋ฐฑ ์ฐจ์ด๋ฌด์‹œ
-s	๋‘ ํŒŒ์ผ์ด ๊ฐ™์„ ๋•Œ ์•Œ๋ฆผ
-u	๋‘ ํŒŒ์ผ์˜ ๋ณ€๊ฒฝ๋˜๋Š” ๋ถ€๋ถ„๊ณผ ๋ณ€๊ฒฝ๋˜๋Š” ๋ถ€๋ถ„์˜ ๊ทผ์ฒ˜์˜ ๋‚ด์šฉ๋„ ์ถœ๋ ฅ

image

dmesgโ€ƒ

dmesg๋Š” display message์˜ ์ค„์ž„๋ง๋กœ ๋ฆฌ๋ˆ…์Šค ๋ถ€ํŒ… ๋ฉ”์‹œ์ง€, ๋ฆฌ๋ˆ…์Šค ๋ถ€ํŒ… ๋กœ๊ทธ๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๋ช…๋ น์–ด์ด๋‹ค. dmesg | less ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด, ๋ฉ”์‹œ์ง€๋ฅผ ์Šคํฌ๋กค ํ•  ์ˆ˜ ์žˆ๋‹ค.

image

du

du disk usage์˜ ์ค„์ž„๋ง๋กœ์„œ, ๋ฆฌ๋ˆ…์Šค ๋””๋ ‰ํ† ๋ฆฌ ์šฉ๋Ÿ‰ ํ™•์ธ ๋ฐ ๋ฆฌ๋ˆ…์Šค ํด๋” ์šฉ๋Ÿ‰ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

image

echo

echo ๋ช…๋ น์–ด๋Š” argument๋กœ ์ „๋‹ฌ๋˜๋Š” ํ…์ŠคํŠธ / ๋ฌธ์ž์—ด์„ ํ™”๋ฉด์— ํ‘œ์‹œํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋œ๋‹ค.

$ echo korea
korea
$ echo korea > f1
$ cat f1
korea

envโ€ƒ

env ๋ช…๋ น์–ด๋Š” ๋ฆฌ๋ˆ…์Šค์˜ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

image

exitโ€ƒ

exit ๋ช…๋ น์–ด๋Š” ํ˜„์žฌ ์„ธ์…˜ ์ข…๋ฃŒ ๋ฐ ๋ช…๋ น์–ด ์Šคํฌ๋ฆฝํŠธ ์ข…๋ฃŒ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

image

file

file ๋ช…๋ น์–ด๋Š” ํŒŒ์ผํ˜•์‹ ํ™•์ธํ•˜๊ณ , ํŒŒ์ผ์˜ ์ข…๋ฅ˜๋ฅผ ํŒ๋‹จํ•˜๋Š” ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด์ด๋‹ค.
ํŒ๋‹จ ์‹œ, ํ™•์žฅ์ž๋ฅผ ๋ณด๊ณ  ํŒ๋‹จํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ๋‚ด์šฉ์„ ๋ณด๊ณ  ํŒ๋‹จํ•œ๋‹ค.

$ file README.md
README.md: ASCII text

find

find ๋ช…๋ น์–ด๋Š” ํŒŒ์ผ, ๋””๋ ‰ํ† ๋ฆฌ์˜ ๊ฒ€์ƒ‰์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด์ด๋‹ค.

find / -name "stdio.h" -print : find the location of stdio.h starting from /

$ find
.
./version-groups.conf
./pluginconf.d
./pluginconf.d/security.conf
./pluginconf.d/fastestmirror.conf
./vars
./protected.d
$ find / -name "stdio.h" -print
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/stdio.h

grep

grep โ€“nr โ€œkoโ€ _ : find all files that contain string โ€œkoโ€. โ€“n means show the line number that contains โ€œkoโ€. โ€“r means โ€œdo this recursively searching down all sub-directoriesโ€. _ menas โ€œall filesโ€ in the current directory.

grep ๋ช…๋ น์–ด๋Š” ์ž…๋ ฅ์œผ๋กœ ์ „๋‹ฌ๋œ ํŒŒ์ผ์—์„œ ํŠน์ • ๋ฌธ์ž์—ด์„ ์ฐพ์„ ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๋ช…๋ น์–ด๋‹ค. ์‰ฝ๊ฒŒ ๋งํ•ด์„œ ์›ํ•˜๋Š” ๋ฌธ์ž๋‚˜ ๋ฌธ์ž์—ด์„ ์ฐพ์„ ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.

$ grep [-์˜ต์…˜] ํŒจํ„ด ํŒŒ์ผ๋ช…

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-03-13 แ„‹แ…ฉแ„’แ…ฎ 5 12 29

์ถœ๋ ฅ๋ช…๋ น์–ด | grep ํŒจํ„ด
$ ll /etc/ssh/
total 96
-rw-r--r--  1 root  wheel   564K  1  1  2020 moduli
-rw-r--r--  1 root  wheel   1.5K  1  1  2020 ssh_config
-rw-r--r--  1 root  wheel   3.1K  1  1  2020 sshd_config
$ ll /etc/ssh/ | grep config
-rw-r--r--  1 root  wheel   1.5K  1  1  2020 ssh_config
-rw-r--r--  1 root  wheel   3.1K  1  1  2020 sshd_config

gunzip

gunzip ๋ช…๋ น์–ด๋Š” ์••์ถ•๋œ ํŒŒ์ผ ์••์ถ•ํ•ด์ œ์— ์“ฐ์ด๋Š” ๋ช…๋ น์–ด์ด๋‹ค. gunzip [์••์ถ•ํ•ด์ฒดํ•  ํŒŒ์ผ๋ช….gz]์œผ๋กœ [์••์ถ•ํ•ด์ฒดํ•  ํŒŒ์ผ๋ช….gz]์„ ์••์ถ•ํ•ด์ œ ํ•  ์ˆ˜ ์žˆ๋‹ค.
gzip -d ๋Š” gunzip๊ณผ ๋™์ผํ•˜๋ฉฐ, gzip ์—์„œ -d ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์œผ๋กœ ์••์ถ•ํ•ด์ œ๋ฅผ ํ•˜๋Š” ์˜ต์…˜์ด๋‹ค.
ํ•˜์ง€๋งŒ, gunzip ์œผ๋กœ ์••์ถ•ํ•ด์ œ๋ฅผ ํ•˜๋ฉด gzip์œผ๋กœ ์••์ถ•ํ•˜๊ธฐ ์ „์˜ ์›๋ณธํŒŒ์ผ์˜ ์†Œ์œ ์ฃผ์™€ ์†Œ์œ ๊ทธ๋ฃน, ํŒŒ์ผ์•ก์„ธ์Šค ์‹œ๊ฐ„, ํŒŒ์ผ๋ณ€๊ฒฝ์‹œ๊ฐ„, ํผ๋ฏธ์…˜์€ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•œ์ฑ„๋กœ ์••์ถ•ํ•ด์ œ๊ฐ€ ๋œ๋‹ค.

์ฐธ๊ณ ๋กœ, gzip [์••์ถ•ํ•  ํŒŒ์ผ๋ช…]์œผ๋กœ [์••์ถ•ํ•  ํŒŒ์ผ]์„ ์••์ถ• ํ•  ์ˆ˜ ์žˆ๋‹ค.

image

gzip

gzip ๋ช…๋ น์–ด๋Š” GNU zip์˜ ์•ฝ์ž๋กœ, gzip ๋ช…๋ น์„ ํ†ตํ•ด ์••์ถ•์ด ์„ฑ๊ณตํ•˜๋ฉด ๊ธฐ์กด์˜ ๋ชจ๋“  ์›๋ณธ ํŒŒ์ผ์ด ์‚ฌ๋ผ์ง€๊ณ  ํ™•์žฅ์ž๊ฐ€ .gz์ธ ์ƒˆ ํŒŒ์ผ์ด ๋งŒ๋“ค์–ด์ง„๋‹ค.

image

head ๋ช…๋ น์–ด๋Š” ํŒŒ์ผ์˜ ์ฒซ ๋ถ€๋ถ„๋งŒ ์ถœ๋ ฅํ•˜๋Š” ๋ช…๋ ์–ด์ด๋‹ค. ์•„๋ฌด ์˜ต์…˜ ์—†์ด ์‚ฌ์šฉํ•˜๋ฉด, ์ฒ˜์Œ 10๊ฐœํ–‰์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ์•„๋ž˜์˜ ๋ช…์–ด๋ฅผ ํ†ตํ•ด ์›ํ•˜๋Š” n๊ฐœ์˜ ํ–‰์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

head -ํ–‰์ˆ˜ ํŒŒ์ผ๋ช…
head -nํ–‰์ˆ˜ ํŒŒ์ผ๋ช…
head ํŒŒ์ผ๋ช… -nํ–‰์ˆ˜
cat ํŒŒ์ผ๋ช… | head -ํ–‰์ˆ˜
cat ํŒŒ์ผ๋ช… | head -nํ–‰์ˆ˜

image

ifconfig

ifconfig ๋ช…๋ น์–ด๋Š” interface configuration์˜ ์ค„์ž„๋ง๋กœ์„œ, ๋ฆฌ๋ˆ…์Šค ๋„คํŠธ์›Œํฌ์˜ IP ์ฃผ์†Œ, ๋งฅ์ฃผ์†Œ, ๋„ท๋งˆ์Šคํฌ, MTU ์„ค์ • ๋“ฑ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

image

less

more ๋ช…๋ น์–ด์™€ ๋น„์Šทํ•˜๋‹ค.

locate

find the location of a file in the file database

ln

ln ๋ช…๋ น์–ด๋Š” ๋งํฌ ์ƒ์„ฑ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด์ด๋‹ค. ๊ธฐ๋ณธ ์˜ต์…˜์€ ํ•˜๋“œ ๋งํฌ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์ด๋ฉฐ, -s ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜๋ฉด ์‹ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

image

ls

ls ๋ช…๋ น์–ด๋Š” โ€œlistingโ€์˜ ์ค„์ž„๋ง๋กœ์„œ, ํ˜„์žฌ ๋””๋ ‰ํ† ๋ฆฌ์— ์žˆ๋Š” ํŒŒ์ผ๋“ค๊ณผ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

$ ls -l
-rwxr-xr-x 1 linuxer1 linuxer1 14 Feb 26 2013 f1

man

man ๋ช…๋ น์–ด๋Š” โ€œmannualโ€์˜ ์ค„์ž„๋ง๋กœ์„œ, commands/system calls/c-lib functions ๋“ฑ์˜ ์‚ฌ์šฉ๋ฒ•(๋งค๋‰ด์–ผ)์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
๋‹ค์Œ ํ™”๋ฉด์œผ๋กœ ์ด๋™ํ•˜๋ ค๋ฉด โ€˜์ŠคํŽ˜์ด์Šค๋ฐ”โ€™๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ด๋™ํ•  ์ˆ˜ ์žˆ๊ณ , โ€˜qโ€™๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ข…๋ฃŒํ•  ์ˆ˜ ์žˆ๋‹ค.

mkdir

mkdir์€ โ€˜make directoryโ€™์˜ ์ค„์ž„๋ง๋กœ์„œ, ๋””๋ ‰ํ† ๋ฆฌ(ํด๋”)๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.

$ mkdir d1

more

more์€ file์˜ contents๋ฅผ ํ™”๋ฉด์— ํ™”๋ฉด ๋‹จ์œ„๋กœ ๋Š์–ด์„œ ์ถœ๋ ฅํ•˜๋Š” ๋ช…๋ น์–ด์ด๋‹ค.
์ด ๋ช…๋ น์–ด๋Š” ์œ„์—์„œ ์•„๋ž˜ ๋ฐฉํ–ฅ์œผ๋กœ๋งŒ ์ถœ๋ ฅ ๋˜๊ธฐ ๋•Œ๋ฌธ์—, ์ง€๋‚˜๊ฐ„ ๋‚ด์šฉ์„ ๋‹ค์‹œ ๋ณผ ์ˆ˜ ์—†๋Š” ๋‹จ์ ์ด ์žˆ๋‹ค.
๋‹ค์Œ ํ™”๋ฉด์œผ๋กœ ์ด๋™ํ•˜๋ ค๋ฉด โ€˜์ŠคํŽ˜์ด์Šค๋ฐ”โ€™๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ด๋™ํ•  ์ˆ˜ ์žˆ๊ณ , โ€˜qโ€™๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ข…๋ฃŒํ•  ์ˆ˜ ์žˆ๋‹ค.

mount

mount ๋ช…๋ น์–ด๋Š” ํŒŒ์ผ์‹œ์Šคํ…œ ๋งˆ์šดํŠธ ๋ช…๋ น์–ด๋กœ์„œ, ํ˜„์žฌ ์‹œ์Šคํ…œ์— ๋งˆ์šดํŠธ๋œ ์ •๋ณด ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

image

mv

mv๋Š” move์˜ ์•ฝ์ž๋กœ์„œ ํŒŒ์ผ์ด๋‚˜ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋‹ค๋ฅธ ์œ„์น˜๋กœ ์ด๋™์‹œํ‚ค๊ฑฐ๋‚˜ ํŒŒ์ผ๋ช…์„ ๋ณ€๊ฒฝํ•˜๊ณ ์ž ํ• ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.
ํŒŒ์ผ์ด๋ฆ„๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋””๋ ‰ํ† ๋ฆฌ๋ช…๋„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค.

mv ํŒŒ์ผ๋ช…1 ํŒŒ์ผ๋ช…2์„ ์‚ฌ์šฉํ•˜๋ฉด, ํŒŒ์ผ๋ช…1์„ ํŒŒ์ผ๋ช…2๋กœ ํŒŒ์ผ๋ช…์„ ๋ณ€๊ฒฝํ•œ๋‹ค. ์ด๋Š” cp ๋ช…๋ น์–ด์™€ rm ๋ช…๋ น์–ด๊ฐ€ ์—ฐ์†์œผ๋กœ ์‚ฌ์šฉ๋œ ๊ฒƒ๊ณผ ๊ฐ™๋‹ค.

$ mv f2 f3 # change the name of file f2 to f3

netstatโ€ƒ

netstat ๋ช…๋ น์–ด๋Š” network statistics (๋„คํŠธ์›Œํฌ ํ†ต๊ณ„)์˜ ์ค„์ž„๋ง๋กœ, ๋„คํŠธ์›Œํฌ ์ ‘์†, ๋ผ์šฐํŒ… ํ…Œ์ด๋ธ”, ๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค์˜ ํ†ต๊ณ„ ์ •๋ณด๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๋„๊ตฌ์ด๋‹ค.

image

ps

ps๋Š” Process Status์˜ ์•ฝ์ž๋กœ ํ˜„์žฌ ๋Œ์•„๊ฐ€๊ณ  ์žˆ๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

$ ps
  PID TTY           TIME CMD
43259 ttys000    0:02.57 -zsh
43304 ttys000    0:00.01 -zsh
43311 ttys000    0:01.86 /Users/oneonlee/.cache/gitstatus/gitstatusd-darwin-x86
60796 ttys000    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS
60812 ttys000    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-03-13 แ„‹แ…ฉแ„’แ…ฎ 5 15 18

pwd

pwd๋Š” Present Working Directory์˜ ์ค„์ž„๋ง๋กœ์„œ, ํ˜„์žฌ directory๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

image

rm

rm ๋ช…๋ น์–ด๋Š” โ€œremoveโ€์˜ ์ค„์ž„๋ง๋กœ์„œ, ํŒŒ์ผ์„ ์‚ญ์ œํ•˜๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

stat

stat ๋ช…๋ น์–ด๋Š” ํŒŒ์ผ ๋˜๋Š” ํŒŒ์ผ์‹œ์Šคํ…œ ์ƒํƒœ๋ฅผ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋Š” ๋ช…๋ น์–ด๋กœ, ํŒŒ์ผํฌ๊ธฐ, Inode ๋ฒˆํ˜ธ, ๋งํฌ ์ˆ˜, ํผ๋ฏธ์…˜, UID, GID, ์ ‘๊ทผ/์ˆ˜์ •/๋ณ€๊ฒฝ ์ผ์‹œ ๋“ฑ์„ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

image

tail

tail ๋ช…๋ น์–ด๋Š” ๋ฌธ์„œ ํŒŒ์ผ์ด๋‚˜ ์ง€์ •๋œ ๋ฐ์ดํ„ฐ์˜ ๋งˆ์ง€๋ง‰ ๋ช‡ ์ค„์„ ๋ณด์—ฌ์ฃผ๋Š” ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด์ด๋‹ค.

tail ํŒŒ์ผ๋ช…์„ ์‚ฌ์šฉํ•˜๋ฉด ํŒŒ์ผ์˜ ๋๋ถ€๋ถ„ 10๊ฐœํ–‰์„ ๋ณด์—ฌ์ค€๋‹ค.
tail ํŒŒ์ผ๋ช… -n์ˆซ์ž๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ˆซ์ž๋งŒํผ ํŒŒ์ผ์˜ ๋๋ถ€๋ถ„ ํ–‰์„ ๋ณด์—ฌ์ค€๋‹ค.

image

time

time ๋ช…๋ น์–ด๋Š” ๋ช…๋ น์–ด ์ˆ˜ํ–‰ ์‹œ๊ฐ„ ์ธก์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด์ด๋‹ค.

image

touchโ€ƒ

touch ๋ช…๋ น์–ด๋Š” ํŒŒ์ผ์˜ ํƒ€์ž„์Šคํƒฌํ”„๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด์ด๋‹ค.

image

tty

tty ๋ช…๋ น์–ด๋Š” TeleTYpewriter (ํ…”๋ ˆํƒ€์ดํ”„๋ผ์ดํ„ฐ; ์›๊ฒฉํƒ€์ž๊ธฐ)์˜ ์ค„์ž„๋ง๋กœ์„œ, ํ„ฐ๋ฏธ๋„ ์ด๋ฆ„์„ ์ถœ๋ ฅํ•˜๋Š” ๋ฆฌ๋ˆ…์Šค์ด๋‹ค.

image

uname

โ€˜UNIX Nameโ€™์˜ ์ค„์ž„๋ง๋กœ, ์šด์˜์ฒด์ œ (operating system)์˜ ์ •๋ณด๋ฅผ ๋ณด์—ฌ์ค€๋‹ค.

์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ ์˜ต์…˜ : uname [-amnprsv]

$ uname -s
Darwin

whereisโ€ƒ

whereis ๋ช…๋ น์–ด๋Š” ๋ช…๋ น์–ด์— ๋Œ€ํ•œ ๋ฐ”์ด๋„ˆ๋ฆฌ, ์†Œ์Šค, ๋งค๋‰ด์–ผ ํŽ˜์ด์ง€์˜ ์œ„์น˜๋ฅผ ์•Œ๋ ค์ฃผ๋Š” ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด์ด๋‹ค.

$ whereis head
/usr/bin/head
$ whereis whereis
/usr/bin/whereis
$ whereis kill
/bin/kill

which

which ๋ช…๋ น์–ด๋Š” ์‹คํ–‰ํŒŒ์ผ์˜ ์ •ํ™•ํ•œ ์œ„์น˜๋ฅผ ์ฐพ๋Š” ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด์ด๋‹ค. โ€˜aliasโ€™๊ฐ€ ์žˆ์œผ๋ฉด ๋จผ์ € ๋ณด์—ฌ์ค€๋‹ค.
(โ€˜aliasโ€™๋Š” ๋ณ„์นญ์ด๋ผ๋Š” ๋œป์œผ๋กœ ๋ฆฌ๋ˆ…์Šค์—์„œ โ€˜aliasโ€™๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ๋ช…๋ น์–ด๋ฅผ ๋‹ค๋ฅธ ์ด๋ฆ„์œผ๋กœ ๋ฐ”๊ฟ”์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์‰˜ ๋‚ด๋ถ€ ๋ช…๋ น์–ด๋ฅผ ๋งํ•œ๋‹ค.)

$ which kill
kill: shell built-in command
$ which cat
/bin/cat
$ which ls
ls: aliased to ls -G
$ which which
which: shell built-in command
$ which whereis
/usr/bin/whereis

whoami

whoami ๋ช…๋ น์–ด๋Š” ์‚ฌ์šฉ์ž๋ช…์„ ์กฐํšŒํ•˜๋Š” ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด์ด๋‹ค.

$ whoami
oneonlee

xxd

ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ 16์ง„์ˆ˜(hexadecimal numbers)๋กœ ๋ณด์—ฌ์ค€๋‹ค.

$ xxd f1
00000000: 6865 6c6c 6f0a                           hello.