<?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/"
	>

<channel>
	<title>공부 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/tag/%EA%B3%B5%EB%B6%80/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Tue, 12 May 2026 22:30:47 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://lycos7560.com/wp-content/uploads/2022/11/cropped-cropped-cropped-log-1-150x150-1-80x80.png</url>
	<title>공부 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>POSIX Shell: 환경변수(Environment Variable)</title>
		<link>https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/</link>
					<comments>https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 22:15:59 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40632</guid>

					<description><![CDATA[<p>환경변수는 시스템의 설정값이나 실행 경로 등, 운영체제 전반에 걸쳐 공유되어야 하는 정보를 담고 있습니다. 일반 변수 vs 환경 변수 가장 큰 차이점은 &#8216;전파(Inheritance)&#8217;입니다. export 명령어: 환경변수 만들기 일반 변수를 환경변수로 승격시킬 때 export를 사용합니다. 주요 표준 환경변수 POSIX 시스템(Linux, AIX 등)에서 미리 정의되어 자주 쓰이는 변수들입니다. 변수명 설명 $PATH 명령어를 찾을 디렉토리 경로 목록 (콜론 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/">POSIX Shell: 환경변수(Environment Variable)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-59c788c2      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#일반-변수-vs-환경-변수" class="uagb-toc-link__trigger">일반 변수 vs 환경 변수</a><li class="uagb-toc__list"><a href="#export-명령어-환경변수-만들기" class="uagb-toc-link__trigger">export 명령어: 환경변수 만들기</a><li class="uagb-toc__list"><a href="#주요-표준-환경변수" class="uagb-toc-link__trigger">주요 표준 환경변수</a><li class="uagb-toc__list"><a href="#실전-예제-path-변수-조작하기" class="uagb-toc-link__trigger">실전 예제: PATH 변수 조작하기</a><li class="uagb-toc__list"><a href="#환경변수-확인법" class="uagb-toc-link__trigger">환경변수 확인법</a><li class="uagb-toc__list"><a href="#주의사항-변수의-수명" class="uagb-toc-link__trigger">주의사항: 변수의 수명</a><li class="uagb-toc__list"><a href="#환경에-따른-분기-case문-결합" class="uagb-toc-link__trigger">환경에 따른 분기 (case문 결합)</a><li class="uagb-toc__list"><a href="#자식에서-export로-변경하면-부모도-영향을-받나" class="uagb-toc-link__trigger">자식에서 export로 변경하면 부모도 영향을 받나?</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#왜-부모는-영향을-받지-않나" class="uagb-toc-link__trigger">왜 부모는 영향을 받지 않나?</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#예시-코드로-확인하기" class="uagb-toc-link__trigger">예시 코드로 확인하기</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#자식이-부모의-환경을-바꾸고-싶을-땐" class="uagb-toc-link__trigger">자식이 부모의 환경을 바꾸고 싶을 땐?</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>환경변수는 시스템의 설정값이나 실행 경로 등, 운영체제 전반에 걸쳐 공유되어야 하는 정보를 담고 있습니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">일반 변수 vs 환경 변수</h2>



<p>가장 큰 차이점은 &#8216;전파(Inheritance)&#8217;입니다.</p>



<ul class="wp-block-list">
<li><strong>일반 변수 (Local Variable):</strong> 현재 실행 중인 스크립트 내에서만 유효합니다.</li>



<li><strong>환경 변수 (Environment Variable):</strong> <code>export</code> 명령어를 통해 시스템의 &#8216;환경&#8217;으로 등록되어, 해당 쉘에서 실행하는 다른 스크립트나 프로그램에서도 읽을 수 있습니다.</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">export 명령어: 환경변수 만들기</h2>



<p>일반 변수를 환경변수로 승격시킬 때 <code>export</code>를 사용합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 1. 선언과 동시에 export (가장 많이 쓰임)
export MY_APP_HOME="/usr/local/engcross"

# 2. 이미 있는 변수를 export
VERSION="2.1.0"
export VERSION</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">주요 표준 환경변수</h2>



<p>POSIX 시스템(Linux, AIX 등)에서 미리 정의되어 자주 쓰이는 변수들입니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>변수명</strong></td><td><strong>설명</strong></td></tr></thead><tbody><tr><td><strong><code>$PATH</code></strong></td><td>명령어를 찾을 디렉토리 경로 목록 (콜론 <code>:</code>으로 구분)</td></tr><tr><td><strong><code>$HOME</code></strong></td><td>현재 사용자의 홈 디렉토리 경로</td></tr><tr><td><strong><code>$USER</code></strong></td><td>현재 접속한 사용자 이름</td></tr><tr><td><strong><code>$PWD</code></strong></td><td>현재 작업 디렉토리 (Print Working Directory)</td></tr><tr><td><strong><code>$LANG</code></strong></td><td>시스템 언어 및 인코딩 (예: <code>ko_KR.UTF-8</code>)</td></tr><tr><td><strong><code>$SHELL</code></strong></td><td>현재 사용 중인 쉘의 경로</td></tr></tbody></table></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">실전 예제: PATH 변수 조작하기</h2>



<p>내가 만든 스크립트를 어디서든 파일명만 입력해서 실행하고 싶을 때 <code>$PATH</code>를 수정합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

# 현재 PATH 끝에 내 스크립트 폴더 추가
export PATH="$PATH:/home/lycos7560/bin"

# 이제 /home/lycos7560/bin 안에 있는 파일들은 
# 절대 경로 없이 이름만으로 실행 가능합니다.</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">환경변수 확인법</h2>



<ul class="wp-block-list">
<li><code>env</code>: 현재 설정된 모든 환경변수 목록 출력</li>



<li><code>printenv PATH</code>: 특정 환경변수(<code>PATH</code>)의 값만 출력</li>



<li><code>set</code>: 환경변수뿐만 아니라 일반 변수, 함수까지 모두 포함해서 출력</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">주의사항: 변수의 수명</h2>



<p>스크립트 내부에서 <code>export</code>한 변수는 <strong>그 스크립트가 종료되면 사라집니다.</strong></p>



<ul class="wp-block-list">
<li><strong>부모 쉘(터미널)에 적용하고 싶다면?</strong></li>
</ul>



<p>스크립트를 실행할 때 <code>./script.sh</code>가 아닌 <code>source ./script.sh</code> 또는 <code>. ./script.sh</code>를 사용해야 합니다. (이를 <strong>Sourcing</strong>이라고 합니다.)</p>



<ul class="wp-block-list">
<li><strong>영구히 적용하고 싶다면?</strong></li>
</ul>



<p>사용자의 홈 디렉토리에 있는 <code>.profile</code> (또는 <code>.bash_profile</code>) 파일에 <code>export</code> 구문을 적어두어야 로그인할 때마다 로드됩니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">## parent.sh
#!/bin/sh
VAR1="Local"      # 일반 변수
export VAR2="Env" # 환경 변수

./child.sh        # 자식 프로세스 실행

## child.sh
#!/bin/sh
printf "VAR1: %s\n" "$VAR1" # 아무것도 안 나옴 (상속 안 됨)
printf "VAR2: %s\n" "$VAR2" # "Env" 출력 (상속 됨)

[결과]
$ ./parent.sh
VAR1: 
VAR2: Env

추가적으로 중요한 점은 자식이 가방(환경변수) 속 내용을 수정하거나 새 물건을 넣어도, 그 결과가 부모에게 돌아오지 않는다는 것입니다. 
자식이 종료되면 자식이 가졌던 가방 복사본은 그대로 파기되기 때문입니다.</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">환경에 따른 분기 (case문 결합)</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

# 실행 환경(USER)에 따라 다른 설정 적용
case "$USER" in
    root)
        export LOG_LEVEL="DEBUG"
        export APP_PATH="/opt/app"
        ;;
    lycos7560)
        export LOG_LEVEL="INFO"
        export APP_PATH="/home/lycos7560/app"
        ;;
    *)
        printf "허용되지 않은 사용자입니다.\n"
        exit 1
        ;;
esac

printf "사용자: %s, 로그레벨: %s\n" "$USER" "$LOG_LEVEL"</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>환경변수는 스크립트가 외부 세계와 소통하는 통로입니다. </p>



<p><code>export</code>를 통해 내가 만든 설정값을 하위 프로그램에 전달하고, <code>$PATH</code>나 <code>$USER</code> 같은 시스템 변수를 이용해 상황에 맞는 유연한 스크립트를 작성해 보세요!</p>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">자식에서 export로 변경하면 부모도 영향을 받나?</h2>



<p><strong>아니요. 부모는 전혀 영향을 받지 않습니다.</strong></p>



<p>이것은 쉘 스크립트 시스템의 아주 중요한 철칙인 <strong>&#8216;일방통행 상속&#8217;</strong> 때문입니다.</p>



<h3 class="wp-block-heading">왜 부모는 영향을 받지 않나?</h3>



<p>부모가 자식 프로세스를 만들 때, 부모의 환경변수를 그대로 주는 게 아니라 &#8216;복사본&#8217;을 복사해서 넘겨주기 때문입니다.</p>



<p>자식이 자기 손에 든 복사본 가방 안의 내용을 아무리 고치고 <code>export</code>를 다시 해도, 그것은 <strong>자신의 가방(자식 프로세스의 메모리)</strong> 내에서의 일일 뿐입니다. </p>



<p>부모의 가방(부모 프로세스의 메모리)은 멀리 떨어져서 보호받고 있습니다.</p>



<h3 class="wp-block-heading">예시 코드로 확인하기</h3>



<p>child.sh</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
export MY_VAL="Changed by Child"
printf "자식: 값을 변경했습니다 -> %s\n" "$MY_VAL"</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<p>parent.sh</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
export MY_VAL="Original Parent Value"

printf "부모: 실행 전 값 -> %s\n" "$MY_VAL"

# 자식 스크립트 실행
./child.sh

printf "부모: 자식 종료 후 값 -> %s\n" "$MY_VAL"</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<p>실행 결과:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">부모: 실행 전 값 -> Original Parent Value
자식: 값을 변경했습니다 -> Changed by Child
부모: 자식 종료 후 값 -> Original Parent Value</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">자식이 부모의 환경을 바꾸고 싶을 땐?</h3>



<p>자식 프로세스를 &#8216;별도로&#8217; 띄우지 않고, <strong>부모의 몸 안에서 직접 실행</strong>하게 하면 됩니다. </p>



<p>이것을 <strong>Sourcing(소싱</strong>)이라고 합니다.</p>



<ul class="wp-block-list">
<li><strong>일반 실행 (<code>./child.sh</code>):</strong> 새로운 자식 쉘을 생성 (부모 영향 X)</li>



<li><strong>소싱 실행 (<code>. ./child.sh</code>):</strong> 현재 부모 쉘에서 코드를 그대로 읽어서 실행 (부모 영향 O)</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>이 개념은 보안과 안정성을 위한 개념입니다.</p>



<p>자식 프로그램이 멋대로 부모 시스템의 설정을 변경하면 문제가 되기 때문이죠.</p>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/">POSIX Shell: 환경변수(Environment Variable)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: case 문</title>
		<link>https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/</link>
					<comments>https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 22:07:50 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40629</guid>

					<description><![CDATA[<p>if 문이 &#8220;예/아니오&#8221;라는 논리적 판단에 강하다면, case 문은 &#8220;이 값은 어디에 해당하나?&#8221;라는 패턴 매칭에 최적화되어 있습니다. 코드의 가독성을 높여주는 case 문의 모든 것을 알아봅니다. 기본 구조 case 문은 변수의 값을 여러 패턴과 비교하며, 처음으로 일치하는 블록을 실행합니다. 활용 가능한 패턴 종류 POSIX 표준에서 지원하는 패턴들입니다. 정규표현식과는 조금 다르니 주의하세요! 예제 ① 스크립트 인자(Argument) 처리 : [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/">POSIX Shell: case 문</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-66d4106a      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#기본-구조" class="uagb-toc-link__trigger">기본 구조</a><li class="uagb-toc__list"><a href="#활용-가능한-패턴-종류" class="uagb-toc-link__trigger">활용 가능한 패턴 종류</a><li class="uagb-toc__list"><a href="#예제" class="uagb-toc-link__trigger">예제</a><li class="uagb-toc__list"><a href="#사용자-입력yn-대소문자-무시하기" class="uagb-toc-link__trigger">사용자 입력(y/n) 대소문자 무시하기</a><li class="uagb-toc__list"><a href="#고급-bash-전용-기능-주의사항" class="uagb-toc-link__trigger">고급: Bash 전용 기능 주의사항</a><li class="uagb-toc__list"><a href="#if-vs-case-언제-무엇을-쓸까" class="uagb-toc-link__trigger">if vs case: 언제 무엇을 쓸까?</a></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p><code>if</code> 문이 &#8220;예/아니오&#8221;라는 논리적 판단에 강하다면, <strong><code>case</code> 문</strong>은 &#8220;이 값은 어디에 해당하나?&#8221;라는 <strong>패턴 매칭</strong>에 최적화되어 있습니다. </p>



<p>코드의 가독성을 높여주는 <code>case</code> 문의 모든 것을 알아봅니다.</p>



<h2 class="wp-block-heading">기본 구조</h2>



<p><code>case</code> 문은 변수의 값을 여러 패턴과 비교하며, 처음으로 일치하는 블록을 실행합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">case "$변수" in
    패턴1)
        명령어
        ;;  # 블록 종료 (C의 break와 유사)
    패턴2|패턴3)
        명령어  # | 로 OR 조건 표현 가능
        ;;
    *)
        명령어  # 일치하는 패턴이 없을 때 (else 역할)
        ;;
esac  # case를 거꾸로 쓴 것</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">활용 가능한 패턴 종류</h2>



<p>POSIX 표준에서 지원하는 패턴들입니다. 정규표현식과는 조금 다르니 주의하세요!</p>



<ul class="wp-block-list">
<li><code>*</code>: 모든 문자열과 일치 (Default 처리용)</li>



<li><code>?</code>: 임의의 문자 <strong>딱 1개</strong>와 일치</li>



<li><code>[abc]</code>: a, b, c 중 하나와 일치</li>



<li><code>[a-z]</code>: 소문자 a부터 z 사이의 문자 하나와 일치</li>



<li><code>pat1|pat2</code>: 패턴1 또는 패턴2 중 하나와 일치 (<strong>OR 조건</strong>)</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제</h2>



