<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="https://publishpress.com/"
	>

<channel>
	<title>Linux command Archives - 아빠프로그래머의 좌충우돌 개발하기!</title>
	<atom:link href="https://www.daddyprogrammer.org/post/tag/linux-command/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.daddyprogrammer.org/post/tag/linux-command/</link>
	<description>기저귀 갈면서 코딩해야 프로다!</description>
	<lastBuildDate>Thu, 17 Feb 2022 09:54:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>

<image>
	<url>https://www.daddyprogrammer.org/wp-content/uploads/2019/04/cropped-spring-bird-2295431_960_720-300x300.jpg</url>
	<title>Linux command Archives - 아빠프로그래머의 좌충우돌 개발하기!</title>
	<link>https://www.daddyprogrammer.org/post/tag/linux-command/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Linux Command &#8211; touch, mkdir, rm, cp, mv, du, df</title>
		<link>https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/</link>
					<comments>https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/#comments</comments>
		
		<dc:creator><![CDATA[happydaddy]]></dc:creator>
		<pubDate>Sun, 21 Apr 2019 14:26:21 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux command]]></category>
		<guid isPermaLink="false">http://3.36.120.4/?p=1187</guid>

					<description><![CDATA[<p>touch &#8211; 빈 파일 생성 mkdir &#8211; 디렉터리 생성 rm &#8211; 파일 삭제 rm &#8211; 확인 없이 파일 삭제 rm &#8211; 확인 없이 디렉터리 삭제. rm &#8211; 디렉터리 하위의 mov 확장자 파일을 모두 삭제 cp &#8211; 파일 복사 cp &#8211; 디렉터리 하위의 모든 파일과 디렉터리를 다른 디렉터리로 복사 mv &#8211; 파일을 이동 mv &#8211; 파일명 [&#8230;]</p>
<p>The post <a href="https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/">Linux Command &#8211; touch, mkdir, rm, cp, mv, du, df</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">touch &#8211; 빈 파일 생성</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) touch hello.txt</pre>



<h3 class="wp-block-heading">mkdir &#8211; 디렉터리 생성</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) mkdir hellodir</pre>



<h3 class="wp-block-heading">rm &#8211; 파일 삭제</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) rm hello.txt</pre>



<h3 class="wp-block-heading">rm &#8211; 확인 없이 파일 삭제</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) rm -f hello.txt</pre>



<h3 class="wp-block-heading">rm &#8211; 확인 없이 디렉터리 삭제.</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) rm -rf hellodir</pre>



<h3 class="wp-block-heading">rm &#8211; 디렉터리 하위의 mov 확장자 파일을 모두 삭제</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) rm /hello/*.mov</pre>



<h3 class="wp-block-heading">cp &#8211; 파일 복사</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) cp hello.txt hello2.txt</pre>



<h3 class="wp-block-heading">cp &#8211; 디렉터리 하위의 모든 파일과 디렉터리를 다른 디렉터리로 복사</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) cp -R /hello /hello2</pre>



<h3 class="wp-block-heading">mv &#8211; 파일을 이동</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) mv hello.txt /hi/hello.txt</pre>



<h3 class="wp-block-heading">mv &#8211; 파일명 변경. 같은 디렉터리 내에서 없는 커맨드를 호출하면 이름이 변경된다.</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) mv hello.txt hello2.txt</pre>



<h3 class="wp-block-heading">mv &#8211; 디렉토리 이동/복사. hellodir2가 존재하면 하위로 hellodir이 이동되고 없으면 hellodir의 이름이 hellodir2로 이름이 변경된다.</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) mv /ubuntu/hellodir /ubuntu/hellodir2</pre>



<h3 class="wp-block-heading">du &#8211; 디렉토리내 파일, 디렉터리들의 용량 확인(disk usage)</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ du
44	./deps/hiredis/adapters
40	./deps/hiredis/examples
1304	./deps/hiredis
368	./deps/jemalloc/bin
88	./deps/jemalloc/build-aux
324	./deps/jemalloc/doc
684	./deps/jemalloc/include/jemalloc/internal
768	./deps/jemalloc/include/jemalloc
12	./deps/jemalloc/include/msvc_compat/C99
20	./deps/jemalloc/include/msvc_compat
788	./deps/jemalloc/include
16	./deps/jemalloc/m4
24	./deps/jemalloc/msvc/projects/vc2015/jemalloc</pre>



<h3 class="wp-block-heading">du &#8211; 해당 디렉터리 용량 확인</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ du -hs redis-5.0.4
115M	redis-5.0.4</pre>



<h3 class="wp-block-heading">du &#8211; 현재 디렉터리에 있는 디렉터리 및 파일 용량 확인</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ du -hs *
100K	00-RELEASENOTES
8.0K	MANIFESTO
4.0K	Makefile
24K	README.md
61M	deps
64K	redis.conf
4.0K	runtest-sentinel
12K	sentinel.conf
53M	src
796K	tests
160K	utils</pre>



<h3 class="wp-block-heading">du &#8211; 현재 디렉터리에 있는 디렉터리 및 파일 중에서 용량이 큰것순으로 5개 보기</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ du -hsx * | sort -rh | head -n 5
61M	deps
53M	src
796K	tests
160K	utils
100K	00-RELEASENOTES</pre>



<h3 class="wp-block-heading">df &#8211; 리눅스 디스크 사용량 확인</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs          485712       0    485712   0% /dev
tmpfs             503624       0    503624   0% /dev/shm
tmpfs             503624     492    503132   1% /run
tmpfs             503624       0    503624   0% /sys/fs/cgroup
/dev/xvda1       8376300 5294644   3081656  64% /
tmpfs             100728       0    100728   0% /run/user/1000</pre>



<h3 class="wp-block-heading">df &#8211; 읽기 쉽게 보기</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        475M     0  475M   0% /dev
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           492M  492K  492M   1% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/xvda1      8.0G  5.1G  3.0G  64% /
tmpfs            99M     0   99M   0% /run/user/1000</pre>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/">Linux Command &#8211; touch, mkdir, rm, cp, mv, du, df</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<series:name><![CDATA[Linux command 알아보기]]></series:name>
	</item>
		<item>
		<title>Linux Command &#8211; cd, dirname, basename, id, uname, cpuinfo, meminfo, locale, ps, kill, top</title>
		<link>https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/</link>
					<comments>https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/#comments</comments>
		
		<dc:creator><![CDATA[happydaddy]]></dc:creator>
		<pubDate>Sun, 21 Apr 2019 13:41:16 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux command]]></category>
		<guid isPermaLink="false">http://3.36.120.4/?p=1180</guid>

					<description><![CDATA[<p>커서 이동 맨앞으로 : Ctrl+a, 맨뒤로 : Crtl+e pwd : 현재 디렉터리 확인 cd : 디렉터리 이동 dirname : 디렉터리 이름 구하기 basename : 파일 이름 구하기 id : 현재 로그인한 id 정보를 확인 uname -a : 서버의 OS 정보를 출력 cat /proc/cpuinfo : 서버의 CPU 정보를 출력 cat /proc/meminfo : 서버의 Memory 정보를 출력 [&#8230;]</p>
<p>The post <a href="https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/">Linux Command &#8211; cd, dirname, basename, id, uname, cpuinfo, meminfo, locale, ps, kill, top</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="mce_0"> 커서 이동 </h2>



<p class="wp-block-paragraph"> 맨앞으로 : <strong>Ctrl+a</strong>, 맨뒤로 : <strong>Crtl+e</strong></p>



<h2 class="wp-block-heading" id="mce_2">pwd :  현재 디렉터리 확인 </h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ pwd
/home/ubuntu</pre>



<h2 class="wp-block-heading">cd : 디렉터리 이동</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 계정의 home 디렉터리로 이동
$) cd or cd ~
# 루트 디렉터리로 이동
$) cd /
# 이전 디렉터리로 이동
$) cd -
# 상위 디렉터리로 이동
$) cd ..
# hellodir 디렉터리로 이동
$) cd /hellodir</pre>