<p>① 스크립트 인자(Argument) 처리 : 서비스 관리 스크립트(<code>start</code>, <code>stop</code> 등)를 만들 때 가장 많이 쓰이는 방식입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

ACTION="$1"

case "$ACTION" in
    start)
        printf "서비스를 시작합니다...\n"
        ;;
    stop)
        printf "서비스를 중지합니다...\n"
        ;;
    restart|reload)
        printf "재시작/설정 로드를 수행합니다...\n"
        ;;
    status)
        printf "현재 상태를 확인합니다...\n"
        ;;
    *)
        printf "사용법: %s {start|stop|restart|status}\n" "$0"
        exit 1
        ;;
esac</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>② 파일 확장자별 분기 처리 : <code>${FILE##*.}</code>와 조합하면 매우 강력해집니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

FILE="backup.tar.gz"
EXT="${FILE##*.}"

case "$EXT" in
    gz|tgz)
        printf "Gzip 압축 파일입니다. 해제 명령: tar xzf %s\n" "$FILE"
        ;;
    zip)
        printf "Zip 파일입니다. 해제 명령: unzip %s\n" "$FILE"
        ;;
    log)
        printf "로그 파일입니다. 실시간 모니터링을 시작합니다.\n"
        ;;
    *)
        printf "지원하지 않는 파일 형식입니다: %s\n" "$EXT"
        ;;
esac</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">사용자 입력(y/n) 대소문자 무시하기</h2>



<p>사용자로부터 <code>yes</code>, <code>Yes</code>, <code>YES</code> 등을 한 번에 입력받고 싶을 때 대괄호(<code>[]</code>) 패턴이 유용합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

printf "계속 진행하시겠습니까? [y/n]: "
read ANSWER

case "$ANSWER" in
    [yY]|[yY][eE][sS])
        printf "진행을 결정하셨습니다.\n"
        ;;
    [nN]|[nN][oO])
        printf "작업을 취소합니다.\n"
        exit 0
        ;;
    *)
        printf "잘못된 입력입니다. y 또는 n을 입력해 주세요.\n"
        exit 1
        ;;
esac</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">고급: Bash 전용 기능 주의사항</h2>



<p>Bash 4.0 이상에서는 <code>;</code> 대신 <code>;&amp;</code> (fall-through)나 <code>;;&amp;</code> 등을 사용할 수 있지만, 이는 <strong>POSIX 표준이 아닙니다.</strong></p>



<ul class="wp-block-list">
<li><strong><code>; &amp;</code></strong>: 다음 패턴의 일치 여부와 상관없이 무조건 다음 블록을 실행합니다.</li>



<li><strong><code>;; &amp;</code></strong>: 다음 패턴들을 계속 검사하여 일치하는 것이 있다면 또 실행합니다.</li>
</ul>



<p><strong>POSIX 팁:</strong> 이식성이 중요한 스크립트에서는 오직 <code><strong>;;</strong></code>만 사용하세요. <code><strong>;</strong></code> 하나만 쓰거나 다른 기호를 섞으면 구형 쉘에서 에러가 납니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">if vs case: 언제 무엇을 쓸까?</h2>



<ul class="wp-block-list">
<li><strong><code>if</code> 문이 유리할 때</strong>: 숫자 크기 비교(<code>-gt</code>, <code>-lt</code>), 복잡한 논리 조합(<code>&amp;&amp;</code>, <code>||</code>), 파일 존재 여부 확인 등.</li>



<li><strong><code>case</code> 문이 유리할 때</strong>: 하나의 변수 값이 특정 문자열 패턴 중 무엇인지 분류할 때 (3개 이상의 분기라면 <code>case</code>를 강력 추천).</li>
</ul>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p><code>case</code> 문을 사용하면 스크립트가 훨씬 읽기 쉬워지고 구조가 명확해집니다. </p>