<h2 class="wp-block-heading">dirname : 디렉터리 이름 구하기</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ dirname /var/log/nginx/access.log
/var/log/nginx</pre>



<h2 class="wp-block-heading">basename : 파일 이름 구하기</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ basename /var/log/nginx/access.log
access.log
$ basename /var/log/nginx/access.log .log
access</pre>



<h2 class="wp-block-heading" id="mce_3">id : 현재 로그인한 id 정보를 확인</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ id
uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),110(lxd)</pre>



<h2 class="wp-block-heading" id="mce_4">uname -a : 서버의 OS 정보를 출력</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ uname -a
Linux ip-172-26-11-44 4.4.0-1079-aws #89-Ubuntu SMP Tue Mar 26 15:25:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux</pre>



<h2 class="wp-block-heading">cat /proc/cpuinfo : 서버의 CPU 정보를 출력</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 63
model name      : Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
stepping        : 2
microcode       : 0x41
cpu MHz         : 2400.072
cache size      : 30720 KB</pre>



<h2 class="wp-block-heading" id="mce_2">cat /proc/meminfo : 서버의 Memory 정보를 출력</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cat /proc/meminfo
MemTotal:         498372 kB
MemFree:           17220 kB
MemAvailable:      90228 kB
Buffers:           21324 kB
Cached:           150520 kB
SwapCached:            0 kB
Active:           388416 kB
Inactive:          27688 kB
Active(anon):     344528 kB
Inactive(anon):     6176 kB
Active(file):      43888 kB
Inactive(file):    21512 kB</pre>