<p>특히 인자 처리나 사용자 응답 처리에서 <code>case</code>를 활용해 보세요. 여러분의 코드가 한층 더 전문가답게 보일 것입니다!</p>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/">POSIX Shell: case 문</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: 변수(Variables) &#038; 문자열(String)</title>
		<link>https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/</link>
					<comments>https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 21:50:52 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40627</guid>

					<description><![CDATA[<p>쉘 스크립트에서 변수는 별도의 선언(형식 지정) 없이 바로 사용할 수 있어 유연하지만, 그만큼 문법이 엄격한 부분도 있습니다. 특히 공백과 따옴표 사용법이 핵심입니다. 변수 선언과 사용 (Variables) Shell 변수는 선언 시 타입을 지정하지 않으며, 공백에 매우 민감합니다. 특수 변수 (Special Variables) 스크립트 실행 시 자동으로 할당되는 예약 변수들입니다. 변수 의미 예시 (./run.sh aix hacmp) $0 스크립트 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/">POSIX Shell: 변수(Variables) &amp; 문자열(String)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-dfed9df5      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#변수-선언과-사용-variables" class="uagb-toc-link__trigger">변수 선언과 사용 (Variables)</a><li class="uagb-toc__list"><a href="#특수-변수-special-variables" class="uagb-toc-link__trigger">특수 변수 (Special Variables)</a><li class="uagb-toc__list"><a href="#기본값-처리-default-values" class="uagb-toc-link__trigger">기본값 처리 (Default Values)</a><li class="uagb-toc__list"><a href="#패턴-제거-pattern-removal" class="uagb-toc-link__trigger">패턴 제거 (Pattern Removal)</a><li class="uagb-toc__list"><a href="#문자열-치환-및-대소문자-변환-bash-확장" class="uagb-toc-link__trigger">문자열 치환 및 대소문자 변환 (Bash 확장)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#문자열-치환" class="uagb-toc-link__trigger">문자열 치환</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#대소문자-변환" class="uagb-toc-link__trigger">대소문자 변환</a></li></ul></li><li class="uagb-toc__list"><a href="#문자열-분리-ifs-활용" class="uagb-toc-link__trigger">문자열 분리 (IFS 활용)</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>쉘 스크립트에서 변수는 별도의 선언(형식 지정) 없이 바로 사용할 수 있어 유연하지만, 그만큼 문법이 엄격한 부분도 있습니다. </p>



<p>특히 <strong>공백</strong>과 <strong>따옴표</strong> 사용법이 핵심입니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">변수 선언과 사용 (Variables)</h2>



<p>Shell 변수는 선언 시 타입을 지정하지 않으며, <strong>공백</strong>에 매우 민감합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 선언: = 앞뒤 공백 금지 (필수!)
NAME="lycos7560" 
COUNT=42 

# 사용: $ 또는 ${}를 사용
echo "$NAME"       # 일반적인 사용
echo "${NAME}"     # 경계를 명확히 할 때 권장
echo "User_${NAME}_log" # 변수명 뒤에 문자가 붙을 때 필수</pre>



<ul class="wp-block-list">
<li><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 주의:</strong> <code>NAME = value</code>처럼 공백을 넣으면 시스템은 <code>NAME</code>을 변수가 아닌 <strong>명령어</strong>로 인식하여 에러(<code>command not found</code>)를 발생시킵니다</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">특수 변수 (Special Variables)</h2>



<p>스크립트 실행 시 자동으로 할당되는 예약 변수들입니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>변수</strong></td><td><strong>의미</strong></td><td><strong>예시 (./run.sh aix hacmp)</strong></td></tr></thead><tbody><tr><td><strong><code>$0</code></strong></td><td>스크립트 이름</td><td><code>./run.sh</code></td></tr><tr><td><strong><code>$1</code> ~ <code>$9</code></strong></td><td>위치 매개변수 (인자)</td><td><code>$1</code>은 <code>aix</code>, <code>$2</code>는 <code>hacmp</code></td></tr><tr><td><strong><code>$#</code></strong></td><td>인자 개수</td><td><code>2</code></td></tr><tr><td><strong><code>$@</code></strong></td><td>모든 인자 (각각 분리)</td><td><code>"aix" "hacmp"</code></td></tr><tr><td><strong><code>$?</code></strong></td><td>마지막 명령어 종료 코드</td><td><code>0</code>(성공) 또는 <code>1~255</code>(실패)</td></tr><tr><td><strong><code>$$</code></strong></td><td>현재 프로세스 PID</td><td><code>1234</code></td></tr></tbody></table></figure>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">기본값 처리 (Default Values)</h2>



<p>변수가 비어있을 때를 대비한 방어적 코딩 기법입니다.</p>



<ul class="wp-block-list">
<li><strong><code>${VAR:-default}</code></strong>: <code>VAR</code>이 비어있으면 <code>default</code>를 사용 (변수 값은 유지)</li>



<li><strong><code>${VAR:=default}</code></strong>: <code>VAR</code>이 비어있으면 <code>default</code>를 <strong>변수에 대입</strong></li>



<li><strong><code>${VAR:?message}</code></strong>: <code>VAR</code>이 비어있으면 메시지 출력 후 <strong>스크립트 종료</strong></li>
</ul>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 예시
HOST=""
printf "Connecting to %s...\n" "${HOST:-localhost}"  # localhost 출력</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">패턴 제거 (Pattern Removal)</h2>



<p>파일 경로에서 파일명만 추출하거나 확장자를 뗄 때 가장 많이 사용하는 강력한 기능입니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>문법</strong></td><td><strong>설명</strong></td><td><strong>기억법</strong></td></tr></thead><tbody><tr><td><strong><code>${VAR#패턴}</code></strong></td><td>앞에서부터 <strong>최단</strong> 일치 제거</td><td><code>#</code>은 키보드 왼쪽(앞), 하나는 짧게</td></tr><tr><td><strong><code>${VAR##패턴}</code></strong></td><td>앞에서부터 <strong>최장</strong> 일치 제거</td><td><code>##</code>은 길게</td></tr><tr><td><strong><code>${VAR%패턴}</code></strong></td><td>뒤에서부터 <strong>최단</strong> 일치 제거</td><td><code>%</code>는 키보드 오른쪽(뒤), 하나는 짧게</td></tr><tr><td><strong><code>${VAR%%패턴}</code></strong></td><td>뒤에서부터 <strong>최장</strong> 일치 제거</td><td><code>%%</code>는 길게</td></tr></tbody></table></figure>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">FILE="/var/log/syslog.tar.gz"

echo "${FILE##*/}"  # syslog.tar.gz (경로 제거)
echo "${FILE%.*}"   # /var/log/syslog.tar (최종 확장자 제거)
echo "${FILE%%.*}"  # /var/log/syslog (모든 확장자 제거)
echo "${FILE%/*}"   # /var/log (디렉토리만 추출)

[결과]
$ ./01_hello.sh start
syslog.tar.gz
/var/log/syslog.tar
/var/log/syslog
/var/log</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문자열 치환 및 대소문자 변환 (Bash 확장)</h2>



<p><strong>주의:</strong> 아래 기능들은 <strong>Bash 4.0 이상</strong>에서 지원됩니다. </p>



<p>구형 AIX의 <code>/bin/sh</code>에서는 작동하지 않을 수 있으니 환경을 확인하세요.</p>



<h3 class="wp-block-heading">문자열 치환</h3>



<ul class="wp-block-list">
<li><code>${STR/old/new}</code>: 첫 번째 일치 항목만 치환</li>



<li><code>${STR//old/new}</code>: 모든 일치 항목 치환</li>
</ul>



<h3 class="wp-block-heading">대소문자 변환</h3>



<ul class="wp-block-list">
<li><code>${STR^^}</code>: 전체 대문자</li>



<li><code>${STR,,}</code>: 전체 소문자</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문자열 분리 (IFS 활용)</h2>



<p><code>IFS</code>(Internal Field Separator)는 쉘이 단어를 나누는 기준 문자입니다. </p>



<p>이를 변경하여 CSV 형태의 데이터를 쉽게 분리할 수 있습니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 콜론(:)으로 구분된 데이터 파싱
LINE="hostname:192.168.1.1:8080"
IFS=":" read -r HOST IP PORT &lt;&lt; EOF
$LINE
EOF

printf "Host: %s, IP: %s, Port: %s\n" "$HOST" "$IP" "$PORT"</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>POSIX 표준 변수 처리(<code>${#}</code>, <code>${%}</code>)는 매우 빠르고 효율적입니다. </p>



<p><code>sed</code>나 <code>awk</code> 같은 외부 명령어를 호출하지 않고도 쉘 자체 기능만으로 문자열을 처리하는 습관을 들이면 스크립트의 성능이 비약적으로 향상됩니다!</p>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/">POSIX Shell: 변수(Variables) &amp; 문자열(String)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: 표준 함수(Function)</title>
		<link>https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/</link>
					<comments>https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 21:27:29 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40616</guid>

					<description><![CDATA[<p>스크립트의 규모가 커지면 중복되는 코드를 줄이기 위해 함수(Function)를 사용해야 합니다. POSIX 표준을 따르면서 어디서나 잘 작동하는 함수 작성법을 알아봅니다. 기본 문법 가장 중요한 차이점은 function이라는 키워드를 쓰지 않는다는 것입니다. 인자 전달 (Arguments) 함수로 값을 보낼 때는 별도의 파라미터 이름을 정의하지 않고, 스크립트 실행 인자와 똑같이 위치 매개변수($1, $2, &#8230;)를 사용합니다. 변수 의미 $1, $2 첫 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/">POSIX Shell: 표준 함수(Function)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-19f9e4de      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#기본-문법" class="uagb-toc-link__trigger">기본 문법</a><li class="uagb-toc__list"><a href="#인자-전달-arguments" class="uagb-toc-link__trigger">인자 전달 (Arguments)</a><li class="uagb-toc__list"><a href="#지역-변수-local-variables-주의사항" class="uagb-toc-link__trigger">지역 변수 (Local Variables) 주의사항</a><li class="uagb-toc__list"><a href="#반환값-return-value" class="uagb-toc-link__trigger">반환값 (Return Value)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#return-종료-상태-코드-반환" class="uagb-toc-link__trigger">① return: 종료 상태 코드 반환</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#printfecho-데이터-결과-반환" class="uagb-toc-link__trigger">② printf/echo: 데이터 결과 반환</a></li></ul></li><li class="uagb-toc__list"><a href="#로깅-함수-만들기" class="uagb-toc-link__trigger">로깅 함수 만들기</a><li class="uagb-toc__list"><a href="#핵심-요약-checklist" class="uagb-toc-link__trigger">핵심 요약 (Checklist)</a><li class="uagb-toc__list"><a href="#주의사항" class="uagb-toc-link__trigger">주의사항</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>스크립트의 규모가 커지면 중복되는 코드를 줄이기 위해 함수(Function)를 사용해야 합니다. </p>



<p>POSIX 표준을 따르면서 어디서나 잘 작동하는 함수 작성법을 알아봅니다.</p>



<h2 class="wp-block-heading">기본 문법</h2>



<p>가장 중요한 차이점은 <strong><code>function</code>이라는 키워드를 쓰지 않는다</strong>는 것입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># POSIX 표준 방식 (권장 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" />)
함수이름() {
    # 실행할 내용
}

# Bash 전용 방식 (POSIX에서는 지양 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/274c.png" alt="❌" class="wp-smiley" style="height: 1em; max-height: 1em;" />)
# function 함수이름 { ... }</pre>



<ul class="wp-block-list">
<li><strong>함수 정의</strong>: 반드시 함수를 <strong>호출하기 전</strong>에 먼저 정의되어 있어야 합니다. (보통 스크립트 상단에 배치)</li>



<li><strong>호출</strong>: 함수 이름만 적으면 실행됩니다. (괄호 <code>()</code> 없이 이름만 사용)</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">인자 전달 (Arguments)</h2>



<p>함수로 값을 보낼 때는 별도의 파라미터 이름을 정의하지 않고, 스크립트 실행 인자와 똑같이 위치 매개변수(<code>$1</code>, <code>$2</code>, &#8230;)를 사용합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">greet() {
    printf "안녕하세요, %s님!\n" "$1"
}

greet "홍길동"  # $1에 "홍길동"이 전달됨</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>변수</strong></td><td><strong>의미</strong></td></tr></thead><tbody><tr><td><code>$1</code>, <code>$2</code></td><td>첫 번째, 두 번째 인자</td></tr><tr><td><code>$#</code></td><td>함수에 전달된 인자의 총 개수</td></tr><tr><td><code>$@</code></td><td>전달된 모든 인자 목록</td></tr></tbody></table></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">지역 변수 (Local Variables) 주의사항</h2>



<p>이 부분이 POSIX 표준의 가장 큰 제약사항입니다.</p>



<ul class="wp-block-list">
<li><strong>Bash</strong>:</li>
</ul>



<p><code>local</code> 키워드를 사용하여 함수 내부에서만 쓰는 변수를 만들 수 있습니다.</p>



<ul class="wp-block-list">
<li><strong>POSIX (sh)</strong>: </li>
</ul>



<p>표준에는 <strong><code>local</code> 키워드가 없습니다.</strong> </p>



<p>함수 안에서 선언한 변수도 기본적으로 전역 변수(Global)가 되어 스크립트 전체에 영향을 줍니다.</p>



<p><strong>해결책:</strong> 함수 내에서만 쓰는 변수는 <code>_var_name</code>처럼 앞에 언더바를 붙이거나, 이름이 겹치지 않게 주의해서 지어야 합니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">반환값 (Return Value)</h2>



<p>함수의 실행 결과를 처리하는 방법은 두 가지입니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>구분</strong></td><td><strong>종료 상태 코드 (Exit Status)</strong></td><td><strong>표준 출력 (Standard Output)</strong></td></tr></thead><tbody><tr><td><strong>데이터 타입</strong></td><td>0 ~ 255 사이의 <strong>정수</strong></td><td><strong>문자열</strong> (텍스트 데이터)</td></tr><tr><td><strong>확인 방법</strong></td><td><code>$?</code> 변수로 확인</td><td><code>$(함수이름)</code> (명령어 치환)으로 캡처</td></tr><tr><td><strong>주 용도</strong></td><td>성공(0) 또는 실패(그 외) 판별</td><td>처리된 결과값 전달 (이름, 날짜 등)</td></tr><tr><td><strong>비유</strong></td><td>&#8220;내 일 잘 끝냈어!&#8221; (결과 보고서의 합격/불합격 도장)</td><td>&#8220;내가 만든 결과물이야.&#8221; (결과 보고서의 내용물)</td></tr></tbody></table></figure>



<h3 class="wp-block-heading">① <code>return</code>: 종료 상태 코드 반환</h3>



<p>숫자(0~255)만 반환할 수 있으며, 주로 성공(0)과 실패(그 외)를 알리는 용도입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">is_file_exist() {
    if [ -f "$1" ]; then
        return 0 # 성공
    else
        return 1 # 실패
    fi
}</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">② <code>printf</code>/<code>echo</code>: 데이터 결과 반환</h3>



<p>문자열이나 계산 결과 자체를 받아야 할 때는 출력문을 이용하고 명령어 치환(<code>$()</code>)으로 낚아챕니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">get_date() {
    printf "%s" "$(date +%Y-%m-%d)"
}

TODAY=$(get_date)
printf "오늘 날짜: %s\n" "$TODAY"</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>간단한 예시</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

get_user_status() {
    _USER_NAME="TestUser1"  # 실제 사용자 이름을 여기에 설정
    
    if [ "$_USER_NAME" = "TestUser" ]; then
        # 1. 표준 출력으로 문자열을 내보냄 (반환 문자열)
        printf "Active User"
        # 2. 종료 코드로 성공을 알림 (명령어 마지막 실행 결과가 0)
        return 0
    else
        printf "Unknown"
        return 1
    fi
}

# 실행 및 데이터 캡처
STATUS_TEXT=$(get_user_status)  # "Active User"가 변수에 저장됨 , 출력 문자열($()): 함수가 무슨 데이터를 만들었는지 알려줌 (실제 값)
STATUS_CODE=$?                  # 0이 변수에 저장됨

printf "문자열 결과: %s\n" "$STATUS_TEXT"
printf "상태 코드: %d\n" "$STATUS_CODE"</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">로깅 함수 만들기</h2>



<p>실제 프로젝트에서 유용하게 쓸 수 있는 메시지 출력 함수 예시입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

# 로깅 함수 정의
log_message() {
    _LEVEL="$1"
    _MSG="$2"
    _TIME=$(date '+%H:%M:%S')

    # 형식: [시간] [로그레벨] 메시지
    printf "[%s] [%s] %s\n" "$_TIME" "$_LEVEL" "$_MSG"
}

# 함수 호출
log_message "INFO" "애플리케이션을 시작합니다."
log_message "WARN" "설정 파일이 없습니다. 기본값을 사용합니다."


if [ "$?" -eq 0 ]; then                                  # 상태 코드($?): 마지막 함수가 어떻게 끝났는지 알려줌 (성공/실패)
    log_message "SUCCESS" "작업이 성공적으로 끝났습니다."
fi</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">핵심 요약 (Checklist)</h2>



<ul class="wp-block-list">
<li><strong><code>function</code> 키워드는 빼자</strong>: 그냥 <code>name() { ... }</code> 형식을 사용하세요.</li>



<li><strong><code>local</code>은 표준이 아니다</strong>: 변수 이름 충돌에 주의하세요.</li>



<li><strong>인자는 <code>$1</code>, <code>$2</code>로</strong>: 함수 호출 시 옆에 나열하면 됩니다.</li>



<li><strong>복잡한 결과는 <code>printf</code>로</strong>: 값을 돌려받고 싶을 땐 출력을 이용하세요.</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">주의사항</h2>



<p> &#8220;출력되는 모든 것&#8221; : 함수 안에서 <code>printf</code>나 <code>echo</code>로 찍는 <strong>모든 내용</strong>은 밖에서 <code>$( )</code>로 감싸는 순간 하나의 <strong>반환 문자열</strong>로 합쳐집니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">my_func() {
    printf "Hello "
    printf "World"
}

RESULT=$(my_func)
# RESULT에는 "Hello World"가 들어갑니다.</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p><code>$?</code> 사용 시 주의 : <code>$?</code>는 <strong>바로 직전 명령의 상태코드</strong>라서 즉시 변수에 저장하는 습관이 중요해요.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">STATUS_CODE=$?   # 이 줄은 OK

# 하지만 이런 경우 주의!
some_func
echo "결과 출력"   # 이 줄이 실행되면 $?가 덮어씌워짐
echo $?            # some_func의 코드가 아님!</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p><code>$()</code>와 서브쉘 비용</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">RESULT=$(my_func)  # 서브쉘이 생성됨 → 성능 비용 있음</pre>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/">POSIX Shell: 표준 함수(Function)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: if</title>
		<link>https://lycos7560.com/etc/posix-shell-if/40609/</link>
					<comments>https://lycos7560.com/etc/posix-shell-if/40609/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 21:11:09 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40609</guid>

					<description><![CDATA[<p>쉘 스크립트에서 if문은 프로그램의 흐름을 결정하는 핵심입니다. 하지만 #!/bin/sh 환경에서는 우리가 흔히 쓰는 Bash 전용 문법([[ ]])을 사용할 수 없습니다. 어디서나 돌아가는 견고한 스크립트를 위한 POSIX 표준 if 문법을 정리합니다. 기본 구조 가장 중요한 것은 if, then, fi의 짝을 맞추는 것입니다. 주의: [ 뒤와 ] 앞에는 반드시 공백이 있어야 합니다. [는 사실 test라는 이름의 명령어이기 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-if/40609/">POSIX Shell: if</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-9a16a507      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#기본-구조" class="uagb-toc-link__trigger">기본 구조</a><li class="uagb-toc__list"><a href="#문자열-비교-string-comparison" class="uagb-toc-link__trigger">문자열 비교 (String Comparison)</a><li class="uagb-toc__list"><a href="#숫자-비교-integer-comparison" class="uagb-toc-link__trigger">숫자 비교 (Integer Comparison)</a><li class="uagb-toc__list"><a href="#파일-상태-확인-file-test" class="uagb-toc-link__trigger">파일 상태 확인 (File Test)</a><li class="uagb-toc__list"><a href="#논리-연산-and-or" class="uagb-toc-link__trigger">논리 연산 (AND, OR)</a><li class="uagb-toc__list"><a href="#사용-예시" class="uagb-toc-link__trigger">사용 예시</a></ol>					</div>
									</div>
				</div>
			


<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>쉘 스크립트에서 <code>if</code>문은 프로그램의 흐름을 결정하는 핵심입니다. </p>



<p>하지만 <code>#!/bin/sh</code> 환경에서는 우리가 흔히 쓰는 Bash 전용 문법(<code>[[ ]]</code>)을 사용할 수 없습니다. </p>



<p>어디서나 돌아가는 견고한 스크립트를 위한 <strong>POSIX 표준 if 문법</strong>을 정리합니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">기본 구조</h2>



<p>가장 중요한 것은 <strong><code>if</code></strong>, <strong><code>then</code></strong>, <code><strong>fi</strong></code>의 짝을 맞추는 것입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">if [ 조건식 ]; then
    # 조건이 참(True)일 때 실행
elif [ 조건식 ]; then
    # 앞의 조건이 거짓이고, 현재 조건이 참일 때 실행
else
    # 모든 조건이 거짓일 때 실행
fi</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<p><strong>주의:</strong> <code>[</code> 뒤와 <code>]</code> 앞에는 반드시 <strong>공백</strong>이 있어야 합니다. <code>[</code>는 사실 <code>test</code>라는 이름의 명령어이기 때문입니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문자열 비교 (String Comparison)</h2>



<p>문자열을 비교할 때는 <code>=</code>와 <code>!=</code>를 사용합니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>조건식</strong></td><td><strong>설명</strong></td></tr></thead><tbody><tr><td><code>[ "$A" = "$B" ]</code></td><td>A와 B가 같으면 참</td></tr><tr><td><code>[ "$A" != "$B" ]</code></td><td>A와 B가 다르면 참</td></tr><tr><td><code>[ -z "$A" ]</code></td><td>문자열 A의 길이가 0이면 참 (Empty)</td></tr><tr><td><code>[ -n "$A" ]</code></td><td>문자열 A의 길이가 0이 아니면 참 (Not Empty)</td></tr></tbody></table></figure>



<p><strong>핵심 팁:</strong> 변수는 반드시 <strong>쌍따옴표(<code>" "</code>)</strong>로 감싸세요. </p>



<p>변수가 비어있을 경우 발생할 수 있는 구문 오류를 방지해줍니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">숫자 비교 (Integer Comparison)</h2>



<p>숫자는 부등호(<code>&lt;</code>, <code>></code>) 대신 <strong>문자 약어</strong>를 사용합니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>조건식</strong></td><td><strong>의미</strong></td><td><strong>Full Name</strong></td></tr></thead><tbody><tr><td><code>[ "$A" -eq "$B" ]</code></td><td>같음</td><td><strong>Eq</strong>ual</td></tr><tr><td><code>[ "$A" -ne "$B" ]</code></td><td>다름</td><td><strong>N</strong>ot <strong>E</strong>qual</td></tr><tr><td><code>[ "$A" -gt "$B" ]</code></td><td>초과</td><td><strong>G</strong>reater <strong>T</strong>han</td></tr><tr><td><code>[ "$A" -ge "$B" ]</code></td><td>이상</td><td><strong>G</strong>reater or <strong>E</strong>qual</td></tr><tr><td><code>[ "$A" -lt "$B" ]</code></td><td>미만</td><td><strong>L</strong>ess <strong>T</strong>han</td></tr><tr><td><code>[ "$A" -le "$B" ]</code></td><td>이하</td><td><strong>L</strong>ess or <strong>E</strong>qual</td></tr></tbody></table></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">파일 상태 확인 (File Test)</h2>



<p>쉘 스크립트에서 가장 많이 쓰이는 강력한 기능입니다.</p>



<ul class="wp-block-list">
<li><code>[ -f "file" ]</code>: 일반 <strong>파일</strong>이 존재하면 참</li>



<li><code>[ -d "dir" ]</code>: <strong>디렉토리</strong>가 존재하면 참</li>



<li><code>[ -e "path" ]</code>: 파일이든 디렉토리든 <strong>존재</strong>만 하면 참</li>



<li><code>[ -r "file" ]</code>: 읽기 권한이 있으면 참</li>



<li><code>[ -x "file" ]</code>: 실행 권한이 있으면 참</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">논리 연산 (AND, OR)</h2>



<p>여러 조건을 조합할 때 POSIX에서는 두 가지 방법을 씁니다.</p>



<p><strong><code>-a</code> (AND), <code>-o</code> (OR)</strong>: 하나의 <code>[ ]</code> 안에서 사용</p>



<ul class="wp-block-list">
<li><code>if [ "$A" = "1" -a "$B" = "2" ]</code></li>
</ul>



<p><strong><code>&amp;&amp;</code>, <code>||</code> 활용</strong>: 여러 개의 <code>[ ]</code>를 연결 (<strong>더 권장됨</strong>)</p>



<ul class="wp-block-list">
<li><code>if [ "$A" = "1" ] &amp;&amp; [ "$B" = "2" ]</code></li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">사용 예시</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

APP_NAME="TestApp"
CONFIG_FILE="./config.conf"
DEBUG_MODE="ON"

printf "시스템 체크를 시작합니다...\n"

# 1. 설정 파일 존재 여부 체크 (파일 테스트)
if [ -f "$CONFIG_FILE" ]; then
    printf "[OK] 설정 파일을 찾았습니다.\n"
else
    printf "[Error] %s 파일이 없습니다.\n" "$CONFIG_FILE"
    # exit 1  # 실제 스크립트라면 여기서 종료 가능
fi

# 2. 디버그 모드 확인 (문자열 비교)
if [ "$DEBUG_MODE" = "ON" ]; then
    printf "[Log] 디버그 모드가 활성화되어 있습니다.\n"
fi

# 3. 인자 개수 확인 (숫자 비교)
# $#는 스크립트에 전달된 인자의 개수입니다.
if [ "$#" -lt 1 ]; then
    printf "사용법: %s [start|stop]\n" "$0"
else
    if [ "$1" = "start" ]; then
        printf "%s을 시작합니다...\n" "$APP_NAME"
    elif [ "$1" = "stop" ]; then
        printf "%s을 중지합니다...\n" "$APP_NAME"
    else
        printf "알 수 없는 명령입니다: %s\n" "$1"
    fi
fi





$ ./01_hello.sh start
시스템 체크를 시작합니다...
[OK] 설정 파일을 찾았습니다.
[Log] 디버그 모드가 활성화되어 있습니다.
TestApp을 시작합니다...</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-if/40609/">POSIX Shell: if</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-if/40609/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: printf</title>
		<link>https://lycos7560.com/etc/posix-bash-printf/40604/</link>
					<comments>https://lycos7560.com/etc/posix-bash-printf/40604/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 20:50:44 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40604</guid>

					<description><![CDATA[<p>쉘 스크립트를 작성할 때 단순히 메시지를 출력하기 위해 echo를 자주 사용합니다. 하지만 스크립트가 복잡해지고 여러 환경에서의 이식성(Portability)이 중요해지면 printf를 사용하는 것이 개발자 정신 건강에 좋다. echo 대신 printf? 특징 echo printf 표준 준수 시스템/쉘마다 동작이 다름 (비표준) POSIX 표준 — 어디서나 동일하게 동작 제어 능력 단순 출력에 최적화 포맷 지정자를 통한 세밀한 제어 가능 개행(줄바꿈) [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-bash-printf/40604/">POSIX Shell: printf</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-db47f186      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#echo-대신-printf" class="uagb-toc-link__trigger">echo 대신 printf?</a><li class="uagb-toc__list"><a href="#기본-문법" class="uagb-toc-link__trigger">기본 문법</a><li class="uagb-toc__list"><a href="#핵심-포맷-지정자-format-specifiers" class="uagb-toc-link__trigger">핵심 포맷 지정자 (Format Specifiers)</a><li class="uagb-toc__list"><a href="#고급-제어-너비-정렬-정밀도" class="uagb-toc-link__trigger">고급 제어: 너비, 정렬, 정밀도</a><li class="uagb-toc__list"><a href="#실전-예제-코드" class="uagb-toc-link__trigger">실전 예제 코드</a><li class="uagb-toc__list"><a href="#이스케이프-시퀀스-escape-sequences" class="uagb-toc-link__trigger">이스케이프 시퀀스 (Escape Sequences)</a></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<p>쉘 스크립트를 작성할 때 단순히 메시지를 출력하기 위해 <code>echo</code>를 자주 사용합니다. </p>



<p>하지만 스크립트가 복잡해지고 여러 환경에서의 이식성(Portability)이 중요해지면 <code>printf</code>를 사용하는 것이 개발자 정신 건강에 좋다.</p>



<h2 class="wp-block-heading">echo 대신 printf?</h2>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>특징</strong></td><td><strong>echo</strong></td><td><strong>printf</strong></td></tr></thead><tbody><tr><td><strong>표준 준수</strong></td><td>시스템/쉘마다 동작이 다름 (비표준)</td><td><strong>POSIX 표준</strong> — 어디서나 동일하게 동작</td></tr><tr><td><strong>제어 능력</strong></td><td>단순 출력에 최적화</td><td>포맷 지정자를 통한 세밀한 제어 가능</td></tr><tr><td><strong>개행(줄바꿈)</strong></td><td>자동으로 줄을 바꿈</td><td><code>\n</code>을 명시해야 함 (의도적 제어 가능)</td></tr><tr><td><strong>신뢰도</strong></td><td><code>-e</code>, <code>-n</code> 옵션 등이 환경마다 다름</td><td>일관된 결과 보장 (이식성 높음)</td></tr></tbody></table></figure>



<p><strong>결론:</strong> 단순한 확인용 출력은 <code>echo</code>가 편하지만, 표(Table)를 만들거나 진법 변환, 정교한 텍스트 배치가 필요하다면 <code>printf</code>를 사용하는 것이 좋다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">기본 문법</h2>



<p><code>printf</code>는 포맷 문자열(Format String)을 먼저 정의하고, 그 뒤에 들어갈 인자(Arguments)를 순서대로 나열하는 문법 체계를 가지고 있다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">printf "포맷문자열" [인자1] [인자2] ...</pre>



<ul class="wp-block-list">
<li><strong>특징</strong>: 인자의 개수가 포맷 지정자보다 많으면, 포맷 문자열을 <strong>반복</strong>해서 적용합니다.</li>



<li><strong>주의</strong>: 자동으로 줄바꿈을 하지 않으므로 문자열 끝에 <code>\n</code>을 붙여야 합니다</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">핵심 포맷 지정자 (Format Specifiers)</h2>



<p>인자의 데이터 타입에 맞는 지정자를 사용해야 합니다.</p>



<ul class="wp-block-list">
<li><code>%s</code>: <strong>S</strong>tring (문자열)</li>



<li><code>%d</code>: <strong>D</strong>ecimal (10진수 정수)</li>



<li><code>%f</code>: <strong>F</strong>loat (부동소수점 실수)</li>



<li><code>%x</code>: He<strong>x</strong>adecimal (16진수 소문자)</li>



<li><code>%o</code>: <strong>O</strong>ctal (8진수)</li>



<li><code>%%</code>: <code>%</code> 기호 자체를 출력</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">고급 제어: 너비, 정렬, 정밀도</h2>



<p><code>printf</code>의 진가는 데이터를 예쁘게 정렬할 때 나타납니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>포맷</strong></td><td><strong>설명</strong></td></tr></thead><tbody><tr><td><code>%10s</code></td><td>최소 10자 너비 확보, <strong>오른쪽</strong> 정렬</td></tr><tr><td><code>%-10s</code></td><td>최소 10자 너비 확보, <strong>왼쪽</strong> 정렬</td></tr><tr><td><code>%.2f</code></td><td>소수점 아래 <strong>2자리</strong>까지 출력</td></tr><tr><td><code>%8.2f</code></td><td>전체 8칸 확보 후 소수점 2자리 출력</td></tr></tbody></table></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">실전 예제 코드</h2>



<p>기본 출력 및 진법 변환</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 이름과 나이 출력
printf "이름: %s, 나이: %d\n" "Kim" 30

# 10진수 255를 16진수로 변환 (결과: 0xff)
printf "16진수 변환: 0x%x\n" 255

# 퍼센트 기호 출력 (결과: 75%)
printf "CPU 사용률: %d%%\n" 75</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>데이터 표(Table) 만들기</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

# 헤더 출력
printf "%-10s %5s %8s\n" "이름" "점수" "등급"
printf "--------------------------\n"

# 데이터 출력
printf "%-10s %5d %8s\n" "홍길동" 95 "A"
printf "%-10s %5d %8s\n" "김철수" 82 "B"
printf "%-10s %5d %8s\n" "이영희" 100 "A+"</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">이스케이프 시퀀스 (Escape Sequences)</h2>



<p>문자열 내에서 특수 기능을 수행하는 기호들입니다.</p>



<ul class="wp-block-list">
<li><code>\n</code>: 줄바꿈 (Newline)</li>



<li><code>\t</code>: 탭 (Tab)</li>



<li><code>\\</code>: 백슬래시(<code>\</code>) 자체 출력</li>



<li><code>\0NNN</code>: 8진수 숫자로 지정된 ASCII 문자 출력</li>
</ul>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-bash-printf/40604/">POSIX Shell: printf</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-bash-printf/40604/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>#include 지시자</title>
		<link>https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/</link>
					<comments>https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 05 Apr 2026 18:33:13 +0000</pubDate>
				<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40565</guid>

					<description><![CDATA[<p>C 언어와 C++에서 #include는 소스 코드 파일의 가장 윗부분에서 흔히 볼 수 있는 전처리기 지시자(Preprocessor Directive)입니다. 1. #include의 핵심 역할 #include는 한마디로 &#8220;복사해서 붙여넣기&#8221;입니다. 컴파일러가 실제 코드를 번역하기 전(전처리 단계), 지정한 파일의 내용을 #include 문장이 있는 그 자리에 통째로 가져와서 삽입합니다. 2. 사용법에 따른 차이 ( &#60; &#62; vs " " ) #include를 사용할 때 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/">#include 지시자</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-537dce7c      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#1-include의-핵심-역할" class="uagb-toc-link__trigger">1. #include의 핵심 역할</a><li class="uagb-toc__list"><a href="#2-사용법에-따른-차이-vs" class="uagb-toc-link__trigger">2. 사용법에 따른 차이 ( &lt; &gt; vs &quot; &quot; )</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#꺽쇠-괄호" class="uagb-toc-link__trigger">① &lt; &gt; (꺽쇠 괄호)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#큰따옴표" class="uagb-toc-link__trigger">② &quot; &quot; (큰따옴표)</a></li></ul></li><li class="uagb-toc__list"><a href="#3-왜-헤더-파일을-포함해야-할까" class="uagb-toc-link__trigger">3. 왜 헤더 파일을 포함해야 할까?</a><li class="uagb-toc__list"><a href="#4-주의사항-중복-포함-방지" class="uagb-toc-link__trigger">4. 주의사항: 중복 포함 방지</a><li class="uagb-toc__list"><a href="#5-자주-사용하는-표준-라이브러리-헤더-목록-c" class="uagb-toc-link__trigger">5. 자주 사용하는 표준 라이브러리 헤더 목록 (c)</a><li class="uagb-toc__list"><a href="#요약" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 요약</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>C 언어와 C++에서 <code>#include</code>는 소스 코드 파일의 가장 윗부분에서 흔히 볼 수 있는 전처리기 지시자(Preprocessor Directive)입니다. </p>



<h2 class="wp-block-heading">1. <code>#include</code>의 핵심 역할</h2>



<p><code>#include</code>는 한마디로 <strong>&#8220;복사해서 붙여넣기&#8221;</strong>입니다. </p>



<p>컴파일러가 실제 코드를 번역하기 전(전처리 단계), 지정한 파일의 내용을 <code>#include</code> 문장이 있는 그 자리에 통째로 가져와서 삽입합니다.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="644" height="299" src="https://lycos7560.com/wp-content/uploads/2026/04/image.png" alt="" class="wp-image-40566" srcset="https://lycos7560.com/wp-content/uploads/2026/04/image.png 644w, https://lycos7560.com/wp-content/uploads/2026/04/image-300x139.png 300w" sizes="(max-width: 644px) 100vw, 644px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading">2. 사용법에 따른 차이 ( <code>&lt; &gt;</code> vs <code>" "</code> )</h2>



<p><code>#include</code>를 사용할 때 괄호의 모양에 따라 파일을 찾는 위치가 달라집니다.</p>



<h3 class="wp-block-heading">① <code>&lt; &gt;</code> (꺽쇠 괄호)</h3>



<ul class="wp-block-list">
<li><strong>사용 예:</strong> <code>#include &lt;stdio.h&gt;</code></li>



<li><strong>설명:</strong> 시스템의 <strong>표준 라이브러리 경로</strong>에서 파일을 찾습니다.</li>



<li><strong>대상:</strong> 컴파일러 설치 시 기본적으로 제공되는 표준 헤더 파일들을 불러올 때 사용합니다.</li>
</ul>



<h3 class="wp-block-heading">② <code>" "</code> (큰따옴표)</h3>



<ul class="wp-block-list">
<li><strong>사용 예:</strong> <code>#include "my_header.h"</code></li>



<li><strong>설명:</strong> <strong>현재 작업 중인 디렉토리(소스 파일이 있는 곳)</strong>에서 먼저 파일을 찾습니다. 만약 거기서 못 찾으면 시스템 표준 경로를 뒤집니다.</li>



<li><strong>대상:</strong> 개발자가 직접 만든 헤더 파일을 불러올 때 주로 사용합니다.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading">3. 왜 헤더 파일을 포함해야 할까?</h2>



<p><code>printf</code>나 <code>scanf</code> 같은 함수를 쓸 수 있는 이유는 그 함수들의 <strong>선언(Declaration)</strong>이 <code>stdio.h</code>라는 파일 안에 들어있기 때문입니다.</p>



<ul class="wp-block-list">
<li>컴파일러는 함수를 만나면 &#8220;이 함수가 어떻게 생겼는지(매개변수, 반환 타입 등)&#8221;를 알아야 합니다.</li>



<li>직접 모든 함수를 정의하기엔 양이 너무 많으므로, 미리 정의된 헤더 파일을 <code>#include</code>로 불러와서 정보를 제공하는 것입니다.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading">4. 주의사항: 중복 포함 방지</h2>



<p>대규모 프로젝트에서는 여러 파일이 서로를 참조하다가 똑같은 헤더 파일을 여러 번 <code>#include</code> 하는 상황이 발생할 수 있습니다. </p>



<p>이는 정의 중복 에러를 일으키므로, 보통 다음과 같은 기법을 사용합니다.</p>



<ul class="wp-block-list">
<li><strong>Header Guard:</strong>C<code>#ifndef MY_HEADER_H #define MY_HEADER_H // 코드 내용 #endif</code></li>



<li><strong>pragma once:</strong>C<code>#pragma once // 코드 내용</code></li>
</ul>



<pre class="EnlighterJSRAW" data-enlighter-language="c" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#ifndef MY_HEADER_H
#define MY_HEADER_H

/* 헤더 파일 내용 */
void say_hello();

#endif</pre>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading">5. 자주 사용하는 표준 라이브러리 헤더 목록 (c)</h2>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">헤더 파일</th><th class="has-text-align-left" data-align="left">포함 내용</th><th class="has-text-align-left" data-align="left">대표 함수</th></tr></thead><tbody><tr><td>&lt;stdio.h&gt;</td><td>표준 입출력</td><td>printf, scanf, fopen</td></tr><tr><td>&lt;stdlib.h&gt;</td><td>메모리·변환·난수</td><td>malloc, free, rand</td></tr><tr><td>&lt;string.h&gt;</td><td>문자열 처리</td><td>strcpy, strlen, strcmp</td></tr><tr><td>&lt;math.h&gt;</td><td>수학 함수</td><td>sqrt, pow, sin</td></tr><tr><td>&lt;time.h&gt;</td><td>시간·날짜</td><td>time, clock, difftime</td></tr></tbody></table></figure>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 요약</h2>



<p><code>#include</code>는 <strong>외부에 작성된 코드나 함수 선언을 현재 파일로 가져오는 통로</strong>입니다. </p>



<p>시스템 라이브러리는 <code>&lt; &gt;</code>를, 내가 만든 파일은 <code>" "</code>를 사용합니다.</p>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/">#include 지시자</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux Default Directory Structure (기본 디렉터리 구조)</title>
		<link>https://lycos7560.com/ubuntu/%eb%a6%ac%eb%88%85%ec%8a%a4-%ea%b8%b0%eb%b3%b8-%eb%94%94%eb%a0%89%ed%84%b0%eb%a6%ac-%ea%b5%ac%ec%a1%b0-linux-default-directory-structure/40290/</link>
					<comments>https://lycos7560.com/ubuntu/%eb%a6%ac%eb%88%85%ec%8a%a4-%ea%b8%b0%eb%b3%b8-%eb%94%94%eb%a0%89%ed%84%b0%eb%a6%ac-%ea%b5%ac%ec%a1%b0-linux-default-directory-structure/40290/#comments</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 01 Mar 2026 07:06:00 +0000</pubDate>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40290</guid>

					<description><![CDATA[<p>디렉터리 구조 표 디렉터리 용도 이름(어원/줄임말) / 파일 시스템 최상위 디렉터리, 모든 경로의 출발점 &#8211; /bin 기본 명령어(binary) 저장소. 부팅/유저 작업에 필수적인 실행 파일 binary /boot 부팅 관련 파일 저장. 커널, 초기 램디스크, 부트로더 설정 포함 boot /dev 장치 파일 저장 (디스크, 터미널, 가상 장치 등) device /etc 시스템 설정 파일(전역 설정) et cetera (원래 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/ubuntu/%eb%a6%ac%eb%88%85%ec%8a%a4-%ea%b8%b0%eb%b3%b8-%eb%94%94%eb%a0%89%ed%84%b0%eb%a6%ac-%ea%b5%ac%ec%a1%b0-linux-default-directory-structure/40290/">Linux Default Directory Structure (기본 디렉터리 구조)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-eedf4b9d      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#디렉터리-구조-표" class="uagb-toc-link__trigger">디렉터리 구조 표</a><li class="uagb-toc__list"><a href="#각-디렉터리-상세-설명" class="uagb-toc-link__trigger">각 디렉터리 상세 설명</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#toc_6a045bf53897b" class="uagb-toc-link__trigger">/</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#bin" class="uagb-toc-link__trigger">/bin</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#boot" class="uagb-toc-link__trigger">/boot</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#dev" class="uagb-toc-link__trigger">/dev</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#etc" class="uagb-toc-link__trigger">/etc</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#home" class="uagb-toc-link__trigger">/home</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lib-lib64" class="uagb-toc-link__trigger">/lib, /lib64</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#media" class="uagb-toc-link__trigger">/media</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#mnt" class="uagb-toc-link__trigger">/mnt</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#opt" class="uagb-toc-link__trigger">/opt</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#proc" class="uagb-toc-link__trigger">/proc</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#root" class="uagb-toc-link__trigger">/root</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#run" class="uagb-toc-link__trigger">/run</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#sbin" class="uagb-toc-link__trigger">/sbin</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#srv" class="uagb-toc-link__trigger">/srv</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#sys" class="uagb-toc-link__trigger">/sys</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#tmp" class="uagb-toc-link__trigger">/tmp</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#usr" class="uagb-toc-link__trigger">/usr</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#var" class="uagb-toc-link__trigger">/var</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lostfound" class="uagb-toc-link__trigger">/lost+found</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">디렉터리 구조 표</h2>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>디렉터리</th><th>용도</th><th>이름(어원/줄임말)</th></tr></thead><tbody><tr><td><code>/</code></td><td>파일 시스템 최상위 디렉터리, 모든 경로의 출발점</td><td>&#8211;</td></tr><tr><td><code>/bin</code></td><td>기본 명령어(binary) 저장소. 부팅/유저 작업에 필수적인 실행 파일</td><td>binary</td></tr><tr><td><code>/boot</code></td><td>부팅 관련 파일 저장. 커널, 초기 램디스크, 부트로더 설정 포함</td><td>boot</td></tr><tr><td><code>/dev</code></td><td>장치 파일 저장 (디스크, 터미널, 가상 장치 등)</td><td>device</td></tr><tr><td><code>/etc</code></td><td>시스템 설정 파일(전역 설정)</td><td>et cetera (원래 의미) / Editable Text Configuration (재해석)</td></tr><tr><td><code>/home</code></td><td>일반 사용자 홈 디렉터리</td><td>home directory</td></tr><tr><td><code>/lib</code>, <code>/lib64</code></td><td>실행 파일이 필요로 하는 공유 라이브러리</td><td>library</td></tr><tr><td><code>/media</code></td><td>USB, CD-ROM 등 이동식 미디어 자동 마운트 지점</td><td>media (removable media)</td></tr><tr><td><code>/mnt</code></td><td>관리자가 수동으로 마운트할 때 사용하는 임시 디렉터리</td><td>mount</td></tr><tr><td><code>/opt</code></td><td>선택적 소프트웨어 설치 경로</td><td>optional</td></tr><tr><td><code>/proc</code></td><td>가상 파일 시스템. 커널과 프로세스 상태 정보 제공</td><td>process</td></tr><tr><td><code>/root</code></td><td>root(관리자) 계정의 홈 디렉터리</td><td>root / superuser</td></tr><tr><td><code>/run</code></td><td>실행 중 생성되는 상태 파일 저장 (PID, 소켓 등)</td><td>runtime</td></tr><tr><td><code>/sbin</code></td><td>시스템 관리용 실행 파일</td><td>system binary</td></tr><tr><td><code>/srv</code></td><td>시스템 서비스 데이터 저장</td><td>service</td></tr><tr><td><code>/sys</code></td><td>커널 객체 정보 제공 가상 파일 시스템</td><td>system</td></tr><tr><td><code>/tmp</code></td><td>임시 파일 저장소</td><td>temporary</td></tr><tr><td><code>/usr</code></td><td>사용자 프로그램과 라이브러리 저장소</td><td>user / Unix System Resources</td></tr><tr><td><code>/var</code></td><td>가변 데이터 저장 (로그, 메일, 캐시 등)</td><td>variable</td></tr><tr><td><code>/lost+found</code></td><td>파일 시스템 손상 복구 시 fsck가 잃어버린 파일 조각을 모아두는 디렉터리</td><td>lost + found</td></tr></tbody></table></figure>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">각 디렉터리 상세 설명</h2>



<h3 class="wp-block-heading"><code>/</code></h3>



<p>리눅스에서 모든 파일과 디렉터리는 **루트 디렉터리 <code>/</code>**를 기준으로 계층 구조를 갖습니다. 모든 경로는 <code>/</code>에서 시작하며, Windows의 <code>C:\</code>와 비슷한 역할을 하지만, 드라이브 개념이 없고 모든 장치가 여기 아래로 마운트됩니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/bin</code></h3>



<p>시스템 부팅과 사용자 작업에 필수적인 <strong>기본 명령어</strong>가 저장됩니다.</p>



<p>예: <code>ls</code>, <code>cp</code>, <code>mv</code>, <code>cat</code>. 싱글 유저 모드에서도 실행 가능하도록 필수 명령어를 제공합니다.</p>



<ul class="wp-block-list">
<li><code>ls</code>, <code>cp</code>, <code>mv</code> &#8211; 파일 작업</li>



<li><code>cat</code>, <code>grep</code> &#8211; 텍스트 도구</li>



<li><code>bash</code> &#8211; 쉘(Shell)</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/boot</code></h3>



<p>부팅 관련 파일이 저장됩니다. </p>



<p>커널 파일(이미)(<code>vmlinuz</code>), 초기 램디스크(<code>initrd</code>/<code>initramfs</code>), 부트로더 설정(<code>grub.cfg</code>) 등이 포함되어 있으며, </p>



<p>부트로더(GRUB)는 이 파일들을 사용해 커널을 메모리에 올립니다.</p>



<p>GNU GRUB(Grand Unified Bootloader), <strong>커널 파일</strong> &#8211; 운영체제의 심장</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/dev</code></h3>



<p>시스템의 <strong>장치 파일</strong>을 모아두는 디렉터리입니다. </p>



<p>하드디스크, 터미널, 프린터, 가상 장치 등이 모두 파일로 표현됩니다. </p>



<p>예: <code>/dev/sda</code>는 첫 번째 디스크, <code>/dev/null</code>은 데이터를 버리는 장치입니다.</p>



<ul class="wp-block-list">
<li><code>/dev/sda1</code> &#8211; 하드 드라이브 파티션</li>



<li><code>/dev/null</code> &#8211; 데이터를 삼켜버리는 유명한 &#8220;블랙홀&#8221;</li>



<li><code>/dev/random</code> &#8211; 난수 생성기</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/etc</code></h3>



<p>시스템의 <strong>전역 설정 파일</strong>이 있는 디렉터리입니다. </p>



<p>리눅스 시스템의 설정 본부입니다. 모든 설정, 규칙, 시스템 기본 설정이 이곳에 저장됩니다.</p>



<p>초기에는 &#8220;et cetera&#8221;(잡다한 설정) 의미였으며, 현재는 시스템 설정을 담당합니다. </p>



<p>예: <code>/etc/passwd</code>(사용자 계정), <code>/etc/fstab</code>(파일 시스템 마운트 정보).</p>



<ul class="wp-block-list">
<li><strong>사용자 계정</strong> (<code>passwd</code>, <code>shadow</code>)</li>



<li><strong>네트워크 설정</strong> (<code>hosts</code>, <code>resolv.conf</code>)</li>



<li><strong>서비스 설정</strong> (SSH, Apache 등)</li>



<li><strong>시작 스크립트 및 시스템 규칙</strong></li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/home</code></h3>



<p>일반 사용자들의 <strong>홈 디렉터리</strong>입니다. </p>



<p>각 사용자는 <code>/home/username</code> 디렉터리를 갖습니다. </p>



<p>root 계정은 <code>/root</code>를 사용합니다. 보안과 안정성을 위해 일반 사용자 폴더(<code>/home</code>)와 분리되어 있습니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/lib</code>, <code>/lib64</code></h3>



<p>실행 파일이 필요로 하는 <strong>공유 라이브러리</strong>를 저장합니다. </p>



<p><code>/bin</code>과 <code>/sbin</code> 프로그램들이 실행되기 위해 필요한 공통 함수들을 제공합니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/media</code></h3>



<p>USB, CD-ROM 등 <strong>이동식 미디어</strong>를 자동 마운트하는 디렉터리입니다. </p>



<p>사용자가 장치를 연결하면 시스템이 <code>/media</code> 아래에 장치를 자동으로 연결합니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/mnt</code></h3>



<p>관리자가 <strong>수동으로 장치를 마운트</strong>할 때 사용하는 임시 디렉터리입니다. 테스트용 외장 하드나 파티션 마운트 시 사용됩니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/opt</code></h3>



<p>선택적 소프트웨어를 설치하는 디렉터리입니다. </p>



<p>표준 레이아웃을 따르지 않는 상용 프로그램이나 독립 패키지를 <code>/opt</code> 아래에 설치하는 방식이 일반적입니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/proc</code></h3>



<p>가상 파일 시스템으로, 커널과 프로세스 상태 정보를 제공합니다. </p>



<p><code>/proc/cpuinfo</code>(CPU 정보), <code>/proc/meminfo</code>(메모리 사용 현황)처럼 실제 파일은 없고 커널이 동적으로 생성합니다.</p>



<ul class="wp-block-list">
<li><code>/proc/cpuinfo</code> &#8211; CPU 상세 정보</li>



<li><code>/proc/meminfo</code> &#8211; 메모리 사용량</li>



<li><code>/proc/[PID]/</code> &#8211; 실행 중인 프로세스 정보</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/root</code></h3>



<p>root(관리자) 계정의 <strong>홈 디렉터리</strong>입니다. 일반 사용자 홈 디렉터리는 <code>/home</code>에 있습니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/run</code></h3>



<p>실행 중 생성되는 <strong>상태 파일</strong>을 저장합니다. </p>



<p>예: 서비스 PID 파일, 소켓 파일, 현재 세션 정보 등&#8230;</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/sbin</code></h3>



<p>시스템 관리용 <strong>실행 파일</strong>을 저장합니다. </p>



<p>예: <code>fsck</code>, <code>reboot</code>, <code>ifconfig</code>. 일반 사용자는 주로 접근하지 않습니다.</p>



<ul class="wp-block-list">
<li><code>mount</code> &#8211; 파일시스템 마운트</li>



<li><code>iptables</code> &#8211; 방화벽 관리</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/srv</code></h3>



<p>시스템에서 제공하는 <strong>서비스 데이터</strong>를 담습니다. 예: 웹 서버의 웹 페이지 데이터 <code>/srv/www</code>.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/sys</code></h3>



<p>커널 객체 정보를 제공하는 <strong>가상 파일 시스템(sysfs)</strong>입니다. </p>



<p>하드웨어와 장치 드라이버 관련 정보를 확인하고 설정할 때 사용합니다.</p>



<p>커널 및 하드웨어 정보와 상호작용하는 더 새롭고 깔끔한 방식의 디렉토리입니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/tmp</code></h3>



<p><strong>임시 파일 저장소</strong>입니다.</p>



<p>프로그램 실행 중 생성되는 임시 데이터를 저장하며, <strong>시스템 재부팅 시 대부분 삭제</strong>됩니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/usr</code></h3>



<p>사용자 프로그램과 라이브러리 저장소입니다. </p>



<p>원래는 &#8220;user&#8221; 디렉터리였으나, 지금은 <strong>응용 프로그램, 라이브러리, 공유 데이터</strong>를 담습니다.</p>



<p><strong>U</strong>ser <strong>S</strong>ystem <strong>R</strong>esources의 약자로, 대부분의 프로그램이 설치되는 곳입니다.</p>



<ul class="wp-block-list">
<li><code>/usr/bin</code> &#8211; 사용자 프로그램 (Firefox, LibreOffice 등)</li>



<li><code>/usr/lib</code> &#8211; 프로그램 라이브러리</li>



<li><code>/usr/local</code> &#8211; 사용자가 직접 설치한 커스텀 소프트웨어</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/var</code></h3>



<p>끊임없이 변하는 가변 데이터를 저장하는 디렉터리입니다. </p>



<p>로그(<code>/var/log</code>), 메일, 캐시, 스풀, 데이터베이스 파일 등 수시로 변경되는 데이터를 저장합니다.</p>



<ul class="wp-block-list">
<li><code>/var/log</code> &#8211; 시스템 로그 (<strong>문제 해결의 보물창고!</strong>)</li>



<li><code>/var/cache</code> &#8211; 애플리케이션 캐시</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><code>/lost+found</code></h3>



<p>파일 시스템 손상 복구를 위해 존재합니다. <code>fsck</code> 실행 시 깨진 inode나 위치를 잃은 파일을 이곳에 모아 복구 작업에 사용합니다.</p>



<p></p>
<p>The post <a href="https://lycos7560.com/ubuntu/%eb%a6%ac%eb%88%85%ec%8a%a4-%ea%b8%b0%eb%b3%b8-%eb%94%94%eb%a0%89%ed%84%b0%eb%a6%ac-%ea%b5%ac%ec%a1%b0-linux-default-directory-structure/40290/">Linux Default Directory Structure (기본 디렉터리 구조)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/ubuntu/%eb%a6%ac%eb%88%85%ec%8a%a4-%ea%b8%b0%eb%b3%b8-%eb%94%94%eb%a0%89%ed%84%b0%eb%a6%ac-%ea%b5%ac%ec%a1%b0-linux-default-directory-structure/40290/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>LVM(Logical Volume Manager) 구조 및 개념</title>
		<link>https://lycos7560.com/etc/lvmlogical-volume-manager-%ea%b5%ac%ec%a1%b0-%eb%b0%8f-%ea%b0%9c%eb%85%90/40489/</link>
					<comments>https://lycos7560.com/etc/lvmlogical-volume-manager-%ea%b5%ac%ec%a1%b0-%eb%b0%8f-%ea%b0%9c%eb%85%90/40489/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 22 Feb 2026 16:13:57 +0000</pubDate>
				<category><![CDATA[기타]]></category>
		<category><![CDATA[AIX admin]]></category>
		<category><![CDATA[AIX hdisk]]></category>
		<category><![CDATA[AIX LVM]]></category>
		<category><![CDATA[AIX storage]]></category>
		<category><![CDATA[Block Device]]></category>
		<category><![CDATA[Data Storage]]></category>
		<category><![CDATA[Disk allocation]]></category>
		<category><![CDATA[disk device]]></category>
		<category><![CDATA[Disk Management]]></category>
		<category><![CDATA[Disk Partition]]></category>
		<category><![CDATA[Enterprise storage]]></category>
		<category><![CDATA[ext4]]></category>
		<category><![CDATA[Extent]]></category>
		<category><![CDATA[FC storage]]></category>
		<category><![CDATA[Fibre Channel]]></category>
		<category><![CDATA[File System]]></category>
		<category><![CDATA[FileSystem]]></category>
		<category><![CDATA[hdisk]]></category>
		<category><![CDATA[hdisk0]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[iSCSI]]></category>
		<category><![CDATA[IT infrastructure]]></category>
		<category><![CDATA[IT 인프라]]></category>
		<category><![CDATA[JFS]]></category>
		<category><![CDATA[JFS2]]></category>
		<category><![CDATA[LE]]></category>
		<category><![CDATA[Linux admin]]></category>
		<category><![CDATA[Linux LVM]]></category>
		<category><![CDATA[Linux storage]]></category>
		<category><![CDATA[Logical Disk]]></category>
		<category><![CDATA[Logical Extent]]></category>
		<category><![CDATA[Logical Partition]]></category>
		<category><![CDATA[Logical storage]]></category>
		<category><![CDATA[Logical Unit Number]]></category>
		<category><![CDATA[Logical Volume]]></category>
		<category><![CDATA[Logical Volume Manager]]></category>
		<category><![CDATA[LP]]></category>
		<category><![CDATA[lsdev]]></category>
		<category><![CDATA[lslv]]></category>
		<category><![CDATA[lspv]]></category>
		<category><![CDATA[lsvg]]></category>
		<category><![CDATA[LUN]]></category>
		<category><![CDATA[LV]]></category>
		<category><![CDATA[lvdisplay]]></category>
		<category><![CDATA[LVM]]></category>
		<category><![CDATA[LVM architecture]]></category>
		<category><![CDATA[LVM concept]]></category>
		<category><![CDATA[LVM hierarchy]]></category>
		<category><![CDATA[LVM 개념]]></category>
		<category><![CDATA[LVM 계층 구조]]></category>
		<category><![CDATA[LVM 구조]]></category>
		<category><![CDATA[lvs]]></category>
		<category><![CDATA[Mirroring]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[mount point]]></category>
		<category><![CDATA[PE]]></category>
		<category><![CDATA[Physical Disk]]></category>
		<category><![CDATA[Physical Extent]]></category>
		<category><![CDATA[Physical Partition]]></category>
		<category><![CDATA[Physical storage]]></category>
		<category><![CDATA[Physical Volume]]></category>
		<category><![CDATA[PP]]></category>
		<category><![CDATA[PV]]></category>
		<category><![CDATA[pvdisplay]]></category>
		<category><![CDATA[pvs]]></category>
		<category><![CDATA[Quorum]]></category>
		<category><![CDATA[SAN]]></category>
		<category><![CDATA[SAN storage]]></category>
		<category><![CDATA[Server storage]]></category>
		<category><![CDATA[Storage]]></category>
		<category><![CDATA[Storage admin]]></category>
		<category><![CDATA[Storage architecture]]></category>
		<category><![CDATA[Storage concept]]></category>
		<category><![CDATA[Storage hierarchy]]></category>
		<category><![CDATA[Storage layer]]></category>
		<category><![CDATA[storage management]]></category>
		<category><![CDATA[Storage pool]]></category>
		<category><![CDATA[Storage virtualization]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[UNIX admin]]></category>
		<category><![CDATA[UNIX LVM]]></category>
		<category><![CDATA[UNIX storage]]></category>
		<category><![CDATA[VG]]></category>
		<category><![CDATA[VGDA]]></category>
		<category><![CDATA[vgdisplay]]></category>
		<category><![CDATA[vgs]]></category>
		<category><![CDATA[Virtual storage]]></category>
		<category><![CDATA[Volume Group]]></category>
		<category><![CDATA[Volume Group Descriptor Area]]></category>
		<category><![CDATA[Volume management]]></category>
		<category><![CDATA[xfs]]></category>
		<category><![CDATA[가상 스토리지]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[논리 디스크]]></category>
		<category><![CDATA[논리 볼륨]]></category>
		<category><![CDATA[논리 볼륨 관리자]]></category>
		<category><![CDATA[논리 스토리지]]></category>
		<category><![CDATA[논리 파티션]]></category>
		<category><![CDATA[데이터 저장]]></category>
		<category><![CDATA[디스크 관리]]></category>
		<category><![CDATA[디스크 파티션]]></category>
		<category><![CDATA[디스크 할당]]></category>
		<category><![CDATA[마운트]]></category>
		<category><![CDATA[마운트 포인트]]></category>
		<category><![CDATA[물리 디스크]]></category>
		<category><![CDATA[물리 볼륨]]></category>
		<category><![CDATA[물리 스토리지]]></category>
		<category><![CDATA[물리 파티션]]></category>
		<category><![CDATA[미러링]]></category>
		<category><![CDATA[볼륨 관리]]></category>
		<category><![CDATA[볼륨 그룹]]></category>
		<category><![CDATA[블록 디바이스]]></category>
		<category><![CDATA[서버 스토리지]]></category>
		<category><![CDATA[스토리지]]></category>
		<category><![CDATA[스토리지 가상화]]></category>
		<category><![CDATA[스토리지 개념]]></category>
		<category><![CDATA[스토리지 계층]]></category>
		<category><![CDATA[스토리지 관리]]></category>
		<category><![CDATA[스토리지 관리자]]></category>
		<category><![CDATA[스토리지 구조]]></category>
		<category><![CDATA[스토리지 아키텍처]]></category>
		<category><![CDATA[스토리지 풀]]></category>
		<category><![CDATA[시스템 관리]]></category>
		<category><![CDATA[시스템 운영]]></category>
		<category><![CDATA[엔터프라이즈 스토리지]]></category>
		<category><![CDATA[인프라]]></category>
		<category><![CDATA[쿼럼]]></category>
		<category><![CDATA[파일 시스템]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40489</guid>

					<description><![CDATA[<p>LVM의 계층 구조와 주요 개념 LVM(Logical Volume Manager)은 리눅스 및 유닉스 계열 시스템에서 사용자가 논리적인 볼륨 저장소를 설정하고 제어할 수 있도록 하는 운영 체제 명령, 라이브러리 및 도구 세트입니다. (Manager) 이는 실제 물리적 디스크와 응용 프로그램 사이에 장치 드라이버 계층을 두어, 물리적 디스크 구조와 무관하게 스토리지 공간을 논리적으로 관리할 수 있게 해줍니다. (여러 물리적인 디스크들을 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/lvmlogical-volume-manager-%ea%b5%ac%ec%a1%b0-%eb%b0%8f-%ea%b0%9c%eb%85%90/40489/">LVM(Logical Volume Manager) 구조 및 개념</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-472a844f      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lvm의-계층-구조와-주요-개념" class="uagb-toc-link__trigger">LVM의 계층 구조와 주요 개념</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#1-물리적-계층-pv-physical-volume-및-pp-physical-partition" class="uagb-toc-link__trigger">1. 물리적 계층: PV (Physical Volume) 및 PP (Physical Partition)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#pv-physical-volume" class="uagb-toc-link__trigger">PV (Physical Volume)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#pp-physical-partition" class="uagb-toc-link__trigger">PP (Physical Partition)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#관련-명령어" class="uagb-toc-link__trigger">관련 명령어</a></li></ul><li class="uagb-toc__list"><a href="#2-논리적-그룹-계층-vg-volume-group" class="uagb-toc-link__trigger">2. 논리적 그룹 계층: VG (Volume Group)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#vg-volume-group" class="uagb-toc-link__trigger">VG (Volume Group)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#관련-명령어" class="uagb-toc-link__trigger">관련 명령어</a></li></ul><li class="uagb-toc__list"><a href="#3-논리적-할당-계층-lv-logical-volume-및-lp-logical-partition-미러링mirroring" class="uagb-toc-link__trigger">3. 논리적 할당 계층: LV (Logical Volume) 및 LP (Logical Partition) / 미러링(Mirroring)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lv-logical-volume" class="uagb-toc-link__trigger">LV (Logical Volume)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lp-logical-partition" class="uagb-toc-link__trigger">LP (Logical Partition)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#미러링mirroring" class="uagb-toc-link__trigger">미러링(Mirroring)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#관련-명령어" class="uagb-toc-link__trigger">관련 명령어</a></li></ul><li class="uagb-toc__list"><a href="#4-계층-구조의-상위-단계-파일-시스템file-system" class="uagb-toc-link__trigger">4. 계층 구조의 상위 단계: 파일 시스템(File System)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#file-system" class="uagb-toc-link__trigger">File System</a></li></ul><li class="uagb-toc__list"><a href="#주요-개념-요약" class="uagb-toc-link__trigger">주요 개념 요약</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#계층-구조" class="uagb-toc-link__trigger">계층 구조</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#유연성" class="uagb-toc-link__trigger">유연성</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#데이터-무결성" class="uagb-toc-link__trigger">데이터 무결성</a></ul></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">LVM의 계층 구조와 주요 개념</h3>



<p><strong>LVM(Logical Volume Manager)</strong>은 리눅스 및 유닉스 계열 시스템에서 사용자가 논리적인 볼륨 저장소를 설정하고 제어할 수 있도록 하는 운영 체제 명령, 라이브러리 및 도구 세트입니다. (Manager)</p>



<p>이는 실제 <strong>물리적 디스크</strong>와 <strong>응용 프로그램</strong> 사이에 <strong>장치 드라이버 계층</strong>을 두어, <strong>물리적 디스크 구조</strong>와<strong> 무관하게 스토리지 공간을 논리적으로 관리</strong>할 수 있게 해줍니다.</p>



<p>(여러 물리적인 디스크들을 하나의 논리적인 디스크처럼 다룰 수 있게 함 &#8211; 고용량, 고속, 데이터의 무결성 등을 실현 가능)</p>



<ul class="wp-block-list">
<li><strong>LVM이 필요한 이유?</strong></li>
</ul>



<p>기존 파티션 기반 스토리지 관리 방식은 용량 확장이나 재구성이 복잡하고 다운 타임이 발생할 수 있다. </p>



<p>그러나 LVM을 사용하면 하드 드라이브를 재분할할 필요 없이 논리 볼륨을 생성, 크기 조정, 이동 및 삭제할 수 있습니다.</p>



<p>LVM의 진정한 매력은 논리 볼륨과 볼륨 그룹의 크기를 실시간으로 조정할 수 있다는 점에 있습니다.</p>



<p>예를 들어) 갑자기 데이터베이스 용량 필요하다고 해도<strong> LVM을 사용하면 운영 중단 없이 손쉽게 공간을 확장</strong>할 수 있습니다.</p>



<p>LVM은 하드 디스크 위에 얇은 소프트웨어 계층을 덧씌워 하드 드라이브 관리의 연속성과 편의성을 추상화한 것이라고 생각하면 될 것 같습니다.</p>



<div class="wp-block-uagb-container uagb-block-a9759a32 alignfull uagb-is-root-container"><div class="uagb-container-inner-blocks-wrap">
<div class="wp-block-uagb-container uagb-block-9b76df1b">
<figure class="wp-block-image size-full is-resized"><img decoding="async" width="960" height="967" src="https://lycos7560.com/wp-content/uploads/2026/02/Lvm.svg_.png" alt="" class="wp-image-40492" style="width:792px;height:auto" srcset="https://lycos7560.com/wp-content/uploads/2026/02/Lvm.svg_.png 960w, https://lycos7560.com/wp-content/uploads/2026/02/Lvm.svg_-298x300.png 298w, https://lycos7560.com/wp-content/uploads/2026/02/Lvm.svg_-150x150.png 150w, https://lycos7560.com/wp-content/uploads/2026/02/Lvm.svg_-768x774.png 768w" sizes="(max-width: 960px) 100vw, 960px" /><figcaption class="wp-element-caption"><a href="https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)">https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)</a></figcaption></figure>
</div>



<div class="wp-block-uagb-container uagb-block-f0a092a6">
<figure class="wp-block-image size-full has-custom-border"><img decoding="async" width="791" height="481" src="https://lycos7560.com/wp-content/uploads/2026/02/image-8.png" alt="" class="wp-image-40490" style="border-width:1px" srcset="https://lycos7560.com/wp-content/uploads/2026/02/image-8.png 791w, https://lycos7560.com/wp-content/uploads/2026/02/image-8-300x182.png 300w, https://lycos7560.com/wp-content/uploads/2026/02/image-8-768x467.png 768w" sizes="(max-width: 791px) 100vw, 791px" /><figcaption class="wp-element-caption"><a href="https://medium.com/@habibullah.127.0.0.1/what-is-lvm-lvm-architecture-how-to-create-pvs-vgs-lvs-in-linux-30acd24e4f0b" target="_blank" rel="noreferrer noopener">https://medium.com/@habibullah.127.0.0.1/what-is-lvm-lvm-architecture-how-to-create-pvs-vgs-lvs-in-linux-30acd24e4f0b</a></figcaption></figure>
</div>
</div></div>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">1. 물리적 계층: PV (Physical Volume) 및 PP (Physical Partition)</h4>



<h5 class="wp-block-heading"><strong>PV (Physical Volume)</strong></h5>



<p>LVM에서 인식하는 <strong>물리적 디스크 드라이브</strong> 자체를 의미하며, AIX 시스템에서는 <code>hdisk0</code>, <code>hdisk1</code>과 같은 이름으로 표시됩니다.</p>



<p><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6900" class="has-inline-color"><strong>하나의 PV는 </strong></mark>반드시 <mark style="background-color:rgba(0, 0, 0, 0);color:#ff6900" class="has-inline-color"><strong>하나의 VG</strong></mark>에만 속할 수 있습니다.</p>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h5 class="wp-block-heading"><strong><strong>PP (Physical Partition)</strong></strong></h5>



<p>PV를 일정한 크기로 나눈 <strong>최소의 물리적 단위</strong>입니다.</p>



<p>PP의 크기는 1MB에서 1GB까지 설정 가능하며, <mark style="background-color:rgba(0, 0, 0, 0);color:#ff6900" class="has-inline-color"><strong>동일한 VG 내의 모든 PV</strong></mark>는<mark style="background-color:rgba(0, 0, 0, 0);color:#ff6900" class="has-inline-color"><strong> 동일한 크기의 PP</strong></mark>를 가집니다.</p>



<h5 class="wp-block-heading"><strong><strong>관련 명령어</strong></strong></h5>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 하드 디스크 총 개수, 파티션 수, 저장 용량 및 사용 가능 용량을 확인
- Linux
lsblk
- AIX
lsdev -Cc disk

# Physical Volumes 총 개수
- Linux
pvs
pvdisplay
- AIX
lspv
lspv hdisk0</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">2. 논리적 그룹 계층: VG (Volume Group)</h4>



<h5 class="wp-block-heading"><strong><strong>VG (Volume Group)</strong></strong></h5>



<p>하나 이상의 <strong>PV들을 논리적으로 묶은 집합체</strong>입니다.</p>



<p>VG 내의 디스크들은 PP라는 단위로 쪼개져 관리되며, 이를 통해 여러 <strong>물리적 디스크에 걸쳐 있는 논리적 볼륨을 생성하는 등 유연한 관리가 가능</strong>해집니다.</p>



<p>데이터 보호를 위해 미러링을 설정하면, <strong>하나의 LP가 2개 또는 3개의 PP에 대응</strong>되어 동일한 데이터 사본을 여러 곳에 저장하게 됩니다.</p>



<h5 class="wp-block-heading"><strong><strong>관련 명령어</strong></strong></h5>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Volume groups 확인
- Linux
vgs
vgdisplay
- AIX
lsvg
lsvg vgname</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">3. 논리적 할당 계층: LV (Logical Volume) 및 LP (Logical Partition) / <strong>미러링(Mirroring)</strong></h4>



<h5 class="wp-block-heading"><strong><strong><strong>LV (Logical Volume)</strong></strong></strong></h5>



<p>사용자가 실제 데이터를 저장하기 위해 VG 내에서 정의하는 <strong>논리적인 저장 공간</strong>입니다.</p>



<p>LV는 사용자에게는 연속된 공간으로 보이지만, <strong>실제 물리적 위치(PP)는 디스크 상에서 흩어져 있거나 여러 PV에 걸쳐 있을 수 있습니다</strong>.</p>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h5 class="wp-block-heading"><strong><strong><strong><strong>LP (Logical Partition)</strong></strong></strong></strong></h5>



<p>LV를 구성하는 <strong>최소 논리 단위</strong>로, <strong>하나 이상의 PP</strong>에 대응됩니다.</p>



<p>※ 참고: AIX에서는 LP/PP라는 용어를 사용하며,<br>Linux LVM에서는 LE/PE(Extent)라는 용어를 사용한다.</p>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h5 class="wp-block-heading"><strong><strong><strong><strong><strong>미러링(Mirroring)</strong></strong></strong></strong></strong></h5>



<p>데이터 보호를 위해 미러링을 설정하면, <strong>하나의 LP가 2개 또는 3개의 PP에 대응</strong>되어 동일한 데이터 사본을 여러 곳에 저장하게 됩니다.</p>



<h5 class="wp-block-heading"><strong><strong>관련 명령어</strong></strong></h5>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Logical volumes 확인
- Linux
lvs
lvdisplay
- AIX
lslv
lslv lvname</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">4. 계층 구조의 상위 단계: 파일 시스템(File System)</h4>



<h5 class="wp-block-heading"><strong><strong><strong>File System</strong></strong></strong></h5>



<p>LV 위에 구축되어 사용자가 <strong>실제 파일을 저장하고 접근할 수 있도록 하는 논리적인 구조</strong>입니다.</p>



<p>생성된 <strong>LV 위에는 JFS 또는 JFS2와 같은 파일 시스템</strong>이 구축되거나, 페이징 공간(Paging Space)으로 사용됩니다.</p>



<p>운영체제는 이러한 파일 시스템을 통해 파일을 저장하고 관리합니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:0;margin-bottom:0"/>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">주요 개념 요약</h4>



<h5 class="wp-block-heading"><strong><strong><strong><strong>계층 구조</strong></strong></strong></strong></h5>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">PV(PP) → VG → LV(LP) → 파일 시스템</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h5 class="wp-block-heading"><strong><strong><strong><strong><strong>유연성</strong></strong></strong></strong></strong></h5>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">LVM을 사용하면 운영 중에 파일 시스템의 용량을 늘리거나 줄이는 것이 가능하며, 
물리적인 디스크 한계를 넘어 스토리지를 효율적으로 관리할 수 있습니다</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h5 class="wp-block-heading"><strong><strong><strong><strong><strong><strong>데이터 무결성</strong></strong></strong></strong></strong></strong></h5>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">VGDA(Volume Group Descriptor Area)와 같은 영역에 LVM 구조 정보를 저장하여 관리하며, 
쿼럼(Quorum) 메커니즘을 통해 디스크 장애 시에도 데이터의 무결성을 보장합니다.</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="[리눅스 기초 강의] 41강. 6.3 LVM(Logical Volume Manage)" width="1778" height="1000" src="https://www.youtube.com/embed/eb2cDW-zXlI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p></p>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/lvmlogical-volume-manager-%ea%b5%ac%ec%a1%b0-%eb%b0%8f-%ea%b0%9c%eb%85%90/40489/">LVM(Logical Volume Manager) 구조 및 개념</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/lvmlogical-volume-manager-%ea%b5%ac%ec%a1%b0-%eb%b0%8f-%ea%b0%9c%eb%85%90/40489/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux Development Tools Install</title>
		<link>https://lycos7560.com/etc/linux-development-tools-install/40476/</link>
					<comments>https://lycos7560.com/etc/linux-development-tools-install/40476/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Mon, 16 Feb 2026 22:31:03 +0000</pubDate>
				<category><![CDATA[기타]]></category>
		<category><![CDATA[autoconf]]></category>
		<category><![CDATA[automake]]></category>
		<category><![CDATA[C 언어]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[C++ 언어]]></category>
		<category><![CDATA[CI/CD]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[dnf]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[glibc-devel]]></category>
		<category><![CDATA[groupinstall]]></category>
		<category><![CDATA[How-to 가이드]]></category>
		<category><![CDATA[kernel-devel]]></category>
		<category><![CDATA[kernel-headers]]></category>
		<category><![CDATA[libstdc++-devel]]></category>
		<category><![CDATA[libtool]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux 개발 환경]]></category>
		<category><![CDATA[Linux 관리]]></category>
		<category><![CDATA[Linux 설치]]></category>
		<category><![CDATA[Linux 정보]]></category>
		<category><![CDATA[Linux 초보자]]></category>
		<category><![CDATA[Linux 커널]]></category>
		<category><![CDATA[Linux 컴파일]]></category>
		<category><![CDATA[Linux 팁]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[OS 개발]]></category>
		<category><![CDATA[Rocky]]></category>
		<category><![CDATA[Rocky Linux]]></category>
		<category><![CDATA[Rocky Linux 설치]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[vmtoolsd]]></category>
		<category><![CDATA[VMware Tools]]></category>
		<category><![CDATA[VMware Workstation]]></category>
		<category><![CDATA[가상 머신]]></category>
		<category><![CDATA[개발 입문]]></category>
		<category><![CDATA[개발 정보]]></category>
		<category><![CDATA[개발 튜토리얼]]></category>
		<category><![CDATA[개발 팁]]></category>
		<category><![CDATA[개발 필수 도구]]></category>
		<category><![CDATA[개발 환경]]></category>
		<category><![CDATA[개발자 가이드]]></category>
		<category><![CDATA[개발자 도구]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기술 문서]]></category>
		<category><![CDATA[기술 블로그]]></category>
		<category><![CDATA[기술 정보]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[단계별 설명]]></category>
		<category><![CDATA[드라이버 개발]]></category>
		<category><![CDATA[디버거]]></category>
		<category><![CDATA[라이브러리 빌드]]></category>
		<category><![CDATA[링킹]]></category>
		<category><![CDATA[바이너리 생성]]></category>
		<category><![CDATA[백엔드 개발]]></category>
		<category><![CDATA[버전 관리]]></category>
		<category><![CDATA[비유 설명]]></category>
		<category><![CDATA[빌드 과정]]></category>
		<category><![CDATA[빌드 관리]]></category>
		<category><![CDATA[빌드 도구]]></category>
		<category><![CDATA[빌드 자동화]]></category>
		<category><![CDATA[상세 설명]]></category>
		<category><![CDATA[서버 개발]]></category>
		<category><![CDATA[설치 가이드]]></category>
		<category><![CDATA[성능 최적화]]></category>
		<category><![CDATA[소스 코드]]></category>
		<category><![CDATA[소스 코드 컴파일]]></category>
		<category><![CDATA[소프트웨어 개발]]></category>
		<category><![CDATA[소프트웨어 빌드]]></category>
		<category><![CDATA[소프트웨어 설치]]></category>
		<category><![CDATA[소프트웨어 아키텍처]]></category>
		<category><![CDATA[시스템 개발]]></category>
		<category><![CDATA[시스템 관리]]></category>
		<category><![CDATA[시스템 구축]]></category>
		<category><![CDATA[시스템 프로그래밍]]></category>
		<category><![CDATA[실습 환경]]></category>
		<category><![CDATA[실전 가이드]]></category>
		<category><![CDATA[에뮬레이션]]></category>
		<category><![CDATA[오류 해결]]></category>
		<category><![CDATA[오픈소스]]></category>
		<category><![CDATA[오픈소스 개발]]></category>
		<category><![CDATA[운영체제]]></category>
		<category><![CDATA[의존성 관리]]></category>
		<category><![CDATA[이해하기 쉬운 설명]]></category>
		<category><![CDATA[임베디드 시스템]]></category>
		<category><![CDATA[자동화]]></category>
		<category><![CDATA[자동화 빌드]]></category>
		<category><![CDATA[주의사항]]></category>
		<category><![CDATA[초보자 가이드]]></category>
		<category><![CDATA[커널 개발]]></category>
		<category><![CDATA[커널 모듈]]></category>
		<category><![CDATA[커널 헤더]]></category>
		<category><![CDATA[컴파일 과정]]></category>
		<category><![CDATA[컴파일 도구]]></category>
		<category><![CDATA[컴파일러]]></category>
		<category><![CDATA[컴퓨터 아키텍처]]></category>
		<category><![CDATA[클라우드 개발]]></category>
		<category><![CDATA[튜토리얼]]></category>
		<category><![CDATA[트러블슈팅]]></category>
		<category><![CDATA[패키지 관리]]></category>
		<category><![CDATA[패키지 설치]]></category>
		<category><![CDATA[프로그래밍]]></category>
		<category><![CDATA[프로그래밍 도구]]></category>
		<category><![CDATA[학습 가이드]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40476</guid>

					<description><![CDATA[<p>Development Tools (개발 도구 모음) ? Linux에서 소프트웨어를 개발하고 컴파일하는 데 필요한 도구들의 패키지입니다. 예를 들어 &#8220;VMware Tools&#8221;처럼 C/C++ 소스 코드로 작성된 프로그램을 설치할 때 반드시 필요합니다. 설치 명령 부분 의미 주의 sudo 관리자 권한 필수! dnf Rocky Linux 패키지 매니저 Ubuntu는 apt groupinstall 패키지 그룹 설치 install과 다름 "Development Tools" 그룹 이름 따옴표 필수 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/linux-development-tools-install/40476/">Linux Development Tools Install</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-7dc8e9d1      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#development-tools-개발-도구-모음" class="uagb-toc-link__trigger">Development Tools (개발 도구 모음) ?</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#설치-명령" class="uagb-toc-link__trigger">설치 명령</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#설치-시간-및-용량" class="uagb-toc-link__trigger">설치 시간 및 용량</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#설치-결과" class="uagb-toc-link__trigger">설치 결과</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#주요-설치-파일-cc-기준" class="uagb-toc-link__trigger">주요 설치 파일 (C/C++ 기준)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#컴파일러-compiler" class="uagb-toc-link__trigger">컴파일러 (Compiler)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#빌드-도구-build-tools" class="uagb-toc-link__trigger">빌드 도구 (Build Tools)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#커널-개발-패키지-kernel-development" class="uagb-toc-link__trigger">커널 개발 패키지 (Kernel Development)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#라이브러리-개발-패키지-library-development" class="uagb-toc-link__trigger">라이브러리 개발 패키지 (Library Development)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#추가-개발-도구" class="uagb-toc-link__trigger">추가 개발 도구</a></li></ul><li class="uagb-toc__list"><a href="#참고-및-주의사항" class="uagb-toc-link__trigger">참고 및 주의사항</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#groupinstall-vs-install" class="uagb-toc-link__trigger">groupinstall vs install</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#설치-확인" class="uagb-toc-link__trigger">설치 확인</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#오류-발생-시" class="uagb-toc-link__trigger">오류 발생 시</a></ul></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">Development Tools (개발 도구 모음) ?</h2>



<p>Linux에서 소프트웨어를 <strong>개발하고 컴파일하는 데 필요한 도구들의 패키지</strong>입니다.</p>



<p>예를 들어 &#8220;VMware Tools&#8221;처럼 <strong>C/C++ 소스 코드로 작성된 프로그램</strong>을 설치할 때 반드시 필요합니다.</p>



<h3 class="wp-block-heading">설치 명령</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">rocky linux

dnf groupinstall "Development Tools" -y

// vm-tool 설치 (Rocky Linux 공식 저장소에서 설치, ISO 방식이 아님)
sudo dnf install open-vm-tools open-vm-tools-desktop -y
</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>부분</th><th>의미</th><th>주의</th></tr></thead><tbody><tr><td><code>sudo</code></td><td>관리자 권한</td><td>필수!</td></tr><tr><td><code>dnf</code></td><td>Rocky Linux 패키지 매니저</td><td>Ubuntu는 <code>apt</code></td></tr><tr><td><code>groupinstall</code></td><td>패키지 <strong>그룹</strong> 설치</td><td><code>install</code>과 다름</td></tr><tr><td><code>"Development Tools"</code></td><td>그룹 이름</td><td><strong>따옴표 필수</strong></td></tr><tr><td><code>-y</code></td><td>Yes 자동 응답</td><td>사용자 입력 생략</td></tr></tbody></table></figure>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--40)"/>



<h3 class="wp-block-heading">설치 시간 및 용량</h3>



<ul class="wp-block-list">
<li><strong>예상 시간:</strong> 3-5분</li>



<li><strong>설치 크기:</strong> ~1GB</li>



<li><strong>필요 디스크:</strong> ~2GB</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20)"/>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">설치 결과</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">20260217 설치 결과는 Rocky Linux 버전 및 시간에 따라 다를 수 있습니다.

--------------

Installed:
  annobin-docs-12.99-1.el10.noarch                 annobin-plugin-gcc-12.99-1.el10.x86_64               asciidoc-10.2.0-12.el10.noarch                   autoconf-2.71-13.el10.noarch                                   
  automake-1.16.5-20.el10.noarch                   bison-3.8.2-9.el10.x86_64                            boost-atomic-1.83.0-5.el10.x86_64                boost-filesystem-1.83.0-5.el10.x86_64                          
  boost-regex-1.83.0-5.el10.x86_64                 boost-system-1.83.0-5.el10.x86_64                    boost-thread-1.83.0-5.el10.x86_64                byacc-2.0.20230521-7.el10.x86_64                               
  cmake-filesystem-3.30.5-3.el10_0.x86_64          cpp-14.3.1-2.1.el10.x86_64                           debugedit-5.1-8.el10.x86_64                      diffstat-1.66-3.el10.x86_64                                    
  docbook-dtds-1.0-92.el10.noarch                  docbook-style-xsl-1.79.2-30.el10.noarch              dwz-0.16-1.el10.x86_64                           dyninst-13.0.0-1.el10.x86_64                                   
  efi-srpm-macros-6-7.el10.noarch                  efivar-libs-39-3.el10.x86_64                         elfutils-0.193-1.el10.rocky.0.1.x86_64           elfutils-debuginfod-client-devel-0.193-1.el10.rocky.0.1.x86_64 
  elfutils-devel-0.193-1.el10.rocky.0.1.x86_64     elfutils-libelf-devel-0.193-1.el10.rocky.0.1.x86_64  flex-2.6.4-19.el10.x86_64                        fonts-srpm-macros-1:2.0.5-18.el10.noarch                       
  forge-srpm-macros-0.4.0-6.el10.noarch            gcc-14.3.1-2.1.el10.x86_64                           gcc-c++-14.3.1-2.1.el10.x86_64                   gcc-plugin-annobin-14.3.1-2.1.el10.x86_64                      
  gdb-16.3-2.el10.x86_64                           gdb-headless-16.3-2.el10.x86_64                      gettext-common-devel-0.22.5-6.el10.noarch        gettext-devel-0.22.5-6.el10.x86_64                             
  git-2.47.3-1.el10.x86_64                         git-core-2.47.3-1.el10.x86_64                        git-core-doc-2.47.3-1.el10.noarch                glibc-devel-2.39-58.el10_1.7.x86_64                            
  go-srpm-macros-3.6.0-4.el10.noarch               graphviz-9.0.0-15.el10.x86_64                        intltool-0.51.0-29.el10.noarch                   javapackages-filesystem-6.4.0-1.el10.noarch                    
  jna-5.14.0-7.el10.x86_64                         kernel-devel-6.12.0-124.35.1.el10_1.x86_64           kernel-headers-6.12.0-124.35.1.el10_1.x86_64     kernel-srpm-macros-1.0-26.el10.noarch                          
  libipt-2.1-5.el10.x86_64                         libstdc++-devel-14.3.1-2.1.el10.x86_64               libtool-2.4.7-13.el10.x86_64                     libxcrypt-devel-4.4.36-10.el10.x86_64                          
  libzstd-devel-1.5.5-9.el10.x86_64                ltrace-0.7.91-52.el10.x86_64                         lua-srpm-macros-1-15.el10.noarch                 m4-1.4.19-11.el10.x86_64                                       
  make-1:4.4.1-9.el10.x86_64                       mokutil-2:0.7.2-1.el10.x86_64                        nss-tools-3.112.0-4.el10_0.x86_64                ocaml-srpm-macros-10-4.el10.noarch                             
  openblas-srpm-macros-2-19.el10.noarch            openssl-devel-1:3.5.1-7.el10_1.x86_64                package-notes-srpm-macros-0.5-13.el10.noarch     patch-2.7.6-26.el10.x86_64                                     
  patchutils-0.4.2-15.el10.x86_64                  perl-Clone-0.46-10.el10.x86_64                       perl-Compress-Raw-Bzip2-2.212-512.el10.x86_64    perl-Compress-Raw-Zlib-2.212-513.el10_1.x86_64                 
  perl-Data-Dump-1.25-13.el10.noarch               perl-Digest-HMAC-1.04-12.el10.noarch                 perl-Digest-SHA-1:6.04-512.el10.x86_64           perl-Encode-Locale-1.05-31.el10.noarch                         
  perl-Error-1:0.17029-18.el10.noarch              perl-Fedora-VSP-0.001-36.el10.noarch                 perl-File-Compare-1.100.800-512.2.el10_0.noarch  perl-File-Copy-2.41-512.2.el10_0.noarch                        
  perl-File-Listing-6.16-5.el10.noarch             perl-Git-2.47.3-1.el10.noarch                        perl-HTML-Parser-3.82-3.el10.x86_64              perl-HTML-Tagset-3.20-59.el10.noarch                           
  perl-HTTP-Cookies-6.11-5.el10.noarch             perl-HTTP-Date-6.06-6.el10.noarch                    perl-HTTP-Message-6.45-5.el10.noarch             perl-HTTP-Negotiate-6.01-40.el10.noarch                        
  perl-I18N-Langinfo-0.24-512.2.el10_0.x86_64      perl-IO-Compress-2.212-512.el10.noarch               perl-IO-HTML-1.004-14.el10.noarch                perl-LWP-MediaTypes-6.04-19.el10.noarch                        
  perl-Module-Load-1:0.36-511.el10.noarch          perl-NTLM-1.09-41.el10.noarch                        perl-Net-HTTP-6.23-6.el10.noarch                 perl-TermReadKey-2.38-24.el10.x86_64                           
  perl-Thread-Queue-3.14-511.el10.noarch           perl-TimeDate-1:2.33-16.el10.noarch                  perl-Try-Tiny-0.31-12.el10.noarch                perl-WWW-RobotRules-6.02-41.el10.noarch                        
  perl-XML-Parser-2.47-6.el10.x86_64               perl-generators-1.16-7.el10.noarch                   perl-lib-0.65-512.2.el10_0.x86_64                perl-libwww-perl-6.76-3.el10.noarch                            
  perl-macros-4:5.40.2-512.2.el10_0.noarch         perl-srpm-macros-1-57.el10.noarch                    perl-subs-1.04-512.2.el10_0.noarch               perl-threads-1:2.40-511.el10.x86_64                            
  perl-threads-shared-1.69-511.el10.x86_64         perl-version-8:0.99.32-4.el10.x86_64                 pesign-116-6.el10.x86_64                         pyproject-srpm-macros-1.16.2-1.el10.noarch                     
  python-srpm-macros-3.12-10.el10.noarch           qt6-srpm-macros-6.9.1-1.el10.noarch                  redhat-rpm-config-293-1.el10.rocky.0.2.noarch    rpm-build-4.19.1.1-20.el10.x86_64                              
  rpm-sign-4.19.1.1-20.el10.x86_64                 rust-toolset-srpm-macros-1.88.0-1.el10.noarch        sgml-common-0.6.3-65.el10.noarch                 source-highlight-3.1.9-25.el10.x86_64                          
  systemd-rpm-macros-257-13.el10.rocky.0.1.noarch  systemtap-5.3-3b.el10.x86_64                         systemtap-client-5.3-3b.el10.x86_64              systemtap-devel-5.3-3b.el10.x86_64                             
  systemtap-runtime-5.3-3b.el10.x86_64             tbb-2021.11.0-7.el10.x86_64                          valgrind-1:3.25.1-3.el10.x86_64                  valgrind-devel-1:3.25.1-3.el10.x86_64                          
  valgrind-docs-1:3.25.1-3.el10.x86_64             valgrind-gdb-1:3.25.1-3.el10.x86_64                  valgrind-scripts-1:3.25.1-3.el10.x86_64          xz-devel-1:5.6.2-4.el10_0.x86_64                               
  zlib-ng-compat-devel-2.2.3-3.el10_1.x86_64       zstd-1.5.5-9.el10.x86_64                            

Complete!</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20)"/>



<h3 class="wp-block-heading">주요 설치 파일 (C/C++ 기준)</h3>



<h4 class="wp-block-heading">컴파일러 (Compiler)</h4>



<p>소스 코드(.c, .cpp) → 기계어 실행파일로 변환</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gcc-14.3.1           → C 언어 컴파일러
gcc-c++-14.3.1       → C++ 언어 컴파일러</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">빌드 도구 (Build Tools)</h4>



<p>컴파일러 옵션 자동 설정 / 복잡한 빌드 과정 자동화 / 어떤 파일을 먼저 컴파일할지 관리 등&#8230;</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">make-4.4.1           → 자동 빌드 관리
autoconf-2.71        → 자동 설정 생성
automake-1.16.5      → Makefile 자동 생성</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">커널 개발 패키지 (Kernel Development)</h4>



<p><strong>역할:</strong> 커널과 상호작용하는 모듈 작성 가능</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">kernel-devel-6.12.0-124.35.1
kernel-headers-6.12.0-124.35.1
-----------------------------------------------
설치 명령어
sudo dnf install kernel-devel kernel-headers -y </pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">라이브러리 개발 패키지 (Library Development)</h4>



<p><strong>역할:</strong> 컴파일된 코드를 실행 가능 파일로 연결 (링킹)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">glibc-devel-2.39           → C 표준 라이브러리
libstdc++-devel-14.3.1     → C++ 표준 라이브러리
-----------------------------------------------
모든 C/C++ 프로그램의 기본 함수 제공
printf(), malloc() 등의 함수 구현</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">추가 개발 도구</h4>



<p>Git: 소스 코드 변경 이력 관리, GDB: 프로그램 실행 중 오류 추적, libtool: 공유 라이브러리(.so) 빌드</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git-2.47.3           → 소스 코드 버전 관리
gdb-16.3             → 프로그램 디버거
libtool-2.4.7        → 라이브러리 빌드 도구</pre>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"/>



<h3 class="wp-block-heading">참고 및 주의사항</h3>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">groupinstall vs install</h4>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/274c.png" alt="❌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 잘못된 방법 (의존성 부족 가능)
sudo dnf install gcc

# <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 올바른 방법 (모든 관련 도구 자동 설치)
sudo dnf groupinstall "Development Tools" -y</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">설치 확인</h4>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 컴파일러 확인
gcc --version

# Make 확인
make --version

# 커널 헤더 확인
ls /usr/src/kernels/</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<h4 class="wp-block-heading">오류 발생 시</h4>



<p><strong>네트워크 오류:</strong></p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo dnf clean all
sudo dnf groupinstall "Development Tools" -y</pre>



<p><strong>의존성 충돌:</strong></p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo dnf groupinstall "Development Tools" --allowerasing -y</pre>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/linux-development-tools-install/40476/">Linux Development Tools Install</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/linux-development-tools-install/40476/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