<h2 class="wp-block-heading">locale : 지역 정보 조회</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"</pre>



<h2 class="wp-block-heading">ps &#8211; 실행중인 프로세스 목록 조회</h2>



<h3 class="wp-block-heading">옵션</h3>



<figure class="wp-block-table"><table><tbody><tr><td>옵션</td><td>내용</td></tr><tr><td><strong>-a</strong></td><td>전체사용자 프로세스 출력</td></tr><tr><td><strong>-e</strong></td><td>모든 프로세스 상태 출력</td></tr><tr><td><strong>-r</strong></td><td>실행중인 프로세스 상태 출력</td></tr><tr><td><strong>-u</strong></td><td>각 프로세스 사용자 및 사용시간 출력</td></tr><tr><td><strong>-x</strong></td><td>제어 터미널이 없는 프로세스 출력</td></tr><tr><td><strong>-l</strong></td><td>긴 포맷(자세한 내용)으로 표시</td></tr><tr><td><strong>-f</strong></td><td>풀 포맷(모든 컬럼내용)으로 표시<br></td></tr></tbody></table></figure>



<h3 class="wp-block-heading">필드별 항목</h3>



<ul class="wp-block-list"><li><strong>USER </strong>&#8211; 프로세스 사용자</li><li><strong>PID </strong>&#8211; 프로세스 ID</li><li><strong>PPID </strong>&#8211; 부모 프로세스 ID</li><li><strong>%CPU</strong> &#8211; CPU 사용률</li><li><strong>%MEM</strong> &#8211; 메모리 사용률</li><li><strong>VSZ </strong>&#8211; 가상 메모리 사용량</li><li><strong>RSS </strong>&#8211; 실제 메모리 사용량</li><li><strong>TTY </strong>&#8211; Teletype. 프로세스가 수행되고 있는 제어 터미널. &#8216;?&#8217;는 제어 터미널에 연결되어있지 않음을 나타냄</li><li><strong>STAT </strong>&#8211; 프로세스 상태( R : 실행 또는 실행대 / S : 수면 / I : 휴식 / T : 정지 / Z : 좀비프로세스 / D : 디스크 대기)</li><li><strong>START, TIME</strong> &#8211; 프로세스가 시작된 시간</li><li><strong>CMD</strong>(Command) &#8211; 실행된 프로세스명</li></ul>



<h3 class="wp-block-heading">ps -ef</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Apr07 ?        00:00:50 /lib/systemd/systemd --system --deserialize 25
root         2     0  0 Apr07 ?        00:00:00 [kthreadd]
root         3     2  0 Apr07 ?        00:00:08 [ksoftirqd/0]
root         5     2  0 Apr07 ?        00:00:00 [kworker/0:0H]
root         7     2  0 Apr07 ?        00:00:09 [rcu_sched]
root         8     2  0 Apr07 ?        00:00:00 [rcu_bh]
root         9     2  0 Apr07 ?        00:00:00 [migration/0]
root        10     2  0 Apr07 ?        00:00:07 [watchdog/0]
root        11     2  0 Apr07 ?        00:00:00 [kdevtmpfs]
root        12     2  0 Apr07 ?        00:00:00 [netns]
root        13     2  0 Apr07 ?        00:00:00 [perf]</pre>



<h3 class="wp-block-heading">ps -aux</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ps -aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  1.0 185332  5076 ?        Ss   Apr07   0:50 /lib/systemd/systemd --system --de
root         2  0.0  0.0      0     0 ?        S    Apr07   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Apr07   0:08 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S&lt;   Apr07   0:00 [kworker/0:0H]
root         7  0.0  0.0      0     0 ?        S    Apr07   0:09 [rcu_sched]
root         8  0.0  0.0      0     0 ?        S    Apr07   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        S    Apr07   0:00 [migration/0]
root        10  0.0  0.0      0     0 ?        S    Apr07   0:07 [watchdog/0]
root        11  0.0  0.0      0     0 ?        S    Apr07   0:00 [kdevtmpfs]</pre>



<h3 class="wp-block-heading">프로세스 명으로 PID 알아내기</h3>



<p class="wp-block-paragraph">ps -ef | grep 프로세스명 | grep -v grep</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ps -ef | grep httpd | grep -v grep
root     23969     1  0 Apr20 ?        00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 23970 23969  0 Apr20 ?        00:00:37 nginx: worker process</pre>



<h3 class="wp-block-heading">프로세스 cpu 사용률 확인</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ps -C nginx -o user,pid,pcpu,pmem,vsize,size,etime,comm
USER       PID %CPU %MEM    VSZ  SIZE     ELAPSED COMMAND
root     23969  0.0  0.3 179612  2076  7-20:54:40 nginx
www-data 23970  0.0  1.3 180596  3060  7-20:54:40 nginx</pre>



<h3 class="wp-block-heading"><strong>PID로 프로세스 이름 알아내기</strong></h3>



<p class="wp-block-paragraph">cat /proc/프로세스아이디/status | grep Name</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cat /proc/23969/status | grep Name
Name:   nginx</pre>



<h2 class="wp-block-heading">kill &#8211; 프로세스 종료</h2>



<h3 class="wp-block-heading">시그널 종류</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ kill -l
1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR
31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX</pre>



<p class="wp-block-paragraph"><strong>kill -15 pid</strong> : Terminate의 약자로 정상 종료 시그널 요청<br><strong>kill -9 pid</strong> : 강제 종료 요청. kill -15로 몇번해도 죽지 않는 경우 사용.<br><strong>kill -1 pid</strong> : 해당 pid 프로세스를 재시작.</p>



<h2 class="wp-block-heading">top &#8211;  프로세스 목록을 CPU 사용률이 높은 것부터 출력</h2>



<h3 class="wp-block-heading">필드별 항목</h3>



<ul class="wp-block-list"><li><strong>PID </strong>: 프로세스 ID (PID)&nbsp; &nbsp; </li><li><strong>USER </strong>: 프로세스를 실행시킨 사용자 ID</li><li><strong>PRI </strong>: 프로세스의 우선순위 (priority)</li><li><strong>NI </strong>: NICE 값. 일의 nice value값이다. 마이너스를 가지는 nice value는 우선순위가 높음.</li><li><strong>VIRT </strong>: 가상 메모리의 사용량(SWAP+RES)</li><li><strong>RES </strong>: 현재 페이지가 상주하고 있는 크기(Resident Size)</li><li><strong>SHR </strong>: 분할된 페이지, 프로세스에 의해 사용된 메모리를 나눈 메모리의 총합.</li><li><strong>S</strong> : 프로세스의 상태 [ S(sleeping), R(running), W(swapped out process), Z(zombies) ]</li><li><strong>%CPU</strong> : 프로세스가 사용하는 CPU의 사용율</li><li><strong>%MEM</strong> : 프로세스가 사용하는 메모리의 사용율</li><li><strong>TIME+</strong> : 프로세스 시작된 이후 경과된 총 시간</li><li><strong>COMMAND </strong>: 실행된 명령어</li><li><strong>Load average</strong> (로드 애버리지) : 세 개의 숫자는 각각 1분, 5분, 15분 간의 평균 실행/대기 중인 프로세스의 수를 나타냄. uptime 명령어로도 확인할 수 있으며, 시스템 부하를 모니터링 할 수 있다. 숫자가 높을 수록 시스템에 부하가 있다는 것이다. load average 값은 CPU의 코어 수를 같이 확인해야 하며, 코어 수 보다 적으면 문제가 없다. </li></ul>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ top
top - 13:53:04 up 20 days, 13:54,  1 user,  load average: 0.00, 0.00, 0.00
Tasks: 110 total,   1 running, 109 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.2 us,  0.0 sy,  0.0 ni, 99.6 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   498372 total,    13396 free,   237284 used,   247692 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   157444 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    1 root      20   0  185332   5072   3188 S  0.0  1.0   0:50.83 systemd
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd
    3 root      20   0       0      0      0 S  0.0  0.0   0:08.18 ksoftirqd/0
    5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
    7 root      20   0       0      0      0 S  0.0  0.0   0:09.68 rcu_sched
    8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh
    9 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0
   10 root      rt   0       0      0      0 S  0.0  0.0   0:07.47 watchdog/0
   11 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kdevtmpfs</pre>



<h3 class="wp-block-heading">top 실행후 옵션</h3>



<ul class="wp-block-list"><li><strong>shift + t</strong> : 실행된 시간이 큰 순서로 정렬</li><li><strong>shift + m</strong> : 메모리 사용량이 큰 순서로 정렬</li><li><strong>shift + p</strong> : cpu 사용량이 큰 순서로 정렬</li><li><strong>shift + b</strong> : 상단의 uptime 및 기타 정보값을 블럭 선택해 표시 </li><li><strong>k</strong> : Process 종료&nbsp; &#8211; k 입력 후 종료할 PID를 입력하고 signal을 입력하라 표시되면 9를 넣어준다.</li><li><strong>c</strong>&nbsp; : 명령 인자 표시 / 비표시</li><li><strong>l</strong> : uptime line(첫번째 행)을 표시 / 비표시</li><li><strong>space bar</strong> : Refresh</li><li><strong>u</strong> : 입력한 유저 소유의 Process만 표시 .which user유저를 입력하라 표시될때 User를 입력. blank(공백) 입력시 모두 표시</li><li><strong>f&nbsp;</strong> : 화면에 표시될 프로세스 관련 항목 설정</li><li><strong>i </strong>: idle 또는 좀비 상태의 프로세스는 표시 되지 않음</li><li><strong>z</strong> : 출력 색상 변경</li><li><strong>d</strong> [sec] : 설정된 초단위로 Refresh</li><li><strong>c&nbsp;</strong> : command뒤에 인자값 표시</li><li><strong>q</strong> : top 종료</li></ul>
<p>The post <a href="https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/">Linux Command &#8211; cd, dirname, basename, id, uname, cpuinfo, meminfo, locale, ps, kill, top</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<series:name><![CDATA[Linux command 알아보기]]></series:name>
	</item>
	</channel>
</rss>
