<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[RSS Feed of jiu's blog]]></title><description><![CDATA[잘 기록하기]]></description><link>https://jiu-jung.github.io</link><generator>GatsbyJS</generator><lastBuildDate>Thu, 16 Apr 2026 12:24:37 GMT</lastBuildDate><item><title><![CDATA[Bash Script: 운영 자동화 실습]]></title><description><![CDATA[운영 자동화 실습 서비스 헬스체크 + 최근 journal 저장 서비스가 내려가 있으면 최근 부팅 기준 로그를 바로 파일로 저장한다.  안전하게 스크립트 작성하기…]]></description><link>https://jiu-jung.github.io/rhel-bash-automation/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-bash-automation/</guid><pubDate>Thu, 16 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;운영-자동화-실습&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%B4%EC%98%81-%EC%9E%90%EB%8F%99%ED%99%94-%EC%8B%A4%EC%8A%B5&quot; aria-label=&quot;운영 자동화 실습 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;운영 자동화 실습&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;서비스-헬스체크--최근-journal-저장&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%84%9C%EB%B9%84%EC%8A%A4-%ED%97%AC%EC%8A%A4%EC%B2%B4%ED%81%AC--%EC%B5%9C%EA%B7%BC-journal-%EC%A0%80%EC%9E%A5&quot; aria-label=&quot;서비스 헬스체크  최근 journal 저장 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;서비스 헬스체크 + 최근 journal 저장&lt;/h3&gt;
&lt;p&gt;서비스가 내려가 있으면 최근 부팅 기준 로그를 바로 파일로 저장한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt;

&lt;span class=&quot;token assign-left variable&quot;&gt;SERVICE&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;${1&lt;span class=&quot;token operator&quot;&gt;:-&lt;/span&gt;sshd}&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;OUT_DIR&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/var/tmp/service-check&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;TS&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;date&lt;/span&gt; +&lt;span class=&quot;token string&quot;&gt;&quot;%Y%m%d-%H%M%S&quot;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$OUT_DIR&lt;/span&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; systemctl is-active &lt;span class=&quot;token parameter variable&quot;&gt;--quiet&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;${SERVICE}&lt;/span&gt;.service&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[OK] &lt;span class=&quot;token variable&quot;&gt;${SERVICE}&lt;/span&gt;.service is active&quot;&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;exit&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[FAIL] &lt;span class=&quot;token variable&quot;&gt;${SERVICE}&lt;/span&gt;.service is not active&quot;&lt;/span&gt;

    &lt;span class=&quot;token assign-left variable&quot;&gt;LOG_FILE&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;${OUT_DIR}&lt;/span&gt;/&lt;span class=&quot;token variable&quot;&gt;${SERVICE}&lt;/span&gt;-&lt;span class=&quot;token variable&quot;&gt;${TS}&lt;/span&gt;.log&quot;&lt;/span&gt;

    journalctl &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;${SERVICE}&lt;/span&gt;.service&quot;&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-b&lt;/span&gt; --no-pager &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$LOG_FILE&lt;/span&gt;&quot;&lt;/span&gt;

    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[INFO] recent boot log saved to: &lt;span class=&quot;token variable&quot;&gt;$LOG_FILE&lt;/span&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;exit&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/bc38e0a78af51250850aa16b453000b7/fb44e/exec.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 48.23529411764706%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAABYlAAAWJQFJUiTwAAAB6UlEQVR42q2Sz27TQBDGt6gVUIoak7YksbETYif22vGf2GlS2vIKIPUROHCoQE1KCkEIiQfoq4BPfZIqyE+B1BMiWn3MOA3cEYfRtzua/eY3oxW4KY5v8ONk8XPxAsDLfwh+dwL8OhZCrInp+HT+4ctnnE0u1PnFDNPZJ0xIz99/xNvxFG/G7/7G2VI5vwrKqcl0hlevT6+llFvCcoLC8SKYbVcZzQ50y0FlV8f2TgN3t6oUj5b6sHp717B+v4L1zcpK1camho0H2lwIbVv0kv2iPzxC2B+qIB6gv3+IKD1AnB2UGpEmg8My3w364OaW7aHpSFJJIJ6y2h729OZcaGTY9ZOCH/XI0CfDpcEzvpdnP8pATbkhOn6MsiYdIaCcDFN4Yaq8XoqdukmEggwDMiQSKlBctKJjAyYO6TGf2Yhq/+SZ1KYgVS3HR/WxMdeY0PXj79yRKBZUqIhKEaFiYjJWRMHkildChrwWOo9UmNJE0UDJKFvIMCNC67ok9OOsSEfPkQ6PVEyj8ri8r3hwu8Nyj7yCEY2XlWtgat5nx0/QkbFquyF2G80loe35l10ZXrm95JsbJHnDfJobLSfXLbuM1ZnzNaOVG5w37bymt8p77Unr617dvKpU65dEeE+Un1GIO/8h2GftN8HgKBMcuW9RAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;exec&apos; title=&apos;&apos; src=&apos;/static/bc38e0a78af51250850aa16b453000b7/ca1dc/exec.png&apos; srcset=&apos;/static/bc38e0a78af51250850aa16b453000b7/e7570/exec.png 170w,
/static/bc38e0a78af51250850aa16b453000b7/f46e7/exec.png 340w,
/static/bc38e0a78af51250850aa16b453000b7/ca1dc/exec.png 680w,
/static/bc38e0a78af51250850aa16b453000b7/02d09/exec.png 1020w,
/static/bc38e0a78af51250850aa16b453000b7/9d567/exec.png 1360w,
/static/bc38e0a78af51250850aa16b453000b7/fb44e/exec.png 2180w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;안전하게-스크립트-작성하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%95%88%EC%A0%84%ED%95%98%EA%B2%8C-%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-%EC%9E%91%EC%84%B1%ED%95%98%EA%B8%B0&quot; aria-label=&quot;안전하게 스크립트 작성하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;안전하게 스크립트 작성하기&lt;/h2&gt;
&lt;h4 id=&quot;1-테스트-환경에서-먼저-실행하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-%ED%85%8C%EC%8A%A4%ED%8A%B8-%ED%99%98%EA%B2%BD%EC%97%90%EC%84%9C-%EB%A8%BC%EC%A0%80-%EC%8B%A4%ED%96%89%ED%95%98%EA%B8%B0&quot; aria-label=&quot;1 테스트 환경에서 먼저 실행하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. 테스트 환경에서 먼저 실행하기&lt;/h4&gt;
&lt;p&gt;운영 서버에서 바로 실행하기보다, 테스트용 디렉터리나 샘플 파일로 먼저 동작을 검증하는 것이 좋다.&lt;/p&gt;
&lt;p&gt;예를 들어 로그 정리 스크립트라면 실제 &lt;code class=&quot;language-text&quot;&gt;/var/log&lt;/code&gt; 대신&lt;br&gt;
직접 만든 &lt;code class=&quot;language-text&quot;&gt;./test-logs&lt;/code&gt; 디렉터리에서 먼저 실행해볼 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;h4 id=&quot;2-절대-경로-사용하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-%EC%A0%88%EB%8C%80-%EA%B2%BD%EB%A1%9C-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0&quot; aria-label=&quot;2 절대 경로 사용하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. 절대 경로 사용하기&lt;/h4&gt;
&lt;p&gt;스크립트는 실행 위치에 따라 상대 경로가 달라질 수 있다.&lt;br&gt;
그래서 중요한 작업일수록 절대 경로를 쓰는 편이 더 안전하다.&lt;/p&gt;
&lt;p&gt;예를 들어:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;LOG_FILE&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/var/log/app.log&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h4 id=&quot;3-삭제-명령rm-주의하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-%EC%82%AD%EC%A0%9C-%EB%AA%85%EB%A0%B9rm-%EC%A3%BC%EC%9D%98%ED%95%98%EA%B8%B0&quot; aria-label=&quot;3 삭제 명령rm 주의하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3. 삭제 명령(&lt;code class=&quot;language-text&quot;&gt;rm&lt;/code&gt;) 주의하기&lt;/h4&gt;
&lt;p&gt;삭제 명령은 가장 조심해야 한다.&lt;br&gt;
특히 변수와 함께 사용할 때는 값이 비어 있거나 예상과 다르면 위험해질 수 있다.&lt;/p&gt;
&lt;p&gt;예를 들어 아래 같은 명령은 항상 신중해야 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-rf&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$TARGET_DIR&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;삭제 작업을 넣기 전에는 먼저 &lt;code class=&quot;language-text&quot;&gt;echo&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;ls&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;find&lt;/code&gt; 등으로&lt;br&gt;
&lt;strong&gt;정말 원하는 대상이 맞는지 확인하는 단계&lt;/strong&gt;를 거치는 것이 좋다.&lt;/p&gt;
&lt;br&gt;
&lt;h4 id=&quot;4-root-권한-스크립트-주의하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-root-%EA%B6%8C%ED%95%9C-%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-%EC%A3%BC%EC%9D%98%ED%95%98%EA%B8%B0&quot; aria-label=&quot;4 root 권한 스크립트 주의하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;4. root 권한 스크립트 주의하기&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;sudo&lt;/code&gt;나 root 권한으로 실행되는 스크립트는 영향 범위가 훨씬 크다.&lt;br&gt;
파일 삭제, 계정 변경, 패키지 설치 같은 작업은 시스템 전체에 영향을 줄 수 있다.&lt;/p&gt;
&lt;p&gt;초기 학습 단계에서는&lt;br&gt;
가능하면 root 권한이 필요 없는 작업부터 연습하는 것이 안전하다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Bash Script: 조건문, 반복문, 함수]]></title><description><![CDATA[이 글에서는 Bash…]]></description><link>https://jiu-jung.github.io/rhel-bash-control/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-bash-control/</guid><pubDate>Wed, 15 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;이 글에서는 Bash 스크립트의 다음 내용들을 다룬다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-control/#%EC%A1%B0%EA%B1%B4%EB%AC%B8&quot;&gt;조건문&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-control/#%EB%B0%98%EB%B3%B5%EB%AC%B8&quot;&gt;반복문&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-control/#%ED%95%A8%EC%88%98&quot;&gt;함수&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-control/#%EB%AA%85%EB%A0%B9%EC%96%B4-%EC%B9%98%ED%99%98&quot;&gt;명령어 치환&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-control/#%EC%9A%B4%EC%98%81-%EC%9E%90%EB%8F%99%ED%99%94%EC%97%90%EC%84%9C-%EC%9E%90%EC%A3%BC-%EC%93%B0%EC%9D%B4%EB%8A%94-%EC%9A%94%EC%86%8C&quot;&gt;운영 자동화에서 자주 쓰이는 요소&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;조건문&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A1%B0%EA%B1%B4%EB%AC%B8&quot; aria-label=&quot;조건문 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;조건문&lt;/h2&gt;
&lt;h3 id=&quot;기본-구조&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B8%B0%EB%B3%B8-%EA%B5%AC%EC%A1%B0&quot; aria-label=&quot;기본 구조 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;기본 구조&lt;/h3&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; 조건1 &lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    명령1
&lt;span class=&quot;token keyword&quot;&gt;elif&lt;/span&gt; 조건2 &lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    명령2
&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
	명령3
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;조건 자리에는 다음 두 가지가 올 수 있다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;[ ... ]&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;[[ ... ]]&lt;/code&gt; 같은 비교식/검사식&lt;/li&gt;
&lt;li&gt;일반 명령어 또는 파이프라인&lt;br&gt;
종료 코드가 &lt;code class=&quot;language-text&quot;&gt;0&lt;/code&gt;이면 참, 아니면 거짓&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;비교식검사식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B9%84%EA%B5%90%EC%8B%9D%EA%B2%80%EC%82%AC%EC%8B%9D&quot; aria-label=&quot;비교식검사식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;비교식/검사식&lt;/h3&gt;
&lt;p&gt;비교식/검사식을 을 사용할 때는 다음 두 가지를 주의해야 한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;앞뒤 공백이 꼭 필요하다.&lt;/li&gt;
&lt;li&gt;문자열 변수는 큰따옴표로 감싸는 것이 안전하다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;운영 스크립트에서 자주 사용하는 조건식은 크게 아래 세 가지다.&lt;/p&gt;
&lt;h4 id=&quot;1-파일-존재-여부&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-%ED%8C%8C%EC%9D%BC-%EC%A1%B4%EC%9E%AC-%EC%97%AC%EB%B6%80&quot; aria-label=&quot;1 파일 존재 여부 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. 파일 존재 여부&lt;/h4&gt;
&lt;p&gt;파일이나 디렉터리가 실제로 있는지 검사할 때 사용한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; backup.log &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;file exists&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; /var/log &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;log directory exists&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;자주 쓰는 파일 관련 테스트:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-f&lt;/code&gt; : 일반 파일이 존재하는가&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-d&lt;/code&gt; : 디렉터리가 존재하는가&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-e&lt;/code&gt; : 파일 또는 디렉터리가 존재하는가&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;2-문자열-비교&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%B9%84%EA%B5%90&quot; aria-label=&quot;2 문자열 비교 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. 문자열 비교&lt;/h4&gt;
&lt;p&gt;문자열 값이 같은지, 비어 있는지 등을 검사할 때 사용한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$env&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;prod&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;production mode&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-z&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;name is empty&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;자주 쓰는 문자열 테스트:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;=&lt;/code&gt; : 문자열이 같은가&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;!=&lt;/code&gt; : 문자열이 다른가&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-z&lt;/code&gt; : 문자열 길이가 0인가&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-n&lt;/code&gt; : 문자열 길이가 0이 아닌가&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;3-숫자-비교&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-%EC%88%AB%EC%9E%90-%EB%B9%84%EA%B5%90&quot; aria-label=&quot;3 숫자 비교 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3. 숫자 비교&lt;/h4&gt;
&lt;p&gt;숫자는 문자열 비교와 다른 연산자를 사용한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$count&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-gt&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;count is greater than 5&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$port&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-eq&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8080&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;default port&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;자주 쓰는 숫자 비교 연산자:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-eq&lt;/code&gt; : 같다&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-ne&lt;/code&gt; : 다르다&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-gt&lt;/code&gt; : 크다&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-ge&lt;/code&gt; : 크거나 같다&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-lt&lt;/code&gt; : 작다&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;-le&lt;/code&gt; : 작거나 같다&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;반복문&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%98%EB%B3%B5%EB%AC%B8&quot; aria-label=&quot;반복문 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;반복문&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;for&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#for&quot; aria-label=&quot;for permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;for&lt;/code&gt;&lt;/h3&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token for-or-select variable&quot;&gt;item&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; 값1 값2 값3
&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
    실행할 명령
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;예: 파일 목록 순회&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token for-or-select variable&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; app.log db.log auth.log
&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;checking &lt;span class=&quot;token variable&quot;&gt;$file&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;예: 현재 디렉터리의 &lt;code class=&quot;language-text&quot;&gt;.log&lt;/code&gt; 파일 순회&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token for-or-select variable&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; *.log
&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;processing &lt;span class=&quot;token variable&quot;&gt;$file&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;while&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#while&quot; aria-label=&quot;while permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;while&lt;/code&gt;&lt;/h3&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; 조건식 &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
    실행할 명령
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;예시&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$count&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-le&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$count&lt;/span&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;token assign-left variable&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$((&lt;/span&gt;count &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;운영에서-자주-쓰이는-반복문-예시&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%B4%EC%98%81%EC%97%90%EC%84%9C-%EC%9E%90%EC%A3%BC-%EC%93%B0%EC%9D%B4%EB%8A%94-%EB%B0%98%EB%B3%B5%EB%AC%B8-%EC%98%88%EC%8B%9C&quot; aria-label=&quot;운영에서 자주 쓰이는 반복문 예시 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;운영에서 자주 쓰이는 반복문 예시&lt;/h3&gt;
&lt;h4 id=&quot;여러-파일-처리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%97%AC%EB%9F%AC-%ED%8C%8C%EC%9D%BC-%EC%B2%98%EB%A6%AC&quot; aria-label=&quot;여러 파일 처리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;여러 파일 처리&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token for-or-select variable&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; *.log
&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ERROR&quot;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$file&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;각 로그 파일에서 &lt;code class=&quot;language-text&quot;&gt;ERROR&lt;/code&gt;를 검색한다.&lt;/p&gt;
&lt;br&gt;
&lt;h4 id=&quot;여러-프로세스-이름-검사&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%97%AC%EB%9F%AC-%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%EC%9D%B4%EB%A6%84-%EA%B2%80%EC%82%AC&quot; aria-label=&quot;여러 프로세스 이름 검사 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;여러 프로세스 이름 검사&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token for-or-select variable&quot;&gt;proc&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; nginx sshd &lt;span class=&quot;token function&quot;&gt;cron&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ef&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[&lt;span class=&quot;token variable&quot;&gt;${proc&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;0&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;1}&lt;/span&gt;]&lt;span class=&quot;token variable&quot;&gt;${proc&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;1}&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여러 서비스 상태를 한 번에 점검할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;h4 id=&quot;여러-로그에-대한-반복-작업&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%97%AC%EB%9F%AC-%EB%A1%9C%EA%B7%B8%EC%97%90-%EB%8C%80%ED%95%9C-%EB%B0%98%EB%B3%B5-%EC%9E%91%EC%97%85&quot; aria-label=&quot;여러 로그에 대한 반복 작업 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;여러 로그에 대한 반복 작업&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token for-or-select variable&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; /var/log/*.log
&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;===== &lt;span class=&quot;token variable&quot;&gt;$file&lt;/span&gt; =====&quot;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failed&quot;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$file&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;로그 파일이 여러 개일 때 같은 필터를 반복 적용하는 데 유용하다.&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;함수&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%A8%EC%88%98&quot; aria-label=&quot;함수 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;함수&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;기본-구조-1&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B8%B0%EB%B3%B8-%EA%B5%AC%EC%A1%B0-1&quot; aria-label=&quot;기본 구조 1 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;기본 구조&lt;/h3&gt;
&lt;p&gt;함수 정의&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function-name function&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hello&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;호출&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;hello&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;함수 이름만 쓰면 된다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;예시&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%98%88%EC%8B%9C&quot; aria-label=&quot;예시 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;예시&lt;/h3&gt;
&lt;p&gt;정의:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function-name function&quot;&gt;check_file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$1&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
        &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$1&lt;/span&gt; exists&quot;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
        &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$1&lt;/span&gt; missing&quot;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;$1&lt;/code&gt; :  전달한 첫 번째 인자&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;호출:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;check_file &lt;span class=&quot;token string&quot;&gt;&quot;/etc/passwd&quot;&lt;/span&gt;
check_file &lt;span class=&quot;token string&quot;&gt;&quot;nofile.txt&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;반복되는-작업을-함수로-분리하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%98%EB%B3%B5%EB%90%98%EB%8A%94-%EC%9E%91%EC%97%85%EC%9D%84-%ED%95%A8%EC%88%98%EB%A1%9C-%EB%B6%84%EB%A6%AC%ED%95%98%EA%B8%B0&quot; aria-label=&quot;반복되는 작업을 함수로 분리하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;반복되는 작업을 함수로 분리하기&lt;/h3&gt;
&lt;p&gt;같은 로직이 두 번 이상 나오기 시작하면 함수로 분리하는 것이 좋다.&lt;/p&gt;
&lt;p&gt;예를 들어 여러 파일의 존재 여부를 검사한다고 할 때, 아래처럼 함수로 분리하는 것이 좋다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function-name function&quot;&gt;check_file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$1&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
        &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[OK] &lt;span class=&quot;token variable&quot;&gt;$1&lt;/span&gt; exists&quot;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
        &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[FAIL] &lt;span class=&quot;token variable&quot;&gt;$1&lt;/span&gt; missing&quot;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

check_file &lt;span class=&quot;token string&quot;&gt;&quot;/etc/passwd&quot;&lt;/span&gt;
check_file &lt;span class=&quot;token string&quot;&gt;&quot;/etc/hosts&quot;&lt;/span&gt;
check_file &lt;span class=&quot;token string&quot;&gt;&quot;./config.env&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;명령어-치환&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AA%85%EB%A0%B9%EC%96%B4-%EC%B9%98%ED%99%98&quot; aria-label=&quot;명령어 치환 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;명령어 치환&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;Bash Script에서는 명령어 실행 결과를 변수에 넣고,&lt;br&gt;
그 값을 이후 조건문이나 반복문에서 활용하는 경우가 많다.&lt;br&gt;
이때 사용하는 문법이 &lt;strong&gt;명령어 치환(command substitution)&lt;/strong&gt; 이다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;명령어의 실행 결과를 변수에 저장할 때는 &lt;code class=&quot;language-text&quot;&gt;$(...)&lt;/code&gt;를 사용한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;whoami&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;  
&lt;span class=&quot;token assign-left variable&quot;&gt;today&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;  
&lt;span class=&quot;token assign-left variable&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ERROR&quot;&lt;/span&gt; app.log&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;예시&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ERROR&quot;&lt;/span&gt; app.log&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;grep -c &quot;ERROR&quot; app.log&lt;/code&gt;를 실행한 뒤,&lt;/li&gt;
&lt;li&gt;그 출력 결과를 &lt;code class=&quot;language-text&quot;&gt;count&lt;/code&gt; 변수에 저장한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;운영-자동화에서-자주-쓰이는-요소&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%B4%EC%98%81-%EC%9E%90%EB%8F%99%ED%99%94%EC%97%90%EC%84%9C-%EC%9E%90%EC%A3%BC-%EC%93%B0%EC%9D%B4%EB%8A%94-%EC%9A%94%EC%86%8C&quot; aria-label=&quot;운영 자동화에서 자주 쓰이는 요소 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;운영 자동화에서 자주 쓰이는 요소&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;변수화&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B3%80%EC%88%98%ED%99%94&quot; aria-label=&quot;변수화 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;변수화&lt;/h3&gt;
&lt;p&gt;고정값을 직접 코드에 반복해서 쓰기보다 변수로 분리하는 것이 좋다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;LOG_DIR&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/var/log&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;KEYWORD&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ERROR&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이렇게 하면 나중에 경로나 검색어를 바꾸기 쉽다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$KEYWORD&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$LOG_DIR&lt;/span&gt;/app.log&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;특히 다음은 변수화하는 경우가 많다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;경로&lt;/li&gt;
&lt;li&gt;파일명&lt;/li&gt;
&lt;li&gt;포트 번호&lt;/li&gt;
&lt;li&gt;환경 이름&lt;/li&gt;
&lt;li&gt;반복 대상 목록&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;조건-검사-후-실행&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A1%B0%EA%B1%B4-%EA%B2%80%EC%82%AC-%ED%9B%84-%EC%8B%A4%ED%96%89&quot; aria-label=&quot;조건 검사 후 실행 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;조건 검사 후 실행&lt;/h3&gt;
&lt;p&gt;무조건 실행하기보다, 조건을 확인하고 실행해야 예상치 못한 실패를 줄일 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$LOG_DIR&lt;/span&gt;/app.log&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$KEYWORD&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$LOG_DIR&lt;/span&gt;/app.log&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;log file not found&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;파일이 있을 때만 읽기&lt;/li&gt;
&lt;li&gt;디렉터리가 있을 때만 이동&lt;/li&gt;
&lt;li&gt;인자가 주어졌을 때만 특정 작업 수행&lt;/li&gt;
&lt;li&gt;이전 명령이 성공했을 때만 다음 단계 진행&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;실패-시-종료&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%A4%ED%8C%A8-%EC%8B%9C-%EC%A2%85%EB%A3%8C&quot; aria-label=&quot;실패 시 종료 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;실패 시 종료&lt;/h3&gt;
&lt;p&gt;가장 단순한 방식은 &lt;code class=&quot;language-text&quot;&gt;exit 1&lt;/code&gt;이다. 아래처럼 필수 파일이 없을 때 바로 종료시킬 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; config.env &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;config.env not found&quot;&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;exit&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;명령 직후 종료 코드를 검사할 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;cp&lt;/span&gt; source.txt backup.txt

&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$?&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ne&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;copy failed&quot;&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;exit&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;로그-남기기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A1%9C%EA%B7%B8-%EB%82%A8%EA%B8%B0%EA%B8%B0&quot; aria-label=&quot;로그 남기기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;로그 남기기&lt;/h3&gt;
&lt;p&gt;자동화 스크립트는 나중에 무엇이 실행됐는지 추적할 수 있어야 한다.&lt;br&gt;
그래서 중요한 단계마다 메시지를 남기는 경우가 많다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[INFO] backup started&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[INFO] checking log files&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[ERROR] config file missing&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;파일에 저장할 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[INFO] backup started&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; backup.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;실행-결과-확인&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%A4%ED%96%89-%EA%B2%B0%EA%B3%BC-%ED%99%95%EC%9D%B8&quot; aria-label=&quot;실행 결과 확인 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;실행 결과 확인&lt;/h3&gt;
&lt;p&gt;스크립트는 실행만 하는 것이 아니라, 실행 결과를 확인하고 필요하면 다음 동작을 정해야 한다.&lt;/p&gt;
&lt;p&gt;예를 들어 로그 검색 결과 개수를 세고 판단할 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ERROR&quot;&lt;/span&gt; app.log&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$count&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-gt&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;errors found: &lt;span class=&quot;token variable&quot;&gt;$count&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;no errors&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;서비스가 실행 중인지 검사할 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ef&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;[n]ginx&apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; /dev/null

&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$?&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-eq&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;nginx is running&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;nginx is not running&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content:encoded></item><item><title><![CDATA[Bash Script: 표준입출력과 리다이렉션, 파이프]]></title><description><![CDATA[Bash Script에는 하나의 명령만 쓰는 것이 아니라 한 명령의 출력을 파일로 보내거나, 다른 명령의 입력으로 넘기거나, 에러만 따로 저장하는 식으로 입력과 출력의 흐름을 조합하며 사용한다. 이 글에서는 Bash…]]></description><link>https://jiu-jung.github.io/rhel-bash-io-pipes/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-bash-io-pipes/</guid><pubDate>Wed, 15 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Bash Script에는 하나의 명령만 쓰는 것이 아니라&lt;br&gt;
한 명령의 출력을 파일로 보내거나, 다른 명령의 입력으로 넘기거나, 에러만 따로 저장하는 식으로&lt;br&gt;
&lt;strong&gt;입력과 출력의 흐름을 조합&lt;/strong&gt;하며 사용한다.&lt;/p&gt;
&lt;p&gt;이 글에서는 Bash의 표준 입출력과 명령어 연결에 대해 정리한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;&quot;&gt;표준 입출력&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;&quot;&gt;리다이렉션&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;&quot;&gt;파이프&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;&quot;&gt;자주 사용하는 연결 패턴&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;&quot;&gt;표준 에러 분리&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;표준-입출력&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%91%9C%EC%A4%80-%EC%9E%85%EC%B6%9C%EB%A0%A5&quot; aria-label=&quot;표준 입출력 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;표준 입출력&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;p&gt;명령어는 실행될 때 입력을 받고, 결과를 출력한다.&lt;br&gt;
리눅스는 이 입출력 경로를 기본적으로 세 가지로 나눠 관리한다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;표준-입력stdin&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%91%9C%EC%A4%80-%EC%9E%85%EB%A0%A5stdin&quot; aria-label=&quot;표준 입력stdin permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;표준 입력(stdin)&lt;/h3&gt;
&lt;p&gt;표준 입력은 &lt;strong&gt;명령어가 입력을 받는 기본 통로&lt;/strong&gt;다.&lt;br&gt;
보통은 키보드 입력이 표준 입력으로 연결된다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;표준-출력stdout&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%91%9C%EC%A4%80-%EC%B6%9C%EB%A0%A5stdout&quot; aria-label=&quot;표준 출력stdout permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;표준 출력(stdout)&lt;/h3&gt;
&lt;p&gt;표준 출력은 &lt;strong&gt;명령어가 정상적인 실행 결과를 내보내는 기본 통로&lt;/strong&gt;다.&lt;/p&gt;
&lt;p&gt;대부분의 명령어 결과는 기본적으로 터미널 화면에 출력되는데,&lt;br&gt;
이때 화면에 보이는 일반 결과가 바로 표준 출력이다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;표준-에러stderr&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%91%9C%EC%A4%80-%EC%97%90%EB%9F%ACstderr&quot; aria-label=&quot;표준 에러stderr permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;표준 에러(stderr)&lt;/h3&gt;
&lt;p&gt;표준 에러는 &lt;strong&gt;오류 메시지를 출력하는 별도의 통로&lt;/strong&gt;다.&lt;br&gt;
에러 메시지도 화면에 보이기 때문에 stdout과 같아 보일 수 있지만, 내부적으로는 &lt;strong&gt;다른 경로&lt;/strong&gt;이다.&lt;/p&gt;
&lt;p&gt;예를 들어 존재하지 않는 파일을 읽으려고 하면:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt; notexist.txt
cat: notexist.txt: No such &lt;span class=&quot;token function&quot;&gt;file&lt;/span&gt; or directory&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 에러 메시지는 일반 출력이 아니라 &lt;strong&gt;stderr&lt;/strong&gt;로 전달된다.&lt;/p&gt;
&lt;p&gt;이렇게 stdout과 stderr가 분리되어 있기 때문에,&lt;br&gt;
정상 결과는 파일로 저장하고 에러는 따로 남기는 식의 처리가 가능하다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;파일-디스크립터&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%8C%8C%EC%9D%BC-%EB%94%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%84%B0&quot; aria-label=&quot;파일 디스크립터 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;파일 디스크립터&lt;/h3&gt;
&lt;p&gt;리눅스는 표준 입출력을 숫자로도 구분한다.&lt;br&gt;
이 숫자를 &lt;strong&gt;파일 디스크립터(file descriptor)&lt;/strong&gt; 라고 한다.&lt;/p&gt;
&lt;p&gt;기본 표준 입출력은 다음과 같이 정해져 있다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;0&lt;/code&gt;: 표준 입력 (&lt;code class=&quot;language-text&quot;&gt;stdin&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;1&lt;/code&gt;: 표준 출력 (&lt;code class=&quot;language-text&quot;&gt;stdout&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;2&lt;/code&gt;: 표준 에러 (&lt;code class=&quot;language-text&quot;&gt;stderr&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;아래 두 표현은 같은 의미다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; out.txt
&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;1&lt;/span&gt;&gt;&lt;/span&gt; out.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;에러만 따로 저장하려면 &lt;code class=&quot;language-text&quot;&gt;2&gt;&lt;/code&gt;를 사용할 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt; error.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;리다이렉션&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A6%AC%EB%8B%A4%EC%9D%B4%EB%A0%89%EC%85%98&quot; aria-label=&quot;리다이렉션 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;리다이렉션&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;p&gt;리다이렉션은 &lt;strong&gt;명령어의 입력 또는 출력을 기본 경로가 아닌 다른 곳으로 보내는 것&lt;/strong&gt;이다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;화면으로 나가던 출력을 파일로 보내거나&lt;/li&gt;
&lt;li&gt;키보드로 받던 입력을 파일에서 받도록 바꾸는 방식이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;출력-리다이렉션&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B6%9C%EB%A0%A5-%EB%A6%AC%EB%8B%A4%EC%9D%B4%EB%A0%89%EC%85%98&quot; aria-label=&quot;출력 리다이렉션 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;출력 리다이렉션&lt;/h3&gt;
&lt;p&gt;출력 리다이렉션은 주로 표준 출력(stdout)이나 표준 에러(stderr)를 파일로 보내기 위해 사용한다.&lt;/p&gt;
&lt;br&gt;
&lt;h4 id=&quot;&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#&quot; aria-label=&quot; permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;&gt;&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&gt;&lt;/code&gt;는 &lt;strong&gt;출력을 파일로 덮어써서 저장&lt;/strong&gt;한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hello&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; output.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 명령은 &lt;code class=&quot;language-text&quot;&gt;hello&lt;/code&gt;를 &lt;code class=&quot;language-text&quot;&gt;output.txt&lt;/code&gt;에 저장한다.&lt;br&gt;
이미 파일이 있다면 기존 내용은 사라지고 새로 덮어써진다.&lt;/p&gt;
&lt;br&gt;
&lt;h4 id=&quot;-1&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#-1&quot; aria-label=&quot; 1 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;&gt;&gt;&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&gt;&gt;&lt;/code&gt;는 &lt;strong&gt;출력을 파일 끝에 이어서 추가&lt;/strong&gt;한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hello&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; output.txt  
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;world&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; output.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;결과:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;hello  
world&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;로그를 계속 누적해서 저장&lt;/strong&gt;할 때 자주 사용한다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;입력-리다이렉션&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9E%85%EB%A0%A5-%EB%A6%AC%EB%8B%A4%EC%9D%B4%EB%A0%89%EC%85%98&quot; aria-label=&quot;입력 리다이렉션 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;입력 리다이렉션&lt;/h3&gt;
&lt;p&gt;입력 리다이렉션은 &lt;strong&gt;표준 입력(stdin)을 파일이나 다른 입력원으로 바꾸는 것&lt;/strong&gt;이다.&lt;/p&gt;
&lt;br&gt;
&lt;h4 id=&quot;-2&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#-2&quot; aria-label=&quot; 2 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;&lt;/code&gt;는 파일 내용을 명령어의 입력으로 전달한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; input.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 명령은 &lt;code class=&quot;language-text&quot;&gt;input.txt&lt;/code&gt;의 내용을 표준 입력으로 받아 줄 수를 센다.&lt;/p&gt;
&lt;br&gt;
&lt;h4 id=&quot;here-document&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#here-document&quot; aria-label=&quot;here document permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;here document&lt;/h4&gt;
&lt;p&gt;here document는 여러 줄 입력을 &lt;strong&gt;직접 스크립트 안에서 표준 입력으로 전달&lt;/strong&gt;하는 방식이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;EOF  
hello  
world  
EOF&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;출력:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;hello  
world&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 방식으로 임시로 Script를 만들어서 실행할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;화면에 출력을 표시하는 대신 &lt;code class=&quot;language-text&quot;&gt;&gt;&lt;/code&gt; 연산자를 사용하여 파일로 리디렉션할 수 도 있다.&lt;br&gt;
아래처럼 하면 여러 줄 내용을 파일로 한 번에 저장할 수 있다.&lt;br&gt;
환경변수, 변수 참조도 가능하다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;EOF&lt;span class=&quot;token bash punctuation&quot;&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; file.txt&lt;/span&gt;
The current working directory is: &lt;span class=&quot;token environment constant&quot;&gt;$PWD&lt;/span&gt;
You are logged in as: &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;whoami&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
EOF&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;파이프&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%8C%8C%EC%9D%B4%ED%94%84&quot; aria-label=&quot;파이프 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;파이프&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;파이프(&lt;code class=&quot;language-text&quot;&gt;|&lt;/code&gt;)는 &lt;strong&gt;한 명령의 표준 출력을 다음 명령의 표준 입력으로 넘기는 연산자&lt;/strong&gt;다.&lt;br&gt;
파일을 중간에 만들지 않고도  명령어 결과를 바로 다음 명령어가 받아 처리할 수 있게 해준다.&lt;/p&gt;
&lt;p&gt;리눅스 명령어는 대부분 텍스트를 입력받고 텍스트를 출력하기 때문에,&lt;br&gt;
파이프를 이용하여 서로 다른 명령어들을 쉽게 연결할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 명령은 다음 흐름으로 동작한다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;ls&lt;/code&gt;가 현재 디렉터리 목록을 출력한다.&lt;/li&gt;
&lt;li&gt;그 출력이 화면으로 가지 않고&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;wc -l&lt;/code&gt;의 표준 입력으로 전달된다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;wc -l&lt;/code&gt;은 줄 수를 세어 결과를 출력한다.&lt;/li&gt;
&lt;/ol&gt;
&lt;br&gt;
&lt;p&gt;파이프는 여러 개를 이어서 쓸 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ef&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; nginx &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;ps -ef&lt;/code&gt; : 전체 프로세스 목록 출력&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;grep nginx&lt;/code&gt; : 그중 nginx가 포함된 줄만 추림&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;wc -l&lt;/code&gt; : 최종 개수 계산&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;자주-사용하는-명령-연결-패턴&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9E%90%EC%A3%BC-%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94-%EB%AA%85%EB%A0%B9-%EC%97%B0%EA%B2%B0-%ED%8C%A8%ED%84%B4&quot; aria-label=&quot;자주 사용하는 명령 연결 패턴 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;자주 사용하는 명령 연결 패턴&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;연결에-자주-쓰이는-명령어&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%97%B0%EA%B2%B0%EC%97%90-%EC%9E%90%EC%A3%BC-%EC%93%B0%EC%9D%B4%EB%8A%94-%EB%AA%85%EB%A0%B9%EC%96%B4&quot; aria-label=&quot;연결에 자주 쓰이는 명령어 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;연결에 자주 쓰이는 명령어&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;ps&lt;/code&gt; : 프로세스 목록 확인&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;grep&lt;/code&gt; : 특정 문자열 검색&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;awk&lt;/code&gt; : 열 단위 추출, 간단한 가공&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;sort&lt;/code&gt; : 정렬&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;uniq&lt;/code&gt; : 중복 제거 또는 중복 개수 확인&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;wc&lt;/code&gt; : 줄 수, 단어 수, 문자 수 계산&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;로그-검색&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A1%9C%EA%B7%B8-%EA%B2%80%EC%83%89&quot; aria-label=&quot;로그 검색 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;로그 검색&lt;/h3&gt;
&lt;p&gt;로그에서 특정 에러만 찾고 싶다면 다음처럼 쓸 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ERROR&quot;&lt;/span&gt; app.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;빈도도 셀 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ERROR&quot;&lt;/span&gt; app.log &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;자주 등장한 메시지를 보고 싶다면:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ERROR&quot;&lt;/span&gt; app.log &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;uniq&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-nr&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;grep&lt;/code&gt; : ERROR 포함 줄 추출&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;sort&lt;/code&gt; : 같은 줄끼리 모이도록 정렬&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;uniq -c&lt;/code&gt; : 중복 횟수 집계&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;sort -nr&lt;/code&gt; : 많은 순서대로 정렬&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;![[Pasted image 20260416171718.png]]&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;프로세스-필터링&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%ED%95%84%ED%84%B0%EB%A7%81&quot; aria-label=&quot;프로세스 필터링 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;프로세스 필터링&lt;/h3&gt;
&lt;p&gt;특정 프로세스가 실행 중인지 확인할 때 자주 쓴다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ef&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; nginx&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;다만 이 방식은 &lt;code class=&quot;language-text&quot;&gt;grep nginx&lt;/code&gt; 자체도 결과에 포함되기 때문에, 아래 방식을 사용한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ef&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;[n]ginx&apos;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ef&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; nginx &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;프로세스 개수만 확인하려면:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ef&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;[n]ginx&apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;파일-내용-가공&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%8C%8C%EC%9D%BC-%EB%82%B4%EC%9A%A9-%EA%B0%80%EA%B3%B5&quot; aria-label=&quot;파일 내용 가공 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;파일 내용 가공&lt;/h3&gt;
&lt;p&gt;파일에서 특정 열만 뽑거나 정리할 수 있다.&lt;/p&gt;
&lt;p&gt;예를 들어 &lt;code class=&quot;language-text&quot;&gt;/etc/passwd&lt;/code&gt;에서 사용자 이름만 보고 싶다면:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;awk&lt;/span&gt; -F: &lt;span class=&quot;token string&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt; /etc/passwd&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;중복 없이 정렬된 목록:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;awk&lt;/span&gt; -F: &lt;span class=&quot;token string&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt; /etc/passwd &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;uniq&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;로그에서 특정 필드만 뽑아 개수를 세는 식의 패턴도 자주 나온다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt; access.log &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;uniq&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-nr&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;표준-에러-분리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%91%9C%EC%A4%80-%EC%97%90%EB%9F%AC-%EB%B6%84%EB%A6%AC&quot; aria-label=&quot;표준 에러 분리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;표준 에러 분리&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;stderr와-stdout-분리가-필요한-이유&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#stderr%EC%99%80-stdout-%EB%B6%84%EB%A6%AC%EA%B0%80-%ED%95%84%EC%9A%94%ED%95%9C-%EC%9D%B4%EC%9C%A0&quot; aria-label=&quot;stderr와 stdout 분리가 필요한 이유 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;stderr와 stdout 분리가 필요한 이유&lt;/h3&gt;
&lt;p&gt;명령 실행 결과와 에러 메시지가 한 파일에 섞이면 실패 원인을 정확히 추적하기 어려워진다.&lt;/p&gt;
&lt;p&gt;예를 들어 배치 작업이 실패했을 때, 정상 처리 로그와 에러 메시지가 뒤섞여 있으면&lt;br&gt;
어디서 문제가 발생했는지 찾는 데 시간이 더 걸린다.&lt;/p&gt;
&lt;p&gt;그래서 stdout과 stderr를 분리하면 다음이 쉬워진다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;정상 처리 결과 확인&lt;/li&gt;
&lt;li&gt;에러 원인 추적&lt;/li&gt;
&lt;li&gt;실패 시점 파악&lt;/li&gt;
&lt;li&gt;자동화 스크립트에서 후속 처리 분기&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;에러-출력-분리하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%97%90%EB%9F%AC-%EC%B6%9C%EB%A0%A5-%EB%B6%84%EB%A6%AC%ED%95%98%EA%B8%B0&quot; aria-label=&quot;에러 출력 분리하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;에러 출력 분리하기&lt;/h3&gt;
&lt;p&gt;에러 메시지만 따로 파일로 저장하려면 &lt;code class=&quot;language-text&quot;&gt;2&gt;&lt;/code&gt;를 사용한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; existing.txt nofile.txt &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt; error.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 경우 존재하지 않는 파일에 대한 에러 메시지는 &lt;code class=&quot;language-text&quot;&gt;error.txt&lt;/code&gt;에 저장된다.&lt;/p&gt;
&lt;p&gt;정상 출력은 별도로 처리하지 않았기 때문에 화면으로 나간다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;표준-출력과-표준-에러를-각각-분리하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%91%9C%EC%A4%80-%EC%B6%9C%EB%A0%A5%EA%B3%BC-%ED%91%9C%EC%A4%80-%EC%97%90%EB%9F%AC%EB%A5%BC-%EA%B0%81%EA%B0%81-%EB%B6%84%EB%A6%AC%ED%95%98%EA%B8%B0&quot; aria-label=&quot;표준 출력과 표준 에러를 각각 분리하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;표준 출력과 표준 에러를 각각 분리하기&lt;/h3&gt;
&lt;p&gt;stdout과 stderr를 각각 다른 파일로 보낼 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; output.txt &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt; error.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;output.txt : 정상 출력 저장&lt;/li&gt;
&lt;li&gt;error.txt : 에러 메시지 저장&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 방식은 정상 결과와 오류 메시지를 완전히 분리해서 보고 싶을 때 유용하다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;표준-출력과-표준-에러를-같은-파일에-저장하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%91%9C%EC%A4%80-%EC%B6%9C%EB%A0%A5%EA%B3%BC-%ED%91%9C%EC%A4%80-%EC%97%90%EB%9F%AC%EB%A5%BC-%EA%B0%99%EC%9D%80-%ED%8C%8C%EC%9D%BC%EC%97%90-%EC%A0%80%EC%9E%A5%ED%95%98%EA%B8%B0&quot; aria-label=&quot;표준 출력과 표준 에러를 같은 파일에 저장하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;표준 출력과 표준 에러를 같은 파일에 저장하기&lt;/h3&gt;
&lt;p&gt;stdout과 stderr를 같은 파일에 함께 저장할 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; all.log &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&gt; all.log&lt;/code&gt; : stdout을 &lt;code class=&quot;language-text&quot;&gt;all.log&lt;/code&gt;로 보냄&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;2&gt;&amp;amp;1&lt;/code&gt; : stderr도 stdout이 향하는 곳과 동일하게 보냄&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;정상 출력과 에러 메시지를 모두 all.log 하나에 저장한다.&lt;/p&gt;
&lt;p&gt;Bash에서는 아래처럼 더 짧게 쓸 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&gt;&lt;/span&gt; all.log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;출력-없이-실행만-하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B6%9C%EB%A0%A5-%EC%97%86%EC%9D%B4-%EC%8B%A4%ED%96%89%EB%A7%8C-%ED%95%98%EA%B8%B0&quot; aria-label=&quot;출력 없이 실행만 하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;출력 없이 실행만 하기&lt;/h3&gt;
&lt;p&gt;스크립트나 명령을 실행하되 출력은 모두 버리고 싶을 때는 &lt;code class=&quot;language-text&quot;&gt;/dev/null&lt;/code&gt;을 사용한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;./script.sh &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; /dev/null &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;/dev/null&lt;/code&gt; : 필요 없는 출력을 버리는 특수 파일&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&gt; /dev/null&lt;/code&gt; : 표준 출력을 버림&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;2&gt;&amp;amp;1&lt;/code&gt; : 표준 에러도 같은 곳으로 보냄&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;주로 다음 상황에서 사용한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;출력이 너무 많지만 성공/실패만 확인하면 될 때&lt;/li&gt;
&lt;li&gt;cron 같은 비대화형 실행에서 불필요한 출력을 줄이고 싶을 때&lt;/li&gt;
&lt;li&gt;조용히 실행하고 종료 코드만 확인하고 싶을 때&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;stderr만-따로-남기기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#stderr%EB%A7%8C-%EB%94%B0%EB%A1%9C-%EB%82%A8%EA%B8%B0%EA%B8%B0&quot; aria-label=&quot;stderr만 따로 남기기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;stderr만 따로 남기기&lt;/h3&gt;
&lt;p&gt;정상 출력은 버리고, 에러만 보고 싶을 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; /dev/null &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt; error.txt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;표준 출력은 버림&lt;/li&gt;
&lt;li&gt;표준 에러만 error.txt에 저장&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;정상 결과는 필요 없고 실패한 이유만 확인하고 싶을 때 유용하다.&lt;/p&gt;
&lt;p&gt;예를 들어 배치 작업, 점검 스크립트, 파일 검사 스크립트에서는&lt;br&gt;
정상 출력은 무시하고 에러만 따로 수집하는 식으로 활용할 수 있다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Bash Script: 기본 문법과 실행 구조]]></title><description><![CDATA[리눅스에서 반복 작업을 자동화하거나 여러 명령을 순서대로 실행하려면 쉘 스크립트를 작성하게 된다. 특히 운영 환경에서는 명령을 한 번 실행하는 것을 넘어, 일관된 절차를 코드로 남기고 재사용 가능한 형태로 만드는 것이 중요하다. 이 글에서는 Bash…]]></description><link>https://jiu-jung.github.io/rhel-bash-basics/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-bash-basics/</guid><pubDate>Tue, 14 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;리눅스에서 반복 작업을 자동화하거나 여러 명령을 순서대로 실행하려면 쉘 스크립트를 작성하게 된다.&lt;/p&gt;
&lt;p&gt;특히 운영 환경에서는 명령을 한 번 실행하는 것을 넘어,&lt;br&gt;
일관된 절차를 코드로 남기고 재사용 가능한 형태로 만드는 것이 중요하다.&lt;/p&gt;
&lt;p&gt;이 글에서는 Bash 스크립트를 처음 다룰 때 필요한 기본 개념을 다음 흐름으로 정리한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-basics/#Shell%EA%B3%BC-Bash&quot;&gt;Shell과 Bash&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-basics/#Bash-Script%EC%9D%98-%EA%B8%B0%EB%B3%B8-%EA%B5%AC%EC%A1%B0%EC%99%80-%EC%8B%A4%ED%96%89&quot;&gt;Bash Script의 기본 구조와 실행&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-basics/#Bash-Script%EC%9D%98-%EC%8B%A4%ED%96%89-%ED%9D%90%EB%A6%84&quot;&gt;Bash Script의 실행 흐름&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-basics/#%EB%B3%80%EC%88%98%EC%99%80-%EB%AC%B8%EC%9E%90%EC%97%B4&quot;&gt;변수와 문자열&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-basics/#%ED%99%98%EA%B2%BD%EB%B3%80%EC%88%98%EC%99%80-export&quot;&gt;환경 변수와 export&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-bash-basics/#%EB%AA%85%EB%A0%B9%ED%96%89-%EC%9D%B8%EC%9E%90&quot;&gt;명령행 인자&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h2 id=&quot;Shell과-Bash&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Shell%EA%B3%BC-Bash&quot; aria-label=&quot;Shell과 Bash permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Shell과 Bash&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;Shell&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Shell&quot; aria-label=&quot;Shell permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Shell&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/aae7df91f12586bb8c261e9607ac897b/fb3ea/shell.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 97.05882352941177%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAYAAACQjC21AAAACXBIWXMAAAsTAAALEwEAmpwYAAAE5klEQVR42nWUC0yTVxTHO8wyde6B7dfva2lplcdQYQ51ypT5wMw4FTYdOF1CnIp10YG8xWWuGsUxA0ppaYGWQrEwRBRUUHEo2ZwPFoeAioyBOByCslaB8ihf+/33tTonUU9ykptz7vndc+8553I4zwrwCqcEY5zrmLRxAtXlQErXGCs0NKWL824qBTkN31Bpvyx9a1ve20/2u3DkchfOC8UBc2zgyF1IXf0agbG1lii7R3NPPcTksw/hXf0I3FNm8Mu7GcrY0sxXX4nmyOTjnbFyuDwPY0UgPzFeYGg28CvN4J02Mz6qentQbBW9ckM5verLMvqjqFO0X9pvNuJEN0Oc7Qdff6NmbKxe/Bj6NNPHMM5M2atUYVs5/9wwJPktI6vXHqZjfNWIlaqwZ24u9gbqETdJhRgfNcKD822eyjoreW4Q4sKW+nGb09z+TwyP02Ude9zODcEzu8m6ZUEOkzBJie8D5ajYGIq6xA9xLWkeqjZ/gtRF2xHvoUT0LCX8f/h1RFwzBEJ3/dioG5Oq2mkzqv7pn3X8LtYHaZnEyRko+HwT+hQSQEeAySGdCi2BoUwhjq0LRZy3ApFzVJBkNdjIChOIlKrQp0BhUXvKxOoBLEmqpnf5a5EVEgVbFgWrWgTLQSksaRL0szpwUILhTHcWzINxzVrESTIQ/EWhjXfmIci8G5X/8cZQRzouCcq7ERFstO+eo8Sfu2aC1ghZmASWXBH6LwjRe0kAs96NtbnDqhGjK8UT8oB92LZAx4j1TeCXtPe4rpC5c6gdJQRx9G+zR/4fiPTTMKnzt2NY7YYhpRiWTDEGWgUYsVKwDVPo76TwwOHLkGBEQyIv7Csk+ucwvsk/w7W0g+Em5C12tIo7r6xr2Cer0VFBJnt5JOhsCoNsJgNFIty9zUfDFQL1l3n4q51A9xEBLKkSMFo+jGGh2CpVMkG7qxnvqgdw31n8GYeIz6OIo519nrm3sM1Xw6QvTmBPF7JZuKNXI8KjdgqWXlbNJMxdJDrUAgyxxbJlk9CFhCPKS8UEJNdAerITbkn6ZRzJgnVjycN3GkSlndi4SG//9t0UdCRPY6FuzjfsMQhgusaF6ToXdwr4MKeKYc2UwMQWaeesJGydkclINHWYWNzeNyFk81RnVQSFrdncaguWbSqjHf1nXBPurKTzHRVeMKnfx33ldPQqpmKQzRx6AuXrlyBmUjpWh+jsxIkudmoaa1nUa04g9+CFhaLj3YxPfpN9a0Am4t9R4GRECOxZBBvMAooDgJJAoMALyOGi5ut5iJ6Sgni/dHjvq7Hxq/rA210eO2qOxYYmo4jtet+9F0bi3stAnKcCGR9vQW3sXLR958GqFFcTZkATHI5or1Rsn5qO2ZGltLMHcxvrWITrKOB42QEBdajlBo+9+pT9l6wRi7LtcR4qREvTkbYsC6pQLeJ9FIiRKrHlAxXjn3hyhFvRA6qo1Txhw575o3+dJ4s3EvRepOHm7wQ7NdSPbfbZO87Qq8IO0RuWG2wRKwpsYZ/m2+ZFldFCbYON91M/yPxb996U7V/6si/MaZggk/NI5cUDVFGbiVtpgvR0DxN0/j4WVnfD+/R9OGxk8e1B/oHzJa+vjPJ9NvZ5cZzyxMmVpfoQKWfiJdqrpX7FzRenH26+7J1bV8FNrtzrGi4PdIzsi2D/AhXf8E8hLtvxAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;shell&apos; title=&apos;&apos; src=&apos;/static/aae7df91f12586bb8c261e9607ac897b/ca1dc/shell.png&apos; srcset=&apos;/static/aae7df91f12586bb8c261e9607ac897b/e7570/shell.png 170w,
/static/aae7df91f12586bb8c261e9607ac897b/f46e7/shell.png 340w,
/static/aae7df91f12586bb8c261e9607ac897b/ca1dc/shell.png 680w,
/static/aae7df91f12586bb8c261e9607ac897b/fb3ea/shell.png 742w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c351f12cf9883291f4737c7a206a0fe5/a27c6/shell_2.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 70%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsTAAALEwEAmpwYAAACa0lEQVR42m1TXUhTYRjecGA3uYuu0tXNwKirsBgVQUWwywjEm24jYoYSQ6cTW2A/Vmyci9yZtcSx6eYiqGYet6aMCiYb04iYuBiFOvfXjt/ZOftx5+/rc1s3eh6+7+F5Pt7nnJfvvEcGIWRZNhQKBQKBz3Ug4Uc6uK+DwSBBELFYDEpBhnYqlVIoFDKZTC6XI1Yq206f6jzS2op0S0sLYo1Gw/M8qhRF8WCYYZhRk0k/aBgcNg4YDDrj2F0Tph8a0g8NG4zGvvt6q83WqJYIl1muO1I6H+YuhNnrUbZntXYjUr31g7saYS+usOi8O1oq1bh6+FDb9B57lsi2+ahj8+D4AjjjB50EOLdUbF8A6OSoj+ry51GNdHivxtEgD8gMILMlKvc7nVlLpiiQJwtZisyCQoahAC9AXhB5XkCLq/N+mBdhmUyK68+FuBluWMrfn4W9/V9m79Gxp8gK6xbx52N+21eud33wttEjqkwa5jxiZg7mvPz27M6qbStqrf5xIguzXph2Qmolz0C7Z9k47h7D3g08mpnyLDfbjiV2R95smKYTo1OJJzNJ/MPmxPvNcXdydGrj4fSvwcl1fyRXrPJuXxh7/Ql3+F/gH9/Oh5thYmXnki54pW/pcm/wpvGrzhztNUd6HnxD9lr/ctdtPzYXR2WCIEoMCVmsZYvcbhWSFfi3BNMUXNtic/S+RatQgRUOspwgcWGN7764SGAYhuP4q0mbFbfdGbEgnkS6jpcTVgAoiSFpeK1W2xhPpVKpVqtPnuho7+hQqVSy/4jHG50LEmH0Y9jtdmcdLpcL7aZwOh0OB2Kapg+/+R+VCIDMEdg+YgAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;shell 2&apos; title=&apos;&apos; src=&apos;/static/c351f12cf9883291f4737c7a206a0fe5/ca1dc/shell_2.png&apos; srcset=&apos;/static/c351f12cf9883291f4737c7a206a0fe5/e7570/shell_2.png 170w,
/static/c351f12cf9883291f4737c7a206a0fe5/f46e7/shell_2.png 340w,
/static/c351f12cf9883291f4737c7a206a0fe5/ca1dc/shell_2.png 680w,
/static/c351f12cf9883291f4737c7a206a0fe5/a27c6/shell_2.png 700w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Shell은 사용자가 입력한 명령을 해석해 운영체제에 전달하는 &lt;strong&gt;명령어 인터페이스&lt;/strong&gt;다.&lt;/p&gt;
&lt;p&gt;사용자는 터미널에서 명령을 입력하고,&lt;br&gt;
Shell은 그 명령을 해석한 뒤 적절한 프로그램을 실행한다.&lt;/p&gt;
&lt;p&gt;이름 그대로 커널을 감싸는 껍데기 역할을 한다고 해서 &lt;strong&gt;Shell&lt;/strong&gt;이라고 부른다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;Shell의 종류&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bourne Shell (&lt;code class=&quot;language-text&quot;&gt;sh&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;C Shell (&lt;code class=&quot;language-text&quot;&gt;csh&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Z Shell (&lt;code class=&quot;language-text&quot;&gt;zsh&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Bourne Again Shell (&lt;code class=&quot;language-text&quot;&gt;bash&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;h4 id=&quot;헷갈리기-쉬운-용어&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%97%B7%EA%B0%88%EB%A6%AC%EA%B8%B0-%EC%89%AC%EC%9A%B4-%EC%9A%A9%EC%96%B4&quot; aria-label=&quot;헷갈리기 쉬운 용어 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;헷갈리기 쉬운 용어&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Shell&lt;/strong&gt;: 명령을 해석하고 실행하는 프로그램&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Terminal&lt;/strong&gt;: Shell을 사용할 수 있게 해주는 화면 환경&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Console&lt;/strong&gt;: 시스템과 직접 연결된 입력/출력 환경을 가리키는 전통적 표현&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prompt&lt;/strong&gt;: 명령 입력을 기다리는 표시 (&lt;code class=&quot;language-text&quot;&gt;$&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;#&lt;/code&gt; 등)&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;Bash&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Bash&quot; aria-label=&quot;Bash permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Bash&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;Bash는 여러 Shell 중 하나이며, 정식 이름은 Bourne Again Shell이다.&lt;/p&gt;
&lt;p&gt;리눅스 환경에서 가장 널리 사용되는 Shell 중 하나이며,&lt;br&gt;
Bourne Shell(&lt;code class=&quot;language-text&quot;&gt;sh&lt;/code&gt;)을 계승하면서 스크립트 작성과 사용자 편의 기능을 강화한 Shell이라고 볼 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;Bash는 단순히 명령을 실행하는 것뿐 아니라 다음 기능도 제공한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;변수 사용&lt;/li&gt;
&lt;li&gt;조건문, 반복문&lt;/li&gt;
&lt;li&gt;명령 치환&lt;/li&gt;
&lt;li&gt;스크립트 파일 실행&lt;/li&gt;
&lt;li&gt;환경 변수 관리&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;이러한 기능 덕분에 Bash는&lt;br&gt;
단순 명령 입력 도구를 넘어 &lt;strong&gt;자동화와 운영 작업을 작성하는 실행 환경&lt;/strong&gt;으로도 사용된다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;Bash-Script&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Bash-Script&quot; aria-label=&quot;Bash Script permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Bash Script&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;Bash Script는 &lt;strong&gt;Bash가 읽고 실행할 명령들을 모아 둔 텍스트 파일&lt;/strong&gt;이다.&lt;/p&gt;
&lt;p&gt;즉, 사용자가 터미널에 직접 입력할 명령들을 파일로 저장해 반복 실행할 수 있게 만든 형태라고 볼 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;주로 다음과 같은 목적에 사용한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;반복 작업 자동화&lt;/li&gt;
&lt;li&gt;운영 절차 표준화&lt;/li&gt;
&lt;li&gt;여러 명령의 순차 실행&lt;/li&gt;
&lt;li&gt;환경 설정 및 배포 보조 작업&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;주요 특징은 다음과 같다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;텍스트 파일 형태로 작성한다&lt;/li&gt;
&lt;li&gt;별도 컴파일 없이 쉘이 읽어서 실행한다&lt;/li&gt;
&lt;li&gt;변수, 조건문, 반복문을 사용할 수 있다&lt;/li&gt;
&lt;li&gt;운영 자동화와 반복 작업 처리에 적합하다&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;예를 들어 여러 명령을 매번 직접 입력하는 대신, 아래처럼 하나의 .sh 파일에 정리해둘 수 있다.&lt;br&gt;
이렇게 하면 동일한 작업을 반복할 때 사람이 직접 명령을 다시 입력하지 않아도 된다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;start&quot;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;date&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;done&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;Bash-Script의-기본-구조와-실행&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Bash-Script%EC%9D%98-%EA%B8%B0%EB%B3%B8-%EA%B5%AC%EC%A1%B0%EC%99%80-%EC%8B%A4%ED%96%89&quot; aria-label=&quot;Bash Script의 기본 구조와 실행 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Bash Script의 기본 구조와 실행&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;기본-구조&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B8%B0%EB%B3%B8-%EA%B5%AC%EC%A1%B0&quot; aria-label=&quot;기본 구조 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;기본 구조&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;기본적인 Bash 스크립트는 아래처럼 시작한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/bash&lt;/span&gt;

&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Hello, Bash&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;Shebang&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Shebang&quot; aria-label=&quot;Shebang permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Shebang&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;스크립트의 &lt;strong&gt;첫 줄&lt;/strong&gt;에 자주 보이는 아래 구문을 &lt;strong&gt;Shebang&lt;/strong&gt;이라고 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 줄은 운영체제에게 “이 파일은 &lt;code class=&quot;language-text&quot;&gt;/bin/bash&lt;/code&gt;로 실행하라”는 의미를 전달한다.&lt;br&gt;
즉, Shebang은 스크립트 파일 자체를 실행할 때 어떤 해석기를 사용할지 명시하는 역할이다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;예를 들어 Python 스크립트라면 이렇게 쓸 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/usr/bin/env python3&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;Bash 스크립트에서는 보통 다음 둘 중 하나를 자주 사용한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;실행-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%A4%ED%96%89-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;실행 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;실행 방식&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;Bash 스크립트는 대표적으로 두 방식으로 실행한다.&lt;/p&gt;
&lt;h4 id=&quot;1-bash-scriptsh&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-bash-scriptsh&quot; aria-label=&quot;1 bash scriptsh permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. &lt;code class=&quot;language-text&quot;&gt;bash script.sh&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;이 방식은 &lt;strong&gt;Bash 프로그램이 script.sh 파일을 읽어서 실행&lt;/strong&gt;하는 형태다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;실행 권한이 없어도 동작 가능&lt;/li&gt;
&lt;li&gt;Shebang이 없어도 Bash로 실행 가능&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;2-scriptsh&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-scriptsh&quot; aria-label=&quot;2 scriptsh permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. &lt;code class=&quot;language-text&quot;&gt;./script.sh&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;이 방식은 &lt;strong&gt;파일 자체를 실행&lt;/strong&gt;하는 형태다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;실행 권한이 있어야 함
&lt;code class=&quot;language-text&quot;&gt;chmod +x ./script.sh&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Shebang이 있어야 어떤 인터프리터로 실행할지 명확함&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;실행-예시&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%A4%ED%96%89-%EC%98%88%EC%8B%9C&quot; aria-label=&quot;실행 예시 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;실행 예시&lt;/h4&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/09468fca44ba016a0137c83265201185/200fa/chmod.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB60lEQVR42qWT32vTUBTH2+lEcDL7M0nbpDZtunZZWztb22XrSteK6BB8EaTidD74F0gb21VFBJ8EBf+I4dv+CDHg9pf44KNgb/L13GyWMacz7sKHc0nu/eScc298Phr4/m0N+PoEwCNi0yN8D+0dd3wHY/q12f/05u0r9LdesJ45hDl4jqe9wQFD9MytfZ6NfqM/GDFz+BLv3n/48kt4PjN/xcrpFcSU9Jhw4knNkWTVSVCMKRknGE04F2ajjn96xpk6d/EozHd2Brfv3N2dCOtG02rfWMfyaptpuSLUrA5V05GeK9B8gT6UgSSnISbU47CFuIrug829ibBab1h6qYrZkMQCkTguhffhc8oOESn5N+ywqOBed2PvUIYtq3X9FvRShfHMtHwR2XwJippzs/AsvFo1rFbnJlaaHVauGhTbMBprqNRX3PJDguI1w6ZlrLZRKF9j+YVFJNN5Iodo7DL4Ys8ZLjVaVnGxRn2LMf6S9y0kyIicLPtzyYVyjZ8mS2nzbu9c4cmy44VyKmvxK0JlMt4zOTV3OmFASHwO0UOS/KBybYo2X/iPjF3h/Ye79Av6XWFUSlqinIEQTzF+SSl6weaH1914PMnwTDAsDoMRaYfYJj56ZDsQFndqS8sjcrkZ+g8x9Z9MHD8BZ6+Kci3arRwAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;chmod&apos; title=&apos;&apos; src=&apos;/static/09468fca44ba016a0137c83265201185/ca1dc/chmod.png&apos; srcset=&apos;/static/09468fca44ba016a0137c83265201185/e7570/chmod.png 170w,
/static/09468fca44ba016a0137c83265201185/f46e7/chmod.png 340w,
/static/09468fca44ba016a0137c83265201185/ca1dc/chmod.png 680w,
/static/09468fca44ba016a0137c83265201185/200fa/chmod.png 913w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;실행 권한이 없는 상태에서, &lt;code class=&quot;language-text&quot;&gt;bash script.sh&lt;/code&gt; 방식으로 실행하면 성공하지만,&lt;br&gt;
&lt;code class=&quot;language-text&quot;&gt;./script.sh&lt;/code&gt; 방식으로 실행하면 실패한다.&lt;/li&gt;
&lt;li&gt;스크립트파일에 실행권한을 추가한 뒤에는 &lt;code class=&quot;language-text&quot;&gt;./script.sh&lt;/code&gt; 방식으로도 실행에 성공했다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;Bash-Script의-실행-흐름&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Bash-Script%EC%9D%98-%EC%8B%A4%ED%96%89-%ED%9D%90%EB%A6%84&quot; aria-label=&quot;Bash Script의 실행 흐름 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Bash Script의 실행 흐름&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;명령어-실행과-순차-처리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AA%85%EB%A0%B9%EC%96%B4-%EC%8B%A4%ED%96%89%EA%B3%BC-%EC%88%9C%EC%B0%A8-%EC%B2%98%EB%A6%AC&quot; aria-label=&quot;명령어 실행과 순차 처리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;명령어 실행과 순차 처리&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;Bash 스크립트는 &lt;strong&gt;명령을 위에서 아래로 순서대로 실행한다.&lt;/strong&gt;&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;한 줄에 명령 하나를 쓰면 그대로 실행된다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;여러 줄로 작성하면 순서대로 처리된다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;step 1&quot;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;date&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;step 2&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;한 줄에 세미콜론 &lt;code class=&quot;language-text&quot;&gt;;&lt;/code&gt;으로 이어서 쓸 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;step 1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;step 2&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;종료-코드-Exit-Code&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A2%85%EB%A3%8C-%EC%BD%94%EB%93%9C-Exit-Code&quot; aria-label=&quot;종료 코드 Exit Code permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;종료 코드 (Exit Code)&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;Shell에서 모든 명령은 실행이 끝난 뒤 &lt;strong&gt;종료 코드(exit code)&lt;/strong&gt; 를 남긴다.&lt;br&gt;
이 값은 명령의 성공 여부를 판단하는 기준이 된다.&lt;/p&gt;
&lt;p&gt;종료코드 값의 의미&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;0&lt;/code&gt; → 성공&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;0이 아닌 값&lt;/code&gt; → 실패 또는 예외 상황&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;로-결과-확인하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A1%9C-%EA%B2%B0%EA%B3%BC-%ED%99%95%EC%9D%B8%ED%95%98%EA%B8%B0&quot; aria-label=&quot;로 결과 확인하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;$?&lt;/code&gt;로 결과 확인하기&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;$?&lt;/code&gt; 를 통해 &lt;strong&gt;직전에 실행한 명령의 종료 코드&lt;/strong&gt;를 확인할 수 있다.&lt;/p&gt;
&lt;p&gt;운영 스크립트에서는 이 종료 코드를 바탕으로 다음 동작을 계속할지, 에러 처리할지를 판단하게 된다.&lt;/p&gt;
&lt;!-- &lt;br&gt; --&gt;
&lt;h4 id=&quot;예시&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%98%88%EC%8B%9C&quot; aria-label=&quot;예시 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;예시&lt;/h4&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/d947d64f72340ece17090321822179ab/200fa/exitcode.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 68.23529411764706%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsTAAALEwEAmpwYAAABnElEQVR42tWSW0sCQRSAt3qRyslWx1l1ttQ2iU2yNC9pdwi6INV/6CH6AUFR/8CnQCnLMkzqrT/VQ7A9RBGE5ZzOrj0UFWX00sDHOQznfHOVAKAV4FEHeIhjHvslZi86oEVaW9vkF8W9q8plGU5Oq0+l43K9cnZePzw6qR8clqxoUvya5/1iCcqV6k2hUHBLlFKtf3DE0MOj4Nd0oQZCwP0hcDIVSLcC7V0UbHYndGD8DHs3E202ArNzC/f5fF6VOOdaPDVuTMzMQTIzJSLRJCTGJiGZnoJINAX6UAxCegQ8ahCYL/ABnBcOlxcWs6sNIaVci8RSRiozDeHhhIgmMpbELKaeXlB40JKZ+Wcwn18QWYH5peWGkBCqMR4wFN4Hbq9f+Hr7zWgd2WxwKT0WTQmx2XhtFN8JvhIuvBWiwKC4KywQPxX9P+G7O3R51GvqNQt6ashTM6CwRmQmFrMrtw0hfmx8VYPhKzNfUCDQDB7eh/+Q4w5X73K5nCrJkkyIU1knsnsXV9rCuN0cbKvT4doJaAMb6XTaLv31eAHnfYq0BLqKBQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;exitcode&apos; title=&apos;&apos; src=&apos;/static/d947d64f72340ece17090321822179ab/ca1dc/exitcode.png&apos; srcset=&apos;/static/d947d64f72340ece17090321822179ab/e7570/exitcode.png 170w,
/static/d947d64f72340ece17090321822179ab/f46e7/exitcode.png 340w,
/static/d947d64f72340ece17090321822179ab/ca1dc/exitcode.png 680w,
/static/d947d64f72340ece17090321822179ab/200fa/exitcode.png 913w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;성공한 명령어 &lt;code class=&quot;language-text&quot;&gt;ls&lt;/code&gt; 의 종료 코드는 0&lt;/li&gt;
&lt;li&gt;실패한 명령어 &lt;code class=&quot;language-text&quot;&gt;cat&lt;/code&gt;의 종료 코드는 1&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;변수와-문자열&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B3%80%EC%88%98%EC%99%80-%EB%AC%B8%EC%9E%90%EC%97%B4&quot; aria-label=&quot;변수와 문자열 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;변수와 문자열&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;p&gt;Bash에서는 값을 변수에 저장해서 재사용할 수 있다.&lt;/p&gt;
&lt;h3 id=&quot;일반-변수&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9D%BC%EB%B0%98-%EB%B3%80%EC%88%98&quot; aria-label=&quot;일반 변수 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;일반 변수&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;일반 변수는 &lt;strong&gt;현재 쉘 안에서만&lt;/strong&gt; 사용하는 값이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;jiu&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;일반 변수를 정의할 때, &lt;code class=&quot;language-text&quot;&gt;=&lt;/code&gt; 양옆에 공백이 없어야 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;jiu&quot;&lt;/span&gt;   &lt;span class=&quot;token comment&quot;&gt;# 정상&lt;/span&gt;
name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;jiu&quot;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;# 오류&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;변수를 사용할 때는 앞에 &lt;code class=&quot;language-text&quot;&gt;$&lt;/code&gt;를 붙인다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;!-- &lt;br&gt; --&gt;
&lt;h4 id=&quot;예시-1&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%98%88%EC%8B%9C-1&quot; aria-label=&quot;예시 1 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;예시&lt;/h4&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/27446cfcbe344bd552e5c52468af9eeb/200fa/var.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 68.23529411764706%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsTAAALEwEAmpwYAAABjElEQVR42t2SzS4DURSAB4sSOpjOnem0M61px09M0qKlOn4WRKKVhr6DhXgACeENurFoUy1tFRUSb2UhGQthI2XucSZESLRUrNzky7mLc79z7r2HAYB2gMdRgPok7iO/xD6LDmhj1te35Fp+/7p8UYTDUvWpVDm2Li6vrNr5pVWpnloHxZJVOCw34zlfOILKydltLpcTGIfDoY1NzZjG7CKEI9N0PBqH0EQM7MiLCnQ5XdDdSxri7BdpRycLC0uJh2w2qzBElrVYfM6cMuZBD0dpGGV6KArD+hgo6hAIngEQvWpDJCVA+3gPJFPpVyFLiOYPjJjq4Ch4/YM0MKRjUhD6iRd4tw+I5G+K6B2gLOeG5ZXVNyFLNE5QTBdeD6EcRltkd/adrKGQuH3mm4D+RPKVMPFRiB2Z5N8LP70hLyk3xGMn+OrIUyugsM5yIk2m1u7exwY/xBTlIFYLUARaQZKDOIcydpi+z2QyCsMxHMu63BssJ+xhpW2MO60hbvf08buqNrJpGIaT+ev1AroCiX6zFZGYAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;var&apos; title=&apos;&apos; src=&apos;/static/27446cfcbe344bd552e5c52468af9eeb/ca1dc/var.png&apos; srcset=&apos;/static/27446cfcbe344bd552e5c52468af9eeb/e7570/var.png 170w,
/static/27446cfcbe344bd552e5c52468af9eeb/f46e7/var.png 340w,
/static/27446cfcbe344bd552e5c52468af9eeb/ca1dc/var.png 680w,
/static/27446cfcbe344bd552e5c52468af9eeb/200fa/var.png 913w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;=&lt;/code&gt; 양 옆에 공백이 있는 경우, 변수 저장이 되지 않는다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;문자열&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%9E%90%EC%97%B4&quot; aria-label=&quot;문자열 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문자열&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;Bash Script에서 문자열은 작은따옴표와 큰따옴표로 표현할 수 있다.&lt;/p&gt;
&lt;h4 id=&quot;작은따옴표--&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9E%91%EC%9D%80%EB%94%B0%EC%98%B4%ED%91%9C--&quot; aria-label=&quot;작은따옴표   permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;작은따옴표 &lt;code class=&quot;language-text&quot;&gt;&apos; &apos;&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;문자열을 &lt;strong&gt;있는 그대로&lt;/strong&gt; 취급한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;jiu&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;$name&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;출력&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h4 id=&quot;큰따옴표--&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%81%B0%EB%94%B0%EC%98%B4%ED%91%9C--&quot; aria-label=&quot;큰따옴표   permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;큰따옴표 &lt;code class=&quot;language-text&quot;&gt;&quot; &quot;&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;변수나 일부 특수 문자가 해석된다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;jiu&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;출력&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;jiu&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;변수-참조&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B3%80%EC%88%98-%EC%B0%B8%EC%A1%B0&quot; aria-label=&quot;변수 참조 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;변수 참조&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;변수 앞에 &lt;code class=&quot;language-text&quot;&gt;$&lt;/code&gt;를 붙여 값을 꺼낸다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;jiu&quot;&lt;/span&gt;  
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;중괄호를 써서 경계를 명확히 할 수도 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;${name}&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;중괄호는 변수명과 다른 문자열이 붙을 때 특히 유용하다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;log&quot;&lt;/span&gt;  
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;${file}&lt;/span&gt;.txt&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h4 id=&quot;문자열과-변수-참조-예시&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%9E%90%EC%97%B4%EA%B3%BC-%EB%B3%80%EC%88%98-%EC%B0%B8%EC%A1%B0-%EC%98%88%EC%8B%9C&quot; aria-label=&quot;문자열과 변수 참조 예시 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문자열과 변수 참조 예시&lt;/h4&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/3aad35b10d0c95a4a5fe04b89282c633/200fa/var2.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAABoElEQVR42s2TSUoDQRSG2xFBRTJ00m3mmKHNYKPRJBJRHHAhCCIIEnFceAM1RhuDguJCUPAQwV0OIRYYT+IBBFPp36oQowsTbFcWfNSm3lf/K14JAlt4e50DXvcB7DB2DcJrWG1lQaivrsv88ePVzTlypwWay2soXFzi6voG2tkFDnKnODzWmnKU12jupIDbu/vnT2FPOD5OlEgCktNXEWWPbpXcusMd0Acssi509ert3f2toEJnH5ZX1soN4UQ6QxKpKUTVcRqOjmI4PgZ1LI2YOgG7w8cu8reianf4kd3cfWkIk5PTZHp2EaGISodCMQSHVS6HPxSFbdALlroVVdYR1rNbX8LMzDxZWl5FIpmhaiJdSxdhKQNKHE5vELzAkJAlIUpsFG5/mAaUEXiGFJhEx2/S/Sw0iYPEbHfBYndRs83J99+ImgtF2U34w9pkDzUgai60Si5Sb+//Cp/qwnd+wCCVmnBju8y+YFv9DT2EDykbYsoH2SBVHia7tddI2GG2SidmUS4xiowHgxRNVqmUmsxozFVL2PaN9j/ScHwAdjeGLEjl5/kAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;var2&apos; title=&apos;&apos; src=&apos;/static/3aad35b10d0c95a4a5fe04b89282c633/ca1dc/var2.png&apos; srcset=&apos;/static/3aad35b10d0c95a4a5fe04b89282c633/e7570/var2.png 170w,
/static/3aad35b10d0c95a4a5fe04b89282c633/f46e7/var2.png 340w,
/static/3aad35b10d0c95a4a5fe04b89282c633/ca1dc/var2.png 680w,
/static/3aad35b10d0c95a4a5fe04b89282c633/200fa/var2.png 913w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;작은따옴표로 감싼 문자열은 있는 그대로 저장된다.&lt;/li&gt;
&lt;li&gt;큰따옴표로 감싼 문자열은 변수 해석이 적용된다.&lt;/li&gt;
&lt;li&gt;중괄호를 써서 변수 경계를 명확히 할 수 있다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;환경변수와-export&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%98%EA%B2%BD%EB%B3%80%EC%88%98%EC%99%80-export&quot; aria-label=&quot;환경변수와 export permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;환경변수와 export&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;환경-변수&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%98%EA%B2%BD-%EB%B3%80%EC%88%98&quot; aria-label=&quot;환경 변수 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;환경 변수&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;환경 변수는 현재 쉘 + 현재 쉘이 실행하는 &lt;strong&gt;자식 프로세스에도 전달되는 변수&lt;/strong&gt;다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;jiu&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;위처럼 환경변수를 설정하면 이후 실행되는 프로그램도 &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt; 값을 참조할 수 있다.&lt;/p&gt;
&lt;p&gt;환경 변수는 단순한 저장값이 아니라 &lt;strong&gt;실행 환경의 일부&lt;/strong&gt;라고 볼 수 있다.&lt;br&gt;
그래서 자식에게 상속되는 문맥에 포함되는 것이다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;export의-의미&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#export%EC%9D%98-%EC%9D%98%EB%AF%B8&quot; aria-label=&quot;export의 의미 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;export의 의미&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;export&lt;/code&gt;는 변수를 환경 변수로 내보내는 명령이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;jiu&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;export&lt;/span&gt; name

&lt;span class=&quot;token comment&quot;&gt;# 한 줄로 쓸 수도 있다.&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;jiu&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;예시-2&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%98%88%EC%8B%9C-2&quot; aria-label=&quot;예시 2 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;예시&lt;/h4&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/946bb8e547b056cfbd217dc461daa4f1/b88a2/env.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 75.88235294117648%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAABYlAAAWJQFJUiTwAAABf0lEQVR42u2Sy07CQBSG0aACxlKgF3qB0spFlKgQlYV7FyaYiDFq9Bl0beLCGAIoYggQWPEsLA3VN4Lp8Yw0yIZIF+6c5MuZnPb/5kxalwsXAOwDWEWsBeTEITRDswcuey1XHu7fa80yPJaq5KlUgbdGC5rtLtTqDShXa1B5riOvUJ6C9mitvtQJra12Z4DSJSr0ycaGmUhnQdbiI1HVLVHRrVh80wqKEcuzFrJWWcHy+XnLy3Djivj84x4+Gy2uMHB0XPhAoZcKvdu5vJnLH0I8vUP0ZAaSmSwYqQwosSTwcgwERZ+JqBqE5VU4u7j+RKHnW4iTmdH1NChagkSMFOjJLQgIKnCS9it4IGE4GU7PL3+EAUExQ2EN8IokFI6iLDKXbKYwKEZNejV8gcwr+hf+rdCHX3ZgC4e2dG4wN6TC4vmVOZmQkzVTUA3gFZ0g4ATMEb9Af+ybyYRuNijdsrzUC3BSh+WkrhNohgkIvd3c3l2/33dT4YLN9N4pk+wXTtyjh9Mm44MAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;env&apos; title=&apos;&apos; src=&apos;/static/946bb8e547b056cfbd217dc461daa4f1/ca1dc/env.png&apos; srcset=&apos;/static/946bb8e547b056cfbd217dc461daa4f1/e7570/env.png 170w,
/static/946bb8e547b056cfbd217dc461daa4f1/f46e7/env.png 340w,
/static/946bb8e547b056cfbd217dc461daa4f1/ca1dc/env.png 680w,
/static/946bb8e547b056cfbd217dc461daa4f1/02d09/env.png 1020w,
/static/946bb8e547b056cfbd217dc461daa4f1/9d567/env.png 1360w,
/static/946bb8e547b056cfbd217dc461daa4f1/b88a2/env.png 1844w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;export를 실행하지 않으면 현재 쉘이 생성한 자식 bash 프로세스에서 &lt;code class=&quot;language-text&quot;&gt;$name&lt;/code&gt;을 인식하지 못한다.&lt;/li&gt;
&lt;li&gt;export를 실행하면 현재 쉘이 생성한 자식 bash 프로세스에서 &lt;code class=&quot;language-text&quot;&gt;$name&lt;/code&gt;을 인식한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;export의-유효기간&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#export%EC%9D%98-%EC%9C%A0%ED%9A%A8%EA%B8%B0%EA%B0%84&quot; aria-label=&quot;export의 유효기간 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;export의 유효기간&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;export&lt;/code&gt;한 변수는 현재 쉘과 그 자식 프로세스에서 유효하지만,&lt;br&gt;
&lt;strong&gt;현재 세션이 끝나면 사라진다&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;즉, 아래 경우에는 더 이상 유지되지 않는다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;터미널 세션 종료&lt;/li&gt;
&lt;li&gt;해당 쉘 종료&lt;/li&gt;
&lt;li&gt;새로 로그인한 다른 쉘 시작&lt;/li&gt;
&lt;li&gt;시스템 재부팅 후 새 세션 시작&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;환경변수-영구적으로-유지하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%98%EA%B2%BD%EB%B3%80%EC%88%98-%EC%98%81%EA%B5%AC%EC%A0%81%EC%9C%BC%EB%A1%9C-%EC%9C%A0%EC%A7%80%ED%95%98%EA%B8%B0&quot; aria-label=&quot;환경변수 영구적으로 유지하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;환경변수 영구적으로 유지하기&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;특정 환경변수를 영구적으로 유지하려면&lt;br&gt;
매번 새 쉘이 시작될 때 다시 설정되도록 &lt;strong&gt;Shell 초기화 파일&lt;/strong&gt;에 적어야 한다.&lt;/p&gt;
&lt;p&gt;보통 아래 파일 중 하나에 export 문을 넣는다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;~/.bashrc&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;~/.bash_profile&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;~/.profile&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;실제로 &lt;code class=&quot;language-text&quot;&gt;~/.bashrc&lt;/code&gt; 파일을 보면, PATH 환경변수를 지정하는 export 문이 기본으로 써있다.
&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/71624596c3012e99a0675f7c755e7077/200fa/bashrc.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAACgUlEQVR42p2TXU/TYBTH5xDlQsWwvj59b7eua7uNDQYKOJ0SNSYkekECxDdujJpoYgwiEozxzjtN/BCEOz6EsYn4UbzyznX7e9rBgBCD2uTX5/RJzy/nnKfNZOhC++dV4McjAA+J5X8kyaHc9mymd40Nvl9b+7Ly4S0eP3sRP3n6HC9X1rGyuoFXa8ez+mYjfr3+Dh8/ff62K8wMDVtWxLs+1HK9LXnV7nnb7g6rcjc7eLY7MHSum004TTGRrNlTh4gzJ89g7vb8Tl9oOVqULxYxWpuMS+UxaIYB3TIgKCYk1kNULYiKnSKph+gke0v3lr/3haofRnptAlJjKlaCCrTJy9CqUzB0D8wOIblVqKoD1bTANB2cbIDfp8NJOhaW7u8Li6EWuRMNqM3Z2PRrKJan4VSb8MpNOOVLEMebMJidVq0ZKjiRpKIGnqD1qDDv61GhEsAohLGg5SEZeQiaDU6jNnUHArXLJ3uWB0F3IZoFyPkSJKsIyfY6HI3kkFCdaEVm6xb0mVZsta7Dat2A7NehlEahBDVK9sEKARS/CuYGkJM4rIMVy2BepcPTLBcWDwjtsheVGhWEF2fioDGN8EID/hgleWFaBScoaYucoPbWBF7pPQtqJycmLT/YF/ICiyzHRBCasTs+Dr9eQ61uQTd78+LZ7gFQayl7cW89OkOBaVHB08F0Lc4ZLnIySWQaumwePM0/kQoX7x6oMAjZVycgkWT+opPrJC8dB0lSKG7nSDh3Z36HfsET5DOGVMONZD1PH60VE/gbJM1JEallRrlXrt3sVzgwwrH1EU7eHuHlTWLrOM7npC1JMVIo3lR0e7sy2tggV1Jhetsj+5/0Hb8BtWGKtu9VqggAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;bashrc&apos; title=&apos;&apos; src=&apos;/static/71624596c3012e99a0675f7c755e7077/ca1dc/bashrc.png&apos; srcset=&apos;/static/71624596c3012e99a0675f7c755e7077/e7570/bashrc.png 170w,
/static/71624596c3012e99a0675f7c755e7077/f46e7/bashrc.png 340w,
/static/71624596c3012e99a0675f7c755e7077/ca1dc/bashrc.png 680w,
/static/71624596c3012e99a0675f7c755e7077/200fa/bashrc.png 913w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;자주-보는-환경-변수-PATH-HOME-USER&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9E%90%EC%A3%BC-%EB%B3%B4%EB%8A%94-%ED%99%98%EA%B2%BD-%EB%B3%80%EC%88%98-PATH-HOME-USER&quot; aria-label=&quot;자주 보는 환경 변수 PATH HOME USER permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;자주 보는 환경 변수: &lt;code class=&quot;language-text&quot;&gt;PATH&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;HOME&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;USER&lt;/code&gt;&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;운영체제는 여러 기본 환경 변수를 제공한다.&lt;/p&gt;
&lt;h4 id=&quot;PATH&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#PATH&quot; aria-label=&quot;PATH permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;PATH&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;명령어를 찾을 디렉터리 목록&lt;/strong&gt;이다.
예를 들어 &lt;code class=&quot;language-text&quot;&gt;ls&lt;/code&gt;라고만 입력해도 실행되는 이유는&lt;br&gt;
Shell이 알아서 &lt;code class=&quot;language-text&quot;&gt;PATH&lt;/code&gt;에 등록된 디렉터리들에서 &lt;code class=&quot;language-text&quot;&gt;ls&lt;/code&gt; 실행 파일을 찾기 때문이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token environment constant&quot;&gt;$PATH&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;HOME&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#HOME&quot; aria-label=&quot;HOME permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;HOME&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;현재 사용자의 홈 디렉터리다.
&lt;code class=&quot;language-text&quot;&gt;/home/user&lt;/code&gt; 같은 값이 들어 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token environment constant&quot;&gt;$HOME&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;USER&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#USER&quot; aria-label=&quot;USER permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;USER&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;현재 사용자 이름이다.
스크립트 안에서 실행 계정을 확인할 때 자주 사용한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token environment constant&quot;&gt;$USER&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;예시-3&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%98%88%EC%8B%9C-3&quot; aria-label=&quot;예시 3 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;예시&lt;/h4&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/946bb8e547b056cfbd217dc461daa4f1/b88a2/env.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 75.88235294117648%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAABYlAAAWJQFJUiTwAAABf0lEQVR42u2Sy07CQBSG0aACxlKgF3qB0spFlKgQlYV7FyaYiDFq9Bl0beLCGAIoYggQWPEsLA3VN4Lp8Yw0yIZIF+6c5MuZnPb/5kxalwsXAOwDWEWsBeTEITRDswcuey1XHu7fa80yPJaq5KlUgbdGC5rtLtTqDShXa1B5riOvUJ6C9mitvtQJra12Z4DSJSr0ycaGmUhnQdbiI1HVLVHRrVh80wqKEcuzFrJWWcHy+XnLy3Djivj84x4+Gy2uMHB0XPhAoZcKvdu5vJnLH0I8vUP0ZAaSmSwYqQwosSTwcgwERZ+JqBqE5VU4u7j+RKHnW4iTmdH1NChagkSMFOjJLQgIKnCS9it4IGE4GU7PL3+EAUExQ2EN8IokFI6iLDKXbKYwKEZNejV8gcwr+hf+rdCHX3ZgC4e2dG4wN6TC4vmVOZmQkzVTUA3gFZ0g4ATMEb9Af+ybyYRuNijdsrzUC3BSh+WkrhNohgkIvd3c3l2/33dT4YLN9N4pk+wXTtyjh9Mm44MAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;env&apos; title=&apos;&apos; src=&apos;/static/946bb8e547b056cfbd217dc461daa4f1/ca1dc/env.png&apos; srcset=&apos;/static/946bb8e547b056cfbd217dc461daa4f1/e7570/env.png 170w,
/static/946bb8e547b056cfbd217dc461daa4f1/f46e7/env.png 340w,
/static/946bb8e547b056cfbd217dc461daa4f1/ca1dc/env.png 680w,
/static/946bb8e547b056cfbd217dc461daa4f1/02d09/env.png 1020w,
/static/946bb8e547b056cfbd217dc461daa4f1/9d567/env.png 1360w,
/static/946bb8e547b056cfbd217dc461daa4f1/b88a2/env.png 1844w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;명령행-인자&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AA%85%EB%A0%B9%ED%96%89-%EC%9D%B8%EC%9E%90&quot; aria-label=&quot;명령행 인자 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;명령행 인자&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;명령행-인자-0-1-2--&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AA%85%EB%A0%B9%ED%96%89-%EC%9D%B8%EC%9E%90-0-1-2--&quot; aria-label=&quot;명령행 인자 0 1 2   permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;명령행 인자: &lt;code class=&quot;language-text&quot;&gt;$0&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;$1&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;$2&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;$#&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;$@&lt;/code&gt;&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;스크립트를 실행할 때 뒤에 값을 붙이면 그 값들을 스크립트 안에서 참조할 수 있다.&lt;br&gt;
이를 통해 스크립트를 입력에 따라 다르게 동작하게 할 수 있다.&lt;/p&gt;
&lt;p&gt;아래처럼 스크립트 실행 시 인자를 넘겨준다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;bash&lt;/span&gt; hello.sh apple banana&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;스크립트 내부에서는 다음처럼 접근한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;$0&lt;/code&gt; : 스크립트 이름&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;$1&lt;/code&gt; : 첫 번째 인자&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;$2&lt;/code&gt; : 두 번째 인자&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;$#&lt;/code&gt; : 인자 개수&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;$@&lt;/code&gt; : 전체 인자 목록&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;예시-4&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%98%88%EC%8B%9C-4&quot; aria-label=&quot;예시 4 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;예시&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;hello.sh&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/bash&lt;/span&gt;

&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;script: &lt;span class=&quot;token variable&quot;&gt;$0&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;first: &lt;span class=&quot;token variable&quot;&gt;$1&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;second: &lt;span class=&quot;token variable&quot;&gt;$2&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;third: &lt;span class=&quot;token variable&quot;&gt;$3&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;count: &lt;span class=&quot;token variable&quot;&gt;$#&lt;/span&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;all: &lt;span class=&quot;token variable&quot;&gt;$@&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/ab2fc4d44045b61fdc100955af7344ec/200fa/parameter.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAACFklEQVR42p2T224SURSGp1UbY1RaGGBggGE4UyiWYynlIAVrY9qkNybaeOpNH8GihIIVbaI21saHaLzrQxgnsb6Hd97Lht+9pzADTRPFnXzZa09mfXutNRmOowudX8sEP7cJ8AzA1piwnG2gU+X660q7tvP1w9E+dvfekkZzD+8PDnHw8Qjt/XdotF6j+eoNdltt1OpNPH/RGGHnZYPU6i0cfvr8fSC8GojElXgyj1uJhY5VlHvTvL130yj0DCZbz2C0aeepa9O9yakb5yHc5etY37h/qglzhbJSXF5BPJ0jZsEFo8UJsyCBp7GOBIvdDUGUITg8w3Stogebj7d+aML5VFbJ5suYjSXJ3HwG4WgCouSHUw6quDxBONwBGgdgd/nUC8w2aUCXnR9sPtGFmcWiUr27hjurayQcjcMbjELyhiH7Iyo+enb7wvAEIqr8r8JUZklJLxYRnkuQGbMIA2+nbTvU1s9wwGQ9i9k+JNOEDx891YXJdE4plFdA2yWpbAGx+AL8oZg6I5bEZjcQDMe6UMK99Q1daHN6FNaa5A0R2T+rzo0lXpB8EV22LxXLutBkcSqsbNoOYS2dm9E/CYulqi7kBafSr4aMIRoR5kuVEeG3vvB3/4Vx6DBhoVQ5BcdNqEL6QGEfgP4lhIIx6bL9dmVVq/CSkRfqRrPthHJM+TImxzO8cBKKxhpcv8KJISb/E83xBzDuhcvT35eKAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;parameter&apos; title=&apos;&apos; src=&apos;/static/ab2fc4d44045b61fdc100955af7344ec/ca1dc/parameter.png&apos; srcset=&apos;/static/ab2fc4d44045b61fdc100955af7344ec/e7570/parameter.png 170w,
/static/ab2fc4d44045b61fdc100955af7344ec/f46e7/parameter.png 340w,
/static/ab2fc4d44045b61fdc100955af7344ec/ca1dc/parameter.png 680w,
/static/ab2fc4d44045b61fdc100955af7344ec/200fa/parameter.png 913w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[리눅스 자원 제어: cgroup]]></title><description><![CDATA[멀티 유저, 멀티 프로세스 운영 환경에서는 각 서비스가 얼마나 CPU…]]></description><link>https://jiu-jung.github.io/rhel-cgroup/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-cgroup/</guid><pubDate>Wed, 01 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;멀티 유저, 멀티 프로세스 운영 환경에서는&lt;br&gt;
각 서비스가 얼마나 CPU와 메모리를 사용할 수 있는지,&lt;br&gt;
그리고 하나의 서비스 문제가 다른 서비스까지 번지지 않도록 어떻게 통제할 것인지가 중요하다.&lt;/p&gt;
&lt;p&gt;따라서 프로세스를 실행 대상뿐만 아니라, &lt;strong&gt;자원 관리의 대상&lt;/strong&gt;으로도 다뤄야 한다.&lt;/p&gt;
&lt;p&gt;이 글에서는 Red Hat 리눅스가 자원 통제를 어떻게 수행하는지, 다음 순서로 정리한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-cgroup/#cgroup-%EC%9E%90%EC%9B%90-%EA%B4%80%EB%A6%AC%EC%9D%98-%ED%95%B5%EC%8B%AC&quot;&gt;&lt;strong&gt;cgroup&lt;/strong&gt;: 자원 관리의 핵심&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-cgroup/#systemd-cgroup%EC%9D%98-%EA%B4%80%EB%A6%AC-%EC%A3%BC%EC%B2%B4&quot;&gt;&lt;strong&gt;systemd&lt;/strong&gt;: cgroup의 관리 주체&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-cgroup/#RHEL%EC%97%90%EC%84%9C-%EB%B3%B4%EB%8A%94-cgroup-%EA%B5%AC%EC%A1%B0&quot;&gt;RHEL에서 보는 cgroup 구조&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-cgroup/#%EC%9E%90%EC%9B%90-%EC%A0%9C%EC%96%B4%EC%9D%98-%EB%8F%99%EC%9E%91-%EB%B0%A9%EC%8B%9D&quot;&gt;자원 제어의 동작 방식&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h2 id=&quot;cgroup-자원-관리의-핵심&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#cgroup-%EC%9E%90%EC%9B%90-%EA%B4%80%EB%A6%AC%EC%9D%98-%ED%95%B5%EC%8B%AC&quot; aria-label=&quot;cgroup 자원 관리의 핵심 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;cgroup: 자원 관리의 핵심&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;cgroup이란&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#cgroup%EC%9D%B4%EB%9E%80&quot; aria-label=&quot;cgroup이란 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;cgroup이란?&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;cgroup은 &lt;strong&gt;Control Group&lt;/strong&gt;의 약자로,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;여러 프로세스&lt;/strong&gt;를 하나의 그룹으로 묶고&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;그룹 단위로 자원을 제한하고 추적&lt;/strong&gt;하는&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;리눅스 커널 기능&lt;/strong&gt;이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;예를 들어 다음과 같은 정책을 적용할 수 있다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;이 서비스는 메모리를 512MB까지만 사용&lt;/li&gt;
&lt;li&gt;이 서비스는 CPU를 일정 비율까지만 사용&lt;/li&gt;
&lt;li&gt;이 서비스는 생성 가능한 프로세스 수를 제한&lt;/li&gt;
&lt;li&gt;이 서비스의 디스크 I/O를 제한&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;리눅스는 cgroup이라는 커널 기능을 통해 &lt;strong&gt;프로세스 그룹 단위로 자원을 제어&lt;/strong&gt;한다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;cgroup이-제공하는-기능&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#cgroup%EC%9D%B4-%EC%A0%9C%EA%B3%B5%ED%95%98%EB%8A%94-%EA%B8%B0%EB%8A%A5&quot; aria-label=&quot;cgroup이 제공하는 기능 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;cgroup이 제공하는 기능&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;cgroup은 크게 네 가지 기능을 제공한다.&lt;/p&gt;
&lt;h4 id=&quot;1-자원-제한-Limit&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-%EC%9E%90%EC%9B%90-%EC%A0%9C%ED%95%9C-Limit&quot; aria-label=&quot;1 자원 제한 Limit permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. 자원 제한 (Limit)&lt;/h4&gt;
&lt;p&gt;각 그룹에 사용할 수 있는 자원 한도를 설정할 수 있다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CPU 사용량 제한&lt;/li&gt;
&lt;li&gt;메모리 사용량 제한&lt;/li&gt;
&lt;li&gt;디스크 I/O 제한&lt;/li&gt;
&lt;li&gt;프로세스 수 제한&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;2-자원-격리-Isolation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-%EC%9E%90%EC%9B%90-%EA%B2%A9%EB%A6%AC-Isolation&quot; aria-label=&quot;2 자원 격리 Isolation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. 자원 격리 (Isolation)&lt;/h4&gt;
&lt;p&gt;하나의 서비스가 문제를 일으켜도
다른 서비스까지 영향을 주지 않도록 분리할 수 있다.&lt;/p&gt;
&lt;h4 id=&quot;3-우선순위-제어-Priority&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-%EC%9A%B0%EC%84%A0%EC%88%9C%EC%9C%84-%EC%A0%9C%EC%96%B4-Priority&quot; aria-label=&quot;3 우선순위 제어 Priority permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3. 우선순위 제어 (Priority)&lt;/h4&gt;
&lt;p&gt;특정 서비스에 더 많은 CPU 비중을 주거나,
덜 중요한 작업의 우선순위를 낮출 수 있다.&lt;/p&gt;
&lt;h4 id=&quot;4-사용량-추적-Accounting&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-%EC%82%AC%EC%9A%A9%EB%9F%89-%EC%B6%94%EC%A0%81-Accounting&quot; aria-label=&quot;4 사용량 추적 Accounting permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;4. 사용량 추적 (Accounting)&lt;/h4&gt;
&lt;p&gt;그룹 단위로 CPU, 메모리, I/O 사용량을 추적할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;systemd-cgroup의-관리-주체&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemd-cgroup%EC%9D%98-%EA%B4%80%EB%A6%AC-%EC%A3%BC%EC%B2%B4&quot; aria-label=&quot;systemd cgroup의 관리 주체 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemd: cgroup의 관리 주체&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;systemd와-cgroup의-관계&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemd%EC%99%80-cgroup%EC%9D%98-%EA%B4%80%EA%B3%84&quot; aria-label=&quot;systemd와 cgroup의 관계 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemd와 cgroup의 관계&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;현대 리눅스에서 서비스 관리는 &lt;strong&gt;systemd&lt;/strong&gt;가 담당한다.&lt;/p&gt;
&lt;p&gt;systemd는 다음과 같은 운영 기능을 제공한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;서비스 시작과 종료&lt;/li&gt;
&lt;li&gt;상태 관리&lt;/li&gt;
&lt;li&gt;자동 재시작&lt;/li&gt;
&lt;li&gt;의존성 관리&lt;/li&gt;
&lt;li&gt;로그 연계&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;자원 제어&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 가운데 &lt;strong&gt;자원 제어&lt;/strong&gt;를 실제로 가능하게 해주는 기반이 바로 &lt;strong&gt;cgroup&lt;/strong&gt;이다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;서비스별-cgroup-생성과-적용&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%84%9C%EB%B9%84%EC%8A%A4%EB%B3%84-cgroup-%EC%83%9D%EC%84%B1%EA%B3%BC-%EC%A0%81%EC%9A%A9&quot; aria-label=&quot;서비스별 cgroup 생성과 적용 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;서비스별 cgroup 생성과 적용&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;systemd는 서비스를 실행할 때,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;해당 서비스 전용 cgroup&lt;/strong&gt; 을 만들고&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;관련 프로세스를 모두 그 안에 넣는다.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;그 다음 &lt;strong&gt;필요한 자원 정책을 그 cgroup에 적용&lt;/strong&gt;한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;정리하면 내부 동작은 다음과 같다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;1. 서비스 실행
2. 해당 서비스용 cgroup 생성
3. 관련 프로세스를 그 cgroup에 배치
4. 자원 정책 적용&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;systemctl-status로-cgroup-확인하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemctl-status%EB%A1%9C-cgroup-%ED%99%95%EC%9D%B8%ED%95%98%EA%B8%B0&quot; aria-label=&quot;systemctl status로 cgroup 확인하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemctl status로 cgroup 확인하기&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;systemctl status&lt;/code&gt;를 보면 다음과 같은 항목이 보인다.&lt;/p&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/089b582cf66f51199d728756415eee5a/21c61/systemctl_status.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 33.529411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAABYlAAAWJQFJUiTwAAABUElEQVR42m2R25KCMBBE+QUVUEBuIUi4hRCuopb7/z/VO0RftmofTk2mU+memlh6ekDPT4hao+kmjMsLXb+ilAPpD9SkuUFqOF+ZqU6QwI4ZnGvy7ekuzeBGDFYlRwz0MNca1bZCLDOa9wa1bpi3N8b1heXxY0KlXtCoGYXSKJ4Lin4w4alo4HcVAiFgZUKibMlMjVDLhuH+Qi575LUCp7tMtMirDpcog+3FcHyaasf71L3f9ZMb4nSOYMVZCXZrUDY9Or1C9gsy6sO0wNG94ngOTbUvERx6aP+D0f0PFq8U1LQhLVozFaOJdi4Rx4EST3s6TfOp/3P81t3ckizHk3Zx73qsksxvgigheYEq5Shp+TyIwP3wD/lXywhBBH5kjK0hjiETBs1vmEWJiQyHvMBC57WsTS/jFF3K0DNuzi3RZzkU/ayk0DlJkHghDl6MX0u1yEUF0MMAAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;systemctl status&apos; title=&apos;&apos; src=&apos;/static/089b582cf66f51199d728756415eee5a/ca1dc/systemctl_status.png&apos; srcset=&apos;/static/089b582cf66f51199d728756415eee5a/e7570/systemctl_status.png 170w,
/static/089b582cf66f51199d728756415eee5a/f46e7/systemctl_status.png 340w,
/static/089b582cf66f51199d728756415eee5a/ca1dc/systemctl_status.png 680w,
/static/089b582cf66f51199d728756415eee5a/02d09/systemctl_status.png 1020w,
/static/089b582cf66f51199d728756415eee5a/21c61/systemctl_status.png 1353w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;CGroup: /system.slice/sshd.service&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 의미는 다음과 같다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;sshd.service&lt;/code&gt;에 속한 프로세스들이&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;/system.slice/sshd.service&lt;/code&gt;라는 cgroup 아래 묶여 있고&lt;/li&gt;
&lt;li&gt;그 단위로 자원 관리가 이루어진다는 뜻이다&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;RHEL에서-보는-cgroup-구조&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#RHEL%EC%97%90%EC%84%9C-%EB%B3%B4%EB%8A%94-cgroup-%EA%B5%AC%EC%A1%B0&quot; aria-label=&quot;RHEL에서 보는 cgroup 구조 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;RHEL에서 보는 cgroup 구조&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;cgroup-버전&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#cgroup-%EB%B2%84%EC%A0%84&quot; aria-label=&quot;cgroup 버전 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;cgroup 버전&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;RHEL에서는 cgroup 버전에 따라 구조가 다르다.&lt;/p&gt;
&lt;p&gt;cgroup v1에서는 리소스별로 CPU, 메모리, I/O 등이 각각 별도의 계층으로 나뉘어,&lt;br&gt;
&lt;strong&gt;CPU용 트리와 메모리용 트리가 따로&lt;/strong&gt; 존재했다.&lt;/p&gt;
&lt;p&gt;반면 cgroup v2는 &lt;strong&gt;모든 자원을 하나의 트리에서 통합 관리&lt;/strong&gt;한다.&lt;/p&gt;
&lt;p&gt;이 구조는 다음 장점이 있다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;구조가 단순함&lt;/li&gt;
&lt;li&gt;systemd와의 통합이 쉬움&lt;/li&gt;
&lt;li&gt;자원 관리 방식이 일관됨&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;RHEL 9 이상에서는 cgroup v2 구조가 기본이다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;cgroup-기본-경로&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#cgroup-%EA%B8%B0%EB%B3%B8-%EA%B2%BD%EB%A1%9C&quot; aria-label=&quot;cgroup 기본 경로 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;cgroup 기본 경로&lt;/h3&gt;
&lt;br&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;/sys/fs/cgroup/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;cgroup v2의 기본 경로는 위와 같다.&lt;br&gt;
이 아래에서 systemd가 관리하는 서비스와 자원 구조를 확인할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;systemd가-관리하는-cgroup-단위&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemd%EA%B0%80-%EA%B4%80%EB%A6%AC%ED%95%98%EB%8A%94-cgroup-%EB%8B%A8%EC%9C%84&quot; aria-label=&quot;systemd가 관리하는 cgroup 단위 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemd가 관리하는 cgroup 단위&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;cgroup 기본 경로 아래에는 systemd가 만든 단위들이 계층적으로 나타난다.&lt;br&gt;
주요 단위는 다음과 같다.&lt;/p&gt;
&lt;h4 id=&quot;1-slice&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-slice&quot; aria-label=&quot;1 slice permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. slice&lt;/h4&gt;
&lt;p&gt;slice는 systemd가 만든 &lt;strong&gt;상위 논리 그룹&lt;/strong&gt;이다.&lt;br&gt;
자원 분배의 큰 틀을 나누는 단위라고 볼 수 있다.&lt;br&gt;
예를 들어 &lt;code class=&quot;language-text&quot;&gt;system.slice&lt;/code&gt; 아래에 있다는 것은 해당 unit이 시스템 서비스 영역에 속한다는 뜻이다.&lt;/p&gt;
&lt;h4 id=&quot;2-service&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-service&quot; aria-label=&quot;2 service permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. service&lt;/h4&gt;
&lt;p&gt;service는 실제 서비스 단위이다.&lt;br&gt;
보통 systemd의 service unit과 1:1로 대응한다.&lt;br&gt;
예: &lt;code class=&quot;language-text&quot;&gt;sshd.service&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;nginx.service&lt;/code&gt;&lt;/p&gt;
&lt;h4 id=&quot;3-scope&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-scope&quot; aria-label=&quot;3 scope permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3. scope&lt;/h4&gt;
&lt;p&gt;scope는 서비스 외부에서 시작된 프로세스를 systemd 관리 범위 안에 포함시킬 때 사용하는 단위다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;정리하면 다음과 같다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;slice&lt;/strong&gt;: 상위 그룹&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;service&lt;/strong&gt;: 실제 서비스 단위&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;scope&lt;/strong&gt;: 외부 프로세스 관리 단위&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;cgroup-controller-파일&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#cgroup-controller-%ED%8C%8C%EC%9D%BC&quot; aria-label=&quot;cgroup controller 파일 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;cgroup controller 파일&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;실제 자원 제한과 사용량 확인은 &lt;strong&gt;controller 파일&lt;/strong&gt;을 통해 이루어진다.&lt;/p&gt;
&lt;p&gt;cgroup 디렉터리 안에는 자원 제한과 상태 확인에 사용하는 controller 파일들이 있다.&lt;br&gt;
이 파일들이 &lt;strong&gt;실제 자원 제어 인터페이스&lt;/strong&gt; 역할을 한다.&lt;/p&gt;
&lt;p&gt;대표적인 controller는 다음과 같다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;controller&lt;/th&gt;
&lt;th&gt;역할&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;cpu&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;CPU 사용량 제어&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;memory&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;메모리 제한 및 사용량 확인&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;io&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;디스크 I/O 제어&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;pids&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;프로세스 수 제한&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;p&gt;예를 들어 다음 경로를 보자.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;/sys/fs/cgroup/system.slice/sshd.service/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 안에는 다음과 같은 파일이 있을 수 있다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;cpu.max&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;memory.max&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;memory.current&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;pids.max&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 파일들의 의미는 다음과 같다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;*.max&lt;/code&gt; : 어디까지 허용할 것인가&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;*.current&lt;/code&gt; : 지금 얼마나 쓰고 있는가&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;실제로 출력해보면 아래처럼 값이 나타난다.&lt;/p&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/973bade2cc88db04fb1f5d4a34dbe769/00706/controller.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 54.70588235294118%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAABYlAAAWJQFJUiTwAAABjUlEQVR42mVSWXaDMAzkDN2TsJjVgFkTyEvSNv1o738lVSMMDemHnkC2RzMaOUVzoOH0QZfrN43nK+mqpyApKa/2lJUdpUVLadlKjvOawsxQZjrCu22Q0uObT0+bYAmnOZyoHc70/vXDwJ+k0pJ2KuNsGLggP+bgjCZeqMnl8KKc6zkprv0DRHefL7gMgov3gKghBwDGPQYM5azk74yetwG97MI/QFDvhguZbmRJjYQXaUpYXqRreRxmlQRAZBz1fmmYFI3EAtiyZMjtx4tcFoY8G2RhyNLATr5FrpZGs5qNn6wlV92RjZg64iIGj0digK7EhIjZKStTWcMABqMg+3aOAmjacXLTBrrPrgIs1pBfiXwAFVYyzndq7bSDIuTgom+lYR1mQyRYKs5gFkxBE3E6KuR/Jbnuj1S2g3SL7ySDFRpBNmKeK/YQ0mf2D6+esEQ49f7ISzosYMhghBza2U1zNMsKARDzRF0UMvuEtyPghk5iGUGSLC0HnPPs9yRzkqpNL+MAO9RvR+Tad7/3tDp1/dDu4wAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;controller&apos; title=&apos;&apos; src=&apos;/static/973bade2cc88db04fb1f5d4a34dbe769/ca1dc/controller.png&apos; srcset=&apos;/static/973bade2cc88db04fb1f5d4a34dbe769/e7570/controller.png 170w,
/static/973bade2cc88db04fb1f5d4a34dbe769/f46e7/controller.png 340w,
/static/973bade2cc88db04fb1f5d4a34dbe769/ca1dc/controller.png 680w,
/static/973bade2cc88db04fb1f5d4a34dbe769/00706/controller.png 862w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;자원-제어의-동작-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9E%90%EC%9B%90-%EC%A0%9C%EC%96%B4%EC%9D%98-%EB%8F%99%EC%9E%91-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;자원 제어의 동작 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;자원 제어의 동작 방식&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;systemd-설정이-cgroup으로-반영되는-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemd-%EC%84%A4%EC%A0%95%EC%9D%B4-cgroup%EC%9C%BC%EB%A1%9C-%EB%B0%98%EC%98%81%EB%90%98%EB%8A%94-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;systemd 설정이 cgroup으로 반영되는 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemd 설정이 cgroup으로 반영되는 방식&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;운영자는 보통 cgroup 파일을 직접 수정하기보다, &lt;strong&gt;systemd 설정을 통해 자원 정책을 적용&lt;/strong&gt;한다.&lt;/p&gt;
&lt;p&gt;예를 들어 &lt;strong&gt;unit file&lt;/strong&gt;에 다음과 같이 설정할 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ini&quot;&gt;&lt;pre class=&quot;language-ini&quot;&gt;&lt;code class=&quot;language-ini&quot;&gt;&lt;span class=&quot;token section&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token section-name selector&quot;&gt;Service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;CPUQuota&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;20%&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;MemoryMax&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;512M&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 설정은 내부적으로 cgroup 관련 값으로 반영된다.&lt;/p&gt;
&lt;p&gt;예를 들어 다음과 같은 controller 파일과 연결된다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;cpu.max&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;memory.max&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;운영자가 &lt;strong&gt;unit file&lt;/strong&gt;을 통해 자원 정책을 설정하면&lt;br&gt;
&lt;strong&gt;systemd&lt;/strong&gt;가 &lt;strong&gt;controller 파일&lt;/strong&gt;에 매핑하여 구현한다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;실행-중-자원-정책-변경&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%A4%ED%96%89-%EC%A4%91-%EC%9E%90%EC%9B%90-%EC%A0%95%EC%B1%85-%EB%B3%80%EA%B2%BD&quot; aria-label=&quot;실행 중 자원 정책 변경 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;실행 중 자원 정책 변경&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;cgroup 기반 자원 정책은 실행 중에도 변경할 수 있다.
다음 두가지 방식으로 자원 정책을 변경할 수 있다.&lt;/p&gt;
&lt;h4 id=&quot;1-systemd-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-systemd-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;1 systemd 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. systemd 방식&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl set-property nginx.service &lt;span class=&quot;token assign-left variable&quot;&gt;CPUQuota&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;30&lt;/span&gt;%&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 명령은 서비스 재시작 없이 자원 정책을 즉시 적용한다.&lt;/p&gt;
&lt;h4 id=&quot;2-low-level&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-low-level&quot; aria-label=&quot;2 low level permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. low-level&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;30000 100000&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; cpu.max&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이처럼 group 파일을 직접 수정할 수도 있다.&lt;br&gt;
다만 실제 운영에서는 직접 파일을 수정하기보다, systemd를 통해 관리하는 것이 더 안전하고 일관적이다.&lt;/p&gt;
&lt;br&gt;
&lt;h2 id=&quot;정리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A0%95%EB%A6%AC&quot; aria-label=&quot;정리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;정리&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;리눅스에서 자원 관리는 프로세스 그룹 단위로 이루어진다.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;cgroup&lt;/strong&gt;은 프로세스를 그룹 단위로 묶어 자원을 제어하는 커널 기능이다.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;systemd&lt;/strong&gt;는 서비스를 실행할 때 해당 서비스용 cgroup을 만들고 자원 정책을 적용한다.&lt;/li&gt;
&lt;li&gt;cgroup 디렉터리의 &lt;strong&gt;controller&lt;/strong&gt; 파일들을 통해 실제 제한과 사용량 확인이 이루어진다.&lt;/li&gt;
&lt;li&gt;운영자가 &lt;strong&gt;unit file&lt;/strong&gt;을 통해 자원 정책을 설정하면 &lt;strong&gt;systemd&lt;/strong&gt;가 &lt;strong&gt;controller 파일&lt;/strong&gt;에 매핑하여 구현한다.&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[리눅스 작업 스케줄링: cron, at]]></title><description><![CDATA[…]]></description><link>https://jiu-jung.github.io/rhel-job-scheduling/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-job-scheduling/</guid><pubDate>Wed, 01 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;서버 운영을 하다 보면 반드시 &lt;strong&gt;정해진 시점에 실행해야 하는 작업&lt;/strong&gt;이 생긴다.&lt;br&gt;
예를 들어 백업, 로그 정리, 임시 파일 삭제, 리포트 생성, 배치 실행 같은 작업은&lt;br&gt;
사람이 매번 수동으로 처리하기 어렵다.&lt;/p&gt;
&lt;p&gt;그래서 운영에서는 &lt;strong&gt;작업을 자동으로 예약하고 실행하는 도구&lt;/strong&gt;가 필요하다.&lt;/p&gt;
&lt;p&gt;이 글에서는 리눅스 작업 스케줄링에 대해 다음 흐름으로 정리한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-job-scheduling/#cron-%EC%A3%BC%EA%B8%B0-%EC%9E%91%EC%97%85-%EC%8A%A4%EC%BC%80%EC%A4%84%EB%9F%AC&quot;&gt;&lt;strong&gt;cron&lt;/strong&gt;: 주기 작업 스케줄러&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-job-scheduling/#at-%EB%8B%A8%EB%B0%9C%EC%84%B1-%EC%9E%91%EC%97%85-%EC%8A%A4%EC%BC%80%EC%A4%84%EB%9F%AC&quot;&gt;&lt;strong&gt;at&lt;/strong&gt;: 단발성 작업 스케줄러&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-job-scheduling/#systemd-%ED%99%98%EA%B2%BD%EC%9D%98-%EC%9E%91%EC%97%85-%EC%8A%A4%EC%BC%80%EC%A4%84%EB%A7%81&quot;&gt;&lt;strong&gt;systemd&lt;/strong&gt; 환경의 작업 스케줄링&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h2 id=&quot;cron-주기-작업-스케줄러&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#cron-%EC%A3%BC%EA%B8%B0-%EC%9E%91%EC%97%85-%EC%8A%A4%EC%BC%80%EC%A4%84%EB%9F%AC&quot; aria-label=&quot;cron 주기 작업 스케줄러 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;cron: 주기 작업 스케줄러&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;1-개념&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-%EA%B0%9C%EB%85%90&quot; aria-label=&quot;1 개념 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. 개념&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;cron&lt;/code&gt;은 리눅스에서 가장 대표적인 &lt;strong&gt;주기적 작업 스케줄러&lt;/strong&gt;다.&lt;br&gt;
정해진 시간이나 주기에 따라 작업을 반복 실행할 때 사용한다.&lt;/p&gt;
&lt;p&gt;예를 들어 다음과 같은 작업이 &lt;code class=&quot;language-text&quot;&gt;cron&lt;/code&gt;의 대상이 된다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;매일 새벽 백업 실행&lt;/li&gt;
&lt;li&gt;일정 주기 로그 정리&lt;/li&gt;
&lt;li&gt;캐시 / 임시 파일 삭제&lt;/li&gt;
&lt;li&gt;주기적 배치 작업 실행&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;즉 &lt;code class=&quot;language-text&quot;&gt;cron&lt;/code&gt;은 &lt;strong&gt;반복되는 운영 작업을 자동화하는 기본 도구&lt;/strong&gt;라고 볼 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;2-동작-구조&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-%EB%8F%99%EC%9E%91-%EA%B5%AC%EC%A1%B0&quot; aria-label=&quot;2 동작 구조 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. 동작 구조&lt;/h3&gt;
&lt;h4 id=&quot;구성-요소&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B5%AC%EC%84%B1-%EC%9A%94%EC%86%8C&quot; aria-label=&quot;구성 요소 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;구성 요소&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;작업 정의: &lt;code class=&quot;language-text&quot;&gt;crontab&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;실행 주체: &lt;code class=&quot;language-text&quot;&gt;crond&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;서비스 관리: &lt;code class=&quot;language-text&quot;&gt;systemd&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;실행-흐름&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%A4%ED%96%89-%ED%9D%90%EB%A6%84&quot; aria-label=&quot;실행 흐름 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;실행 흐름&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;사용자는 &lt;code class=&quot;language-text&quot;&gt;crontab&lt;/code&gt;에 실행 규칙을 등록한다.&lt;/li&gt;
&lt;li&gt;실제 실행은 백그라운드 데몬인 &lt;code class=&quot;language-text&quot;&gt;crond&lt;/code&gt;가 수행한다.&lt;/li&gt;
&lt;li&gt;데몬은 &lt;code class=&quot;language-text&quot;&gt;systemd&lt;/code&gt;가 서비스 단위로 관리한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;3-운영-시-주의사항&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-%EC%9A%B4%EC%98%81-%EC%8B%9C-%EC%A3%BC%EC%9D%98%EC%82%AC%ED%95%AD&quot; aria-label=&quot;3 운영 시 주의사항 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3. 운영 시 주의사항&lt;/h3&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;cron&lt;/code&gt;은 &lt;strong&gt;조용히 실패(silent failure)&lt;/strong&gt; 할 수 있다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;대표적인 원인은 다음과 같다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;환경 변수 미설정 (&lt;code class=&quot;language-text&quot;&gt;PATH&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;권한 문제&lt;/li&gt;
&lt;li&gt;스크립트 내부 에러&lt;/li&gt;
&lt;li&gt;표준 출력 / 에러 출력이 별도로 수집되지 않음&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;예를 들어 &lt;strong&gt;터미널에서는 잘 실행되던 스크립트가, cron에서는 실패하는 경우&lt;/strong&gt;가 자주 있다.&lt;br&gt;
이는 cron이 로그인 셸과 다른 환경에서 실행되기 때문이다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;그래서 운영 환경에서는 단순히 작업을 등록하는 것보다, &lt;strong&gt;실패를 확인할 수 있게&lt;/strong&gt; 만드는 것이 더 중요하다.&lt;/p&gt;
&lt;p&gt;따라서 실무에서는 반드시 다음을 고려해야 한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;로그 파일로 출력 리다이렉션&lt;/li&gt;
&lt;li&gt;에러 출력 포함 (&lt;code class=&quot;language-text&quot;&gt;2&gt;&amp;amp;1&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;모니터링 연계&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;4-crontab-기본-명령어&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-crontab-%EA%B8%B0%EB%B3%B8-%EB%AA%85%EB%A0%B9%EC%96%B4&quot; aria-label=&quot;4 crontab 기본 명령어 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;4. crontab 기본 명령어&lt;/h3&gt;
&lt;br&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# 현재 등록된 작업 확인&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;crontab&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 작업 편집&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;crontab&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-e&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;5-crontab-포맷&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#5-crontab-%ED%8F%AC%EB%A7%B7&quot; aria-label=&quot;5 crontab 포맷 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;5. crontab 포맷&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;cron&lt;/code&gt;은 다음 5개의 시간 필드로 실행 시점을 지정한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;* * * * * command
│ │ │ │ │
│ │ │ │ └ 요일 (0-7, 일요일=0 또는 7)
│ │ │ └ 월 (1-12)
│ │ └ 일 (1-31)
│ └ 시 (0-23)
└ 분 (0-59)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;6-crontab-사용-예시&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#6-crontab-%EC%82%AC%EC%9A%A9-%EC%98%88%EC%8B%9C&quot; aria-label=&quot;6 crontab 사용 예시 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;6. crontab 사용 예시&lt;/h3&gt;
&lt;br&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt; * * * /opt/myapp/backup.sh &lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; /var/log/myapp-backup.log &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 설정은 다음 의미를 가진다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;매일 새벽 3시 실행&lt;/li&gt;
&lt;li&gt;표준 출력 + 에러 로그를 파일에 기록&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;실행뿐 아니라 실패 여부를 나중에 추적할 수 있도록 로그까지 함께 남기는 형태다.&lt;/p&gt;
&lt;br&gt;
&lt;h2 id=&quot;at-단발성-작업-스케줄러&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#at-%EB%8B%A8%EB%B0%9C%EC%84%B1-%EC%9E%91%EC%97%85-%EC%8A%A4%EC%BC%80%EC%A4%84%EB%9F%AC&quot; aria-label=&quot;at 단발성 작업 스케줄러 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;at: 단발성 작업 스케줄러&lt;/h2&gt;
&lt;hr&gt;
&lt;h3 id=&quot;1-개념-1&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-%EA%B0%9C%EB%85%90-1&quot; aria-label=&quot;1 개념 1 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. 개념&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;at&lt;/code&gt;은 &lt;strong&gt;한 번만 실행되는 작업&lt;/strong&gt; 을 예약할 때 사용한다.&lt;/p&gt;
&lt;p&gt;예를 들어 점검 종료 후 새벽 2시에 스크립트를 한 번 실행하거나,&lt;br&gt;
일정 시각에 일회성 후처리 작업을 예약할 때 사용할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;2-at-사용-예시&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-at-%EC%82%AC%EC%9A%A9-%EC%98%88%EC%8B%9C&quot; aria-label=&quot;2 at 사용 예시 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. at 사용 예시&lt;/h3&gt;
&lt;br&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;at 02:00
&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; /opt/myapp/run-once-job.sh
&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; Ctrl+D&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;위 예시는 지정한 시각에 스크립트를 한 번 실행하도록 예약하는 방식이다.&lt;/p&gt;
&lt;p&gt;명령 입력을 마친 뒤 &lt;code class=&quot;language-text&quot;&gt;Ctrl + D&lt;/code&gt;를 누르면 작업이 등록된다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;3-at-주요-명령어&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-at-%EC%A3%BC%EC%9A%94-%EB%AA%85%EB%A0%B9%EC%96%B4&quot; aria-label=&quot;3 at 주요 명령어 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3. at 주요 명령어&lt;/h3&gt;
&lt;br&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# 예약 목록 확인&lt;/span&gt;
atq

&lt;span class=&quot;token comment&quot;&gt;# 작업 삭제&lt;/span&gt;
atrm &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;job_id&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;4-동작-구조&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-%EB%8F%99%EC%9E%91-%EA%B5%AC%EC%A1%B0&quot; aria-label=&quot;4 동작 구조 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;4. 동작 구조&lt;/h3&gt;
&lt;h4 id=&quot;구성-요소-1&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B5%AC%EC%84%B1-%EC%9A%94%EC%86%8C-1&quot; aria-label=&quot;구성 요소 1 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;구성 요소&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;작업 등록: &lt;code class=&quot;language-text&quot;&gt;at&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;실행 주체: &lt;code class=&quot;language-text&quot;&gt;atd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;서비스 관리: &lt;code class=&quot;language-text&quot;&gt;systemd&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;실행-흐름-1&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%A4%ED%96%89-%ED%9D%90%EB%A6%84-1&quot; aria-label=&quot;실행 흐름 1 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;실행 흐름&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;사용자는 &lt;code class=&quot;language-text&quot;&gt;at&lt;/code&gt; 명령으로 실행 규칙을 등록한다.&lt;/li&gt;
&lt;li&gt;실제 실행은 백그라운드 데몬인 &lt;code class=&quot;language-text&quot;&gt;atd&lt;/code&gt;가 수행한다.&lt;/li&gt;
&lt;li&gt;데몬은 &lt;code class=&quot;language-text&quot;&gt;systemd&lt;/code&gt;가 서비스 단위로 관리한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;*구조는 cron과 비슷하지만, 반복 실행이 아니라 1회 실행이라는 점이 다르다.&lt;/p&gt;
&lt;br&gt;
&lt;h2 id=&quot;systemd-환경의-작업-스케줄링&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemd-%ED%99%98%EA%B2%BD%EC%9D%98-%EC%9E%91%EC%97%85-%EC%8A%A4%EC%BC%80%EC%A4%84%EB%A7%81&quot; aria-label=&quot;systemd 환경의 작업 스케줄링 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemd 환경의 작업 스케줄링&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;p&gt;지금까지의 내용을 &lt;code class=&quot;language-text&quot;&gt;systemd&lt;/code&gt; 관점에서 정리하면,&lt;br&gt;
리눅스 작업 스케줄링 구조는 다음처럼 볼 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;구성 요소&lt;/th&gt;
&lt;th&gt;역할&lt;/th&gt;
&lt;th&gt;systemd 관계&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;cron&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;반복 작업 스케줄링&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;crond.service&lt;/code&gt;로 관리&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;at&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;단발성 작업 스케줄링&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;atd.service&lt;/code&gt;로 관리&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;systemd&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;스케줄러 데몬의 실행·상태 관리&lt;/td&gt;
&lt;td&gt;상위 관리 주체&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;사용자는 &lt;code class=&quot;language-text&quot;&gt;cron&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;at&lt;/code&gt;으로 언제 작업을 실행할지 정의하고,&lt;br&gt;
&lt;code class=&quot;language-text&quot;&gt;systemd&lt;/code&gt;는 그 규칙을 수행하는 데몬의 실행과 상태를 관리한다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;참고-대안-systemd-timer&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0-%EB%8C%80%EC%95%88-systemd-timer&quot; aria-label=&quot;참고 대안 systemd timer permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;(참고) 대안: systemd timer&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;systemd 환경에서는 cron 대신 &lt;strong&gt;systemd timer&lt;/strong&gt;를 사용하는 방식도 존재한다.&lt;/p&gt;
&lt;p&gt;보통 &lt;code class=&quot;language-text&quot;&gt;.service&lt;/code&gt;와 &lt;code class=&quot;language-text&quot;&gt;.timer&lt;/code&gt;를 조합해서 사용하며,&lt;br&gt;
systemd 체계 안에서 더 일관되게 관리할 수 있다는 장점이 있다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;주요 특징&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;.service&lt;/code&gt; + &lt;code class=&quot;language-text&quot;&gt;.timer&lt;/code&gt; 조합&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;journal&lt;/code&gt;과 연계된 로그 확인&lt;/li&gt;
&lt;li&gt;의존성 및 실행 순서 관리 가능&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;하지만 다음의 이유로 &lt;strong&gt;실무에서는 여전히 cron이 많이 사용&lt;/strong&gt;된다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;기존 시스템과의 호환성&lt;/li&gt;
&lt;li&gt;단순 작업에 대한 직관성&lt;/li&gt;
&lt;li&gt;빠르게 등록하고 확인하기 쉬운 사용성&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h2 id=&quot;정리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A0%95%EB%A6%AC&quot; aria-label=&quot;정리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;정리&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;cron&lt;/code&gt;은 반복 작업 스케줄링 도구&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;at&lt;/code&gt;은 1회성 작업 스케줄링 도구&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;crond&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;atd&lt;/code&gt;는 각각 &lt;code class=&quot;language-text&quot;&gt;systemd&lt;/code&gt;가 관리하는 서비스&lt;/li&gt;
&lt;li&gt;운영에서는 작업 등록 자체보다 실패를 확인할 수 있는 로그와 실행 결과 관리가 더 중요하다&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[리눅스 프로세스: 구조부터 제어까지]]></title><description><![CDATA[리눅스에서 실행되는 모든 프로그램은 프로세스 단위로 관리된다. 프로세스는 PID…]]></description><link>https://jiu-jung.github.io/rhel-process/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-process/</guid><pubDate>Wed, 01 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;리눅스에서 실행되는 모든 프로그램은 &lt;strong&gt;프로세스&lt;/strong&gt; 단위로 관리된다.&lt;/p&gt;
&lt;p&gt;프로세스는 &lt;strong&gt;PID, 부모-자식 관계, 실행 상태, 자원 사용 정보&lt;/strong&gt;등을 가지며,&lt;br&gt;
운영체제는 이를 기준으로 프로그램의 실행을 추적하고 제어한다.&lt;/p&gt;
&lt;p&gt;이 글에서는 리눅스 프로세스가 어떤 구조로 동작하고 관리되는지 다음 순서로 정리한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-process/#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%9D%98-%EC%8B%9C%EC%9E%91-PID-1&quot;&gt;프로세스의 시작: &lt;strong&gt;PID 1&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-process/#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%9D%98-%EA%B5%AC%EC%A1%B0-%EA%B3%84%EC%B8%B5%EC%A0%81-%ED%8A%B8%EB%A6%AC&quot;&gt;프로세스의 구조: 계층적 트리&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-process/#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%9D%98-%EC%83%9D%EC%84%B1%EA%B3%BC-%EC%8B%A4%ED%96%89&quot;&gt;프로세스의 생성과 실행: fork, exec&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-process/#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%EA%B4%80%EC%B0%B0-%EB%B0%8F-%EC%A0%9C%EC%96%B4-%EB%AA%85%EB%A0%B9%EC%96%B4&quot;&gt;프로세스 관찰 및 제어: ps, top, kill, nice&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h2 id=&quot;프로세스의-시작-PID-1&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%9D%98-%EC%8B%9C%EC%9E%91-PID-1&quot; aria-label=&quot;프로세스의 시작 PID 1 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;프로세스의 시작: PID 1&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;p&gt;리눅스에서 사용자 공간의 모든 프로세스는&lt;br&gt;
부팅 직후 커널이 실행한 &lt;strong&gt;첫 번째 프로세스&lt;/strong&gt;에서 출발한다.&lt;br&gt;
이 첫 프로세스가 바로 &lt;strong&gt;PID 1&lt;/strong&gt; 이다.&lt;/p&gt;
&lt;p&gt;커널은 사용자 프로그램을 하나씩 직접 실행하지 않는다.&lt;br&gt;
대신 사용자 공간의 시작점이 되는 프로세스 하나를 먼저 실행하고,&lt;br&gt;
이후의 서비스와 세션 관리는 그 프로세스가 맡는다.&lt;/p&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;커널은 직접 모든 사용자 프로그램을 실행하지 않고,&lt;br&gt;
사용자 공간의 시작점이 되는 &lt;strong&gt;PID 1&lt;/strong&gt; 을 먼저 실행한다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;부팅-이후-실행-흐름&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B6%80%ED%8C%85-%EC%9D%B4%ED%9B%84-%EC%8B%A4%ED%96%89-%ED%9D%90%EB%A6%84&quot; aria-label=&quot;부팅 이후 실행 흐름 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;부팅 이후 실행 흐름&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;부팅 직후 실행 흐름은 다음과 같다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;펌웨어(BIOS/UEFI)&lt;/strong&gt; 가 하드웨어를 초기화&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;부트로더(GRUB 등)&lt;/strong&gt; 가 리눅스 커널을 메모리에 적재&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;커널(kernel)&lt;/strong&gt; 이 메모리, CPU, 장치 드라이버, 파일시스템 등을 초기화&lt;/li&gt;
&lt;li&gt;커널이 사용자 공간의 첫 프로세스인 &lt;strong&gt;PID 1&lt;/strong&gt; 을 실행&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PID 1&lt;/strong&gt; 이 이후 서비스와 세션을 시작&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;즉, 사용자 공간은 커널이 실행한 &lt;strong&gt;PID 1&lt;/strong&gt; 에서부터 시작된다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;PID-1의-역할&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#PID-1%EC%9D%98-%EC%97%AD%ED%95%A0&quot; aria-label=&quot;PID 1의 역할 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;PID 1의 역할&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;PID 1은 이후 사용자 공간 전체의 기준점이 된다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;모든 사용자 공간 프로세스의 &lt;strong&gt;최상위 부모&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;서비스 시작 및 관리&lt;/li&gt;
&lt;li&gt;orphan 프로세스 수용&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;init과-systemd&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#init%EA%B3%BC-systemd&quot; aria-label=&quot;init과 systemd permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;init과 systemd&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;이러한 &lt;strong&gt;PID 1 역할&lt;/strong&gt;을 전통적으로는 &lt;strong&gt;init&lt;/strong&gt; 이 맡았고, 현대 리눅스에서는 대부분 &lt;strong&gt;systemd&lt;/strong&gt; 가 맡는다.&lt;br&gt;
둘 다 사용자 공간의 첫 프로세스라는 점은 같지만, &lt;strong&gt;시스템을 관리하는 방식에는 차이&lt;/strong&gt;가 있다.&lt;/p&gt;
&lt;h4 id=&quot;왜-init에서-systemd로-넘어갔을까&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-init%EC%97%90%EC%84%9C-systemd%EB%A1%9C-%EB%84%98%EC%96%B4%EA%B0%94%EC%9D%84%EA%B9%8C&quot; aria-label=&quot;왜 init에서 systemd로 넘어갔을까 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 init에서 systemd로 넘어갔을까?&lt;/h4&gt;
&lt;br&gt;
&lt;p&gt;전통적인 init은 현대 시스템을 운영하기에는 몇 가지 한계가 있었다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;서비스들을 &lt;strong&gt;순차적으로 실행&lt;/strong&gt;해서 부팅이 느릴 수 있음&lt;/li&gt;
&lt;li&gt;서비스 간 &lt;strong&gt;의존성 관리&lt;/strong&gt;가 어려움&lt;/li&gt;
&lt;li&gt;로그, 타이머, 소켓 같은 운영 기능이 분리되어 있음&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;반면 systemd는 이런 한계를 보완하면서, 현대 리눅스 운영 환경에 맞는 기능을 함께 제공한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;의존성 기반 실행&lt;/li&gt;
&lt;li&gt;병렬 부팅&lt;/li&gt;
&lt;li&gt;서비스/로그/타이머의 통합 관리&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;init&lt;/strong&gt;은 서비스를 &lt;strong&gt;순서대로 띄우는 시작점&lt;/strong&gt;에 가까웠다면&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;systemd&lt;/strong&gt;는 서비스들을 &lt;strong&gt;관계 기반으로 관리하는 운영 체계&lt;/strong&gt;에 가깝다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;프로세스의-구조-계층적-트리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%9D%98-%EA%B5%AC%EC%A1%B0-%EA%B3%84%EC%B8%B5%EC%A0%81-%ED%8A%B8%EB%A6%AC&quot; aria-label=&quot;프로세스의 구조 계층적 트리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;프로세스의 구조: 계층적 트리&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;p&gt;PID 1 이후에 만들어지는 프로세스들은&lt;br&gt;
서로 독립적으로 존재하는 것이 아니라, &lt;strong&gt;부모-자식 관계를 가지는 트리 구조&lt;/strong&gt;를 이룬다.&lt;/p&gt;
&lt;p&gt;그래서 프로세스를 이해할 때는&lt;br&gt;
무엇이 실행 중인지만 보는 것이 아니라, &lt;strong&gt;누가 누구를 생성했는가&lt;/strong&gt;까지 함께 봐야 한다.&lt;/p&gt;
&lt;p&gt;이 구조를 이해하면 다음과 같은 점에서 도움이 된다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;어떤 프로세스가 &lt;strong&gt;누가 만든 것인지&lt;/strong&gt;를 통해 동작 흐름을 이해할 수 있다&lt;/li&gt;
&lt;li&gt;장애 분석 시 &lt;strong&gt;원인을 추적&lt;/strong&gt;하기 쉽다&lt;/li&gt;
&lt;li&gt;종료나 재시작 시 &lt;strong&gt;영향 범위&lt;/strong&gt;를 판단할 수 있다&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;트리-구조의-특징&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%8A%B8%EB%A6%AC-%EA%B5%AC%EC%A1%B0%EC%9D%98-%ED%8A%B9%EC%A7%95&quot; aria-label=&quot;트리 구조의 특징 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;트리 구조의 특징&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;프로세스 트리는 몇 가지 기본 특징을 가진다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;모든 프로세스는 고유한 &lt;strong&gt;PID&lt;/strong&gt; 를 가진다&lt;/li&gt;
&lt;li&gt;대부분의 프로세스는 자신을 만든 부모의 &lt;strong&gt;PPID(Parent PID)&lt;/strong&gt; 를 가진다&lt;/li&gt;
&lt;li&gt;새로운 프로세스는 기존 프로세스가 생성한다&lt;/li&gt;
&lt;li&gt;사용자 공간 프로세스 트리의 최상위 기준점은 &lt;strong&gt;PID 1(systemd)&lt;/strong&gt; 이다&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;프로세스의-상속&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%9D%98-%EC%83%81%EC%86%8D&quot; aria-label=&quot;프로세스의 상속 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;프로세스의 상속&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;자식 프로세스는 부모가 가진 실행 문맥 일부를 이어받은 상태에서 시작한다.&lt;/p&gt;
&lt;p&gt;대표적으로 다음과 같은 것들이 상속된다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;환경 변수&lt;/li&gt;
&lt;li&gt;현재 작업 디렉터리&lt;/li&gt;
&lt;li&gt;파일 디스크립터&lt;/li&gt;
&lt;li&gt;사용자 및 권한 정보&lt;/li&gt;
&lt;li&gt;일부 리소스 제한값&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이런 상속 구조 덕분에, 셸에서 환경 변수를 &lt;code class=&quot;language-text&quot;&gt;export&lt;/code&gt; 한 뒤 명령어를 실행하면&lt;br&gt;
그 명령어가 실행된 프로세스도 같은 환경을 사용할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;orphan과-zombie-프로세스&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#orphan%EA%B3%BC-zombie-%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4&quot; aria-label=&quot;orphan과 zombie 프로세스 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;orphan과 zombie 프로세스&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;프로세스 트리에는 일반적인 부모-자식 관계만 있는 것이 아니라,&lt;br&gt;
운영 중 자주 언급되는 예외적인 상태도 있다.&lt;/p&gt;
&lt;h4 id=&quot;orphan-process&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#orphan-process&quot; aria-label=&quot;orphan process permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;orphan process&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;부모 프로세스가 먼저 종료되어 고아가 된 자식 프로세스&lt;/li&gt;
&lt;li&gt;자식 프로세스는 보통 PID 1(&lt;code class=&quot;language-text&quot;&gt;systemd&lt;/code&gt;)가 수용한다&lt;/li&gt;
&lt;li&gt;부모가 종료되었다고 해서 자식이 즉시 함께 종료되지는 않는다&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;zombie-process&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#zombie-process&quot; aria-label=&quot;zombie process permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;zombie process&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;자식 프로세스는 이미 종료되었지만, 부모가 종료 상태를 아직 회수하지 않아&lt;br&gt;
프로세스 테이블에 남아 있는 상태&lt;/li&gt;
&lt;li&gt;실제로 실행 중인 것은 아니며, 부모가 &lt;code class=&quot;language-text&quot;&gt;wait()&lt;/code&gt; 계열 호출로 상태를 회수하면 정리된다&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;orphan은 &lt;strong&gt;살아 있는 자식이 부모를 잃은 상태&lt;/strong&gt;이고,&lt;br&gt;
zombie는 &lt;strong&gt;이미 종료된 자식의 상태 정보가 아직 회수되지 않은 상태&lt;/strong&gt;다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;프로세스의-생성과-실행&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%9D%98-%EC%83%9D%EC%84%B1%EA%B3%BC-%EC%8B%A4%ED%96%89&quot; aria-label=&quot;프로세스의 생성과 실행 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;프로세스의 생성과 실행&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;p&gt;프로세스 트리는 기존 프로세스가 새로운 프로세스를 만들면서 형성된다.&lt;/p&gt;
&lt;p&gt;리눅스에서는 이 과정을 보통 &lt;code class=&quot;language-text&quot;&gt;fork()&lt;/code&gt; 와 &lt;code class=&quot;language-text&quot;&gt;exec()&lt;/code&gt;로 설명한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;fork()&lt;/code&gt;&lt;/strong&gt;: 새 프로세스를 만든다&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;exec()&lt;/code&gt;&lt;/strong&gt;: 현재 프로세스를 다른 프로그램으로 바꾼다&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;리눅스에서 프로그램 실행은&lt;br&gt;
&lt;strong&gt;프로세스 생성(&lt;code class=&quot;language-text&quot;&gt;fork&lt;/code&gt;)&lt;/strong&gt; 과 &lt;strong&gt;프로그램 교체(&lt;code class=&quot;language-text&quot;&gt;exec&lt;/code&gt;)&lt;/strong&gt; 가 이어지는 구조로 이해할 수 있다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;fork-프로세스-생성&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#fork-%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%EC%83%9D%EC%84%B1&quot; aria-label=&quot;fork 프로세스 생성 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;fork(): 프로세스 생성&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;fork()&lt;/code&gt; 는 현재 프로세스를 복제하여 &lt;strong&gt;자식 프로세스&lt;/strong&gt;를 만든다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;pid &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fork&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;fork()&lt;/code&gt; 가 호출되면, 부모와 자식은 거의 동일한 실행 문맥을 가진 상태에서 각각 실행을 이어간다.&lt;/p&gt;
&lt;p&gt;반환값은 다음과 같다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;부모 프로세스: 자식의 PID 반환&lt;/li&gt;
&lt;li&gt;자식 프로세스: &lt;code class=&quot;language-text&quot;&gt;0&lt;/code&gt; 반환&lt;/li&gt;
&lt;li&gt;실패 시: &lt;code class=&quot;language-text&quot;&gt;-1&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;부모와 자식은 같은 코드에서 시작하지만, &lt;strong&gt;반환값이 다르기 때문에 이후 서로 다른 동작으로 분기&lt;/strong&gt;할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;exec-프로그램-교체&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#exec-%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%A8-%EA%B5%90%EC%B2%B4&quot; aria-label=&quot;exec 프로그램 교체 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;exec(): 프로그램 교체&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;exec()&lt;/code&gt; 계열 함수는 현재 프로세스의 메모리 공간을 &lt;strong&gt;새 프로그램으로 덮어쓴다&lt;/strong&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token function&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/bin/ls&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;exec()&lt;/code&gt; 는 새 프로세스를 만들지 않고, 이미 존재하는 프로세스를 &lt;strong&gt;다른 프로그램으로 교체&lt;/strong&gt;한다.&lt;/p&gt;
&lt;p&gt;따라서 다음의 특징이 있다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;기존 PID 유지&lt;/li&gt;
&lt;li&gt;기존 프로세스 자리에 새 프로그램이 올라감&lt;/li&gt;
&lt;li&gt;성공하면 원래 코드로 돌아오지 않음&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;왜-fork-와-exec-를-나눴을까&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-fork-%EC%99%80-exec-%EB%A5%BC-%EB%82%98%EB%88%B4%EC%9D%84%EA%B9%8C&quot; aria-label=&quot;왜 fork 와 exec 를 나눴을까 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 fork() 와 exec() 를 나눴을까&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;두 과정이 분리되어 있어서 &lt;strong&gt;프로세스를 실행하기 전에 필요한 준비&lt;/strong&gt;를 먼저 할 수 있다.&lt;/p&gt;
&lt;p&gt;예를 들면 자식 프로세스에서 &lt;code class=&quot;language-text&quot;&gt;exec()&lt;/code&gt; 전에 다음과 같은 작업이 가능하다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;표준 입력/출력 리다이렉션&lt;/li&gt;
&lt;li&gt;파일 디스크립터 정리&lt;/li&gt;
&lt;li&gt;환경 변수 설정&lt;/li&gt;
&lt;li&gt;권한 변경&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;즉 &lt;strong&gt;실행 환경을 먼저 준비한 뒤 원하는 프로그램으로 교체할 수 있기 때문에&lt;/strong&gt;&lt;br&gt;
&lt;code class=&quot;language-text&quot;&gt;fork()&lt;/code&gt; 와 &lt;code class=&quot;language-text&quot;&gt;exec()&lt;/code&gt; 가 나뉘어 있다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;Shell에서-명령어가-실행되는-흐름&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Shell%EC%97%90%EC%84%9C-%EB%AA%85%EB%A0%B9%EC%96%B4%EA%B0%80-%EC%8B%A4%ED%96%89%EB%90%98%EB%8A%94-%ED%9D%90%EB%A6%84&quot; aria-label=&quot;Shell에서 명령어가 실행되는 흐름 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Shell에서 명령어가 실행되는 흐름&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;터미널에서 &lt;code class=&quot;language-text&quot;&gt;ls&lt;/code&gt; 를 입력하면 개념적으로 다음과 같이 동작한다.&lt;br&gt;
&lt;em&gt;(실제 구현에서는 &lt;code class=&quot;language-text&quot;&gt;clone&lt;/code&gt;이나 &lt;code class=&quot;language-text&quot;&gt;posix_spawn&lt;/code&gt; 같은 최적화가 사용될 수 있다.)&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;bash → fork → exec(ls)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;bash&lt;/code&gt; 가 자식 프로세스를 하나 만든다&lt;/li&gt;
&lt;li&gt;자식 프로세스가 &lt;code class=&quot;language-text&quot;&gt;exec()&lt;/code&gt; 를 호출해 &lt;code class=&quot;language-text&quot;&gt;ls&lt;/code&gt; 프로그램으로 바뀐다&lt;/li&gt;
&lt;li&gt;부모 셸은 자식이 끝날 때까지 기다리거나, 상황에 따라 백그라운드로 넘긴다&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;프로세스-관찰-및-제어&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%EA%B4%80%EC%B0%B0-%EB%B0%8F-%EC%A0%9C%EC%96%B4&quot; aria-label=&quot;프로세스 관찰 및 제어 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;프로세스 관찰 및 제어&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;p&gt;이제 실행 중인 프로세스를 어떻게 확인하고, 상태를 바꾸고, 자원 사용을 조정할 것인지 알아보자.&lt;/p&gt;
&lt;p&gt;리눅스에서 프로세스 제어는 크게 세 가지로 나뉜다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;조회&lt;/strong&gt;: &lt;code class=&quot;language-text&quot;&gt;ps&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;top&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;상태 변경&lt;/strong&gt;: &lt;code class=&quot;language-text&quot;&gt;kill&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;자원 사용 제어(우선순위)&lt;/strong&gt;: &lt;code class=&quot;language-text&quot;&gt;nice&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;renice&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;ps-현재-프로세스-조회&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#ps-%ED%98%84%EC%9E%AC-%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%EC%A1%B0%ED%9A%8C&quot; aria-label=&quot;ps 현재 프로세스 조회 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;ps: 현재 프로세스 조회&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;*ps: process status의 약자&lt;/p&gt;
&lt;p&gt;현재 시점의 프로세스 상태를 &lt;strong&gt;정적인 스냅샷&lt;/strong&gt;으로 보여준다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;자주 쓰는 옵션&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;a&lt;/code&gt;: 다른 사용자 프로세스도 포함&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;u&lt;/code&gt;: 사용자 중심 포맷&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;x&lt;/code&gt;: 터미널 없는 프로세스도 포함&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;e&lt;/code&gt;: 환경 변수까지 함께 표시&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;f&lt;/code&gt;: 부모-자식 관계를 포함한 full format 표시&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;자주 쓰는 형태&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# 가장 많이 쓰이는 형태&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; aux

&lt;span class=&quot;token comment&quot;&gt;# 시스템 전체 프로세스를 계층/관계 중심으로 보기 좋다.&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ef&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 특정 PID만 조회&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;PID&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 프로세스 트리 형태로 보기  &lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-ef&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--forest&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;top-실시간-프로세스-모니터링&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#top-%EC%8B%A4%EC%8B%9C%EA%B0%84-%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81&quot; aria-label=&quot;top 실시간 프로세스 모니터링 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;top: 실시간 프로세스 모니터링&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;시스템의 CPU, 메모리, 로드 평균, 프로세스 상태를 &lt;strong&gt;실시간으로 갱신&lt;/strong&gt;해서 보여준다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;확인하는 것&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CPU 사용률&lt;/li&gt;
&lt;li&gt;메모리 사용량&lt;/li&gt;
&lt;li&gt;load average&lt;/li&gt;
&lt;li&gt;어떤 프로세스가 자원을 많이 먹는지&lt;/li&gt;
&lt;li&gt;프로세스 상태 (&lt;code class=&quot;language-text&quot;&gt;R&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;S&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;D&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Z&lt;/code&gt; 등)&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;자주 쓰는 형태&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# 특정 PID만 집중 모니터링&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;top&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;PID&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 특정 사용자의 프로세스만 보기&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;top&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 갱신 주기 지정&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;top&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;second&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 전체 커맨드라인 표시&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;top&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-c&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;실행 중 자주 쓰는 키&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;P&lt;/code&gt;: CPU 사용량 기준 정렬&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;M&lt;/code&gt;: 메모리 사용량 기준 정렬&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;k&lt;/code&gt;: 프로세스 종료 신호 보내기&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;r&lt;/code&gt;: nice 값 변경&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;1&lt;/code&gt;: CPU 코어별 보기&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;q&lt;/code&gt;: 종료&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;kill-프로세스에-제어-시그널-전달&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#kill-%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%97%90-%EC%A0%9C%EC%96%B4-%EC%8B%9C%EA%B7%B8%EB%84%90-%EC%A0%84%EB%8B%AC&quot; aria-label=&quot;kill 프로세스에 제어 시그널 전달 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;kill: 프로세스에 제어 시그널 전달&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;프로세스를 종료하는 명령어가 아니라, &lt;strong&gt;프로세스에 시그널을 보내는 명령어&lt;/strong&gt;다.&lt;br&gt;
종료뿐 아니라 재로드, 일시 정지, 재개 같은 제어에도 사용할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;자주 쓰는 형태&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# 기본 종료 요청 - SIGTERM(15)&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;kill&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;PID&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# SIGTERM 명시&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;kill&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-TERM&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;PID&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 재시작 없이 설정 재로드 용도로 자주 사용&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;kill&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-HUP&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;PID&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 시그널 목록 확인&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;kill&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;자주 쓰는 시그널&lt;/strong&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;시그널&lt;/th&gt;
&lt;th&gt;의미&lt;/th&gt;
&lt;th&gt;용도&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;SIGTERM (15)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;정상 종료 요청&lt;/td&gt;
&lt;td&gt;가장 먼저 시도&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;SIGKILL (9)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;강제 종료&lt;/td&gt;
&lt;td&gt;최후 수단&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;SIGINT (2)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;인터럽트&lt;/td&gt;
&lt;td&gt;Ctrl+C 유사&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;SIGHUP (1)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;hangup/reload&lt;/td&gt;
&lt;td&gt;설정 재적용 용도&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;SIGSTOP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;일시 정지&lt;/td&gt;
&lt;td&gt;즉시 멈춤&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;SIGCONT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;재개&lt;/td&gt;
&lt;td&gt;중단 후 다시 실행&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;운영 주의사항&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;무조건 &lt;code class=&quot;language-text&quot;&gt;kill -9&lt;/code&gt; 부터 쓰지 않는다&lt;/li&gt;
&lt;li&gt;먼저 &lt;code class=&quot;language-text&quot;&gt;SIGTERM&lt;/code&gt; 으로 정상 종료를 시도한다&lt;/li&gt;
&lt;li&gt;종료가 안 될 때만 &lt;code class=&quot;language-text&quot;&gt;SIGKILL&lt;/code&gt; 고려한다.&lt;/li&gt;
&lt;li&gt;서비스라면 &lt;code class=&quot;language-text&quot;&gt;kill&lt;/code&gt; 보다 &lt;code class=&quot;language-text&quot;&gt;systemctl stop/restart&lt;/code&gt; 가 우선이다&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;nice--renice-CPU-우선순위-조정&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#nice--renice-CPU-%EC%9A%B0%EC%84%A0%EC%88%9C%EC%9C%84-%EC%A1%B0%EC%A0%95&quot; aria-label=&quot;nice  renice CPU 우선순위 조정 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;nice / renice: CPU 우선순위 조정&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;리눅스 스케줄러는 모든 프로세스에 동일하게 CPU를 주지 않는다.&lt;br&gt;
각 프로세스는 우선순위를 가지며, 사용자는 &lt;code class=&quot;language-text&quot;&gt;nice&lt;/code&gt; 값을 통해 이를 조정할 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;기본 규칙&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;값 범위: &lt;strong&gt;-20 ~ 19&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;숫자가 &lt;strong&gt;낮을수록 우선순위 높음&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;숫자가 &lt;strong&gt;높을수록 우선순위 낮음&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;nice&lt;/code&gt;: 새 프로세스를 특정 우선순위로 시작&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;nice&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt; python app.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;renice&lt;/code&gt;: 이미 실행 중인 프로세스의 우선순위 변경&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;renice&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1234&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;nice와 renice는 프로세스를 종료하지 않고도&lt;br&gt;
CPU 경쟁에서의 상대적 우선순위를 조정할 수 있게 해준다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h2 id=&quot;정리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A0%95%EB%A6%AC&quot; aria-label=&quot;정리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;정리&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;모든 프로세스는 &lt;strong&gt;PID 1에서 시작된다&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;프로세스는 &lt;strong&gt;트리 구조로 연결된다&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;실행은 &lt;code class=&quot;language-text&quot;&gt;fork → exec&lt;/code&gt;으로 이루어진다&lt;/li&gt;
&lt;li&gt;운영자는 이를 &lt;strong&gt;조회(ps/top)하고 제어(kill/nice)&lt;/strong&gt; 한다&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[리눅스 서비스 관리: systemd, systemctl, unit file]]></title><description><![CDATA[…]]></description><link>https://jiu-jung.github.io/rhel-service/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-service/</guid><pubDate>Wed, 01 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;리눅스 운영 환경에서는 단순히 &lt;strong&gt;프로세스가 실행 중인가&lt;/strong&gt;만 보는 것으로는 충분하지 않다.&lt;br&gt;
실제로 운영에서는 &lt;strong&gt;서비스가 정상적으로 관리되고 있는가&lt;/strong&gt;를 기준으로 시스템을 바라보게 된다.&lt;/p&gt;
&lt;p&gt;예를 들어 어떤 프로그램이 죽었을 때,&lt;br&gt;
단순 프로세스라면 종료된 것으로 끝나지만 서비스로 관리되고 있다면 자동으로 다시 시작될 수 있다.&lt;br&gt;
또 부팅 시 자동 실행, 권한 분리, 환경 변수 주입, 로그 확인까지 모두 서비스 단위에서 관리된다.&lt;/p&gt;
&lt;p&gt;이 글에서는 리눅스 서비스 운영의 핵심 개념을 다음 순서로 정리한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-service/#%EC%84%9C%EB%B9%84%EC%8A%A4-%EB%A6%AC%EB%88%85%EC%8A%A4-%EC%9A%B4%EC%98%81%EC%9D%98-%EC%A4%91%EC%8B%AC&quot;&gt;&lt;strong&gt;서비스&lt;/strong&gt;: 리눅스 운영의 중심&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-service/#systemd-%EB%A6%AC%EB%88%85%EC%8A%A4-%EC%84%9C%EB%B9%84%EC%8A%A4-%EA%B4%80%EB%A6%AC%EC%9D%98-%EC%A4%91%EC%8B%AC&quot;&gt;&lt;strong&gt;systemd&lt;/strong&gt;: 서비스 관리의 중심&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-service/#systemctl-%EC%84%9C%EB%B9%84%EC%8A%A4-%EC%A0%9C%EC%96%B4-%EC%9D%B8%ED%84%B0%ED%8E%98%EC%9D%B4%EC%8A%A4&quot;&gt;&lt;strong&gt;systemctl&lt;/strong&gt;: 서비스 제어 인터페이스&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-service/#Unit-File-%EC%84%9C%EB%B9%84%EC%8A%A4-%EC%9A%B4%EC%98%81-%EC%A0%95%EC%B1%85-%EB%AC%B8%EC%84%9C&quot;&gt;&lt;strong&gt;unit file&lt;/strong&gt;: 서비스 운영 정책 문서&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h2 id=&quot;서비스-리눅스-운영의-중심&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%84%9C%EB%B9%84%EC%8A%A4-%EB%A6%AC%EB%88%85%EC%8A%A4-%EC%9A%B4%EC%98%81%EC%9D%98-%EC%A4%91%EC%8B%AC&quot; aria-label=&quot;서비스 리눅스 운영의 중심 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;서비스: 리눅스 운영의 중심&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;리눅스 운영은 프로세스가 아니라 서비스 단위로 제어한다.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;프로세스와-서비스는-무엇이-다를까&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%99%80-%EC%84%9C%EB%B9%84%EC%8A%A4%EB%8A%94-%EB%AC%B4%EC%97%87%EC%9D%B4-%EB%8B%A4%EB%A5%BC%EA%B9%8C&quot; aria-label=&quot;프로세스와 서비스는 무엇이 다를까 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;프로세스와 서비스는 무엇이 다를까&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;리눅스를 처음 배울 때는 보통 프로세스의 개념과 관리 방법을 먼저 배운다.&lt;br&gt;
운영 관점에서는 여기서 한 단계 더 나아가 &lt;strong&gt;서비스&lt;/strong&gt;라는 관리 단위를 이해해야 한다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;프로세스-vs-서비스&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-vs-%EC%84%9C%EB%B9%84%EC%8A%A4&quot; aria-label=&quot;프로세스 vs 서비스 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;프로세스 vs 서비스&lt;/h3&gt;
&lt;br&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;구분&lt;/th&gt;
&lt;th&gt;프로세스 (Process)&lt;/th&gt;
&lt;th&gt;서비스 (Service)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;정의&lt;/td&gt;
&lt;td&gt;실행 중인 프로그램&lt;/td&gt;
&lt;td&gt;운영 단위&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;생명주기&lt;/td&gt;
&lt;td&gt;죽으면 끝&lt;/td&gt;
&lt;td&gt;재시작 가능&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;관리 방식&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;kill&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;ps&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;systemctl&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;운영 관점&lt;/td&gt;
&lt;td&gt;개별 실행 단위&lt;/td&gt;
&lt;td&gt;정책 기반 관리 단위&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;프로세스는 &lt;strong&gt;실행 상태&lt;/strong&gt;이고,&lt;/li&gt;
&lt;li&gt;서비스는 &lt;strong&gt;운영 정책을 포함한 단위&lt;/strong&gt;이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;모든 서비스는 하나 이상의 프로세스를 포함한다.&lt;br&gt;
모든 프로세스가 서비스는 아니다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;서비스&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%84%9C%EB%B9%84%EC%8A%A4&quot; aria-label=&quot;서비스 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;서비스&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;따라서 서비스는 단순히 프로그램을 띄우는 개념이 아니다.&lt;/p&gt;
&lt;p&gt;보통 아래와 같은 운영 요소를 함께 포함한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;자동 재시작&lt;/li&gt;
&lt;li&gt;로그 관리&lt;/li&gt;
&lt;li&gt;부팅 시 자동 실행&lt;/li&gt;
&lt;li&gt;실행 계정 및 권한 설정&lt;/li&gt;
&lt;li&gt;환경 변수 주입&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;즉, 서비스는 리눅스에서&lt;br&gt;
&lt;strong&gt;프로세스를 더 안정적이고 일관되게 운영하기 위해 사용하는 관리 단위&lt;/strong&gt;라고 볼 수 있다.&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;systemd-리눅스-서비스-관리의-중심&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemd-%EB%A6%AC%EB%88%85%EC%8A%A4-%EC%84%9C%EB%B9%84%EC%8A%A4-%EA%B4%80%EB%A6%AC%EC%9D%98-%EC%A4%91%EC%8B%AC&quot; aria-label=&quot;systemd 리눅스 서비스 관리의 중심 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemd: 리눅스 서비스 관리의 중심&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;systemd&lt;/strong&gt;는 현대 리눅스 배포판에서 서비스 관리를 담당하는 표준 시스템이다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;systemd의-역할&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemd%EC%9D%98-%EC%97%AD%ED%95%A0&quot; aria-label=&quot;systemd의 역할 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemd의 역할&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;systemd는 시스템 전반의 실행 흐름을 관리하는 중심 역할을 맡는다.&lt;/p&gt;
&lt;p&gt;주요 역할은 다음과 같다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PID 1, &lt;strong&gt;시스템에서 가장 먼저 시작되는 프로세스&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;다른 프로세스들의 부모 프로세스&lt;/li&gt;
&lt;li&gt;서비스 실행 및 상태 관리&lt;/li&gt;
&lt;li&gt;부팅 과정 제어&lt;/li&gt;
&lt;li&gt;로그 관리 (&lt;code class=&quot;language-text&quot;&gt;journalctl&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;특히 PID 1이라는 점이 중요하다.&lt;br&gt;
리눅스에서 &lt;strong&gt;시스템이 부팅되면 가장 먼저 시작되는 프로세스가 systemd&lt;/strong&gt; 이고,&lt;br&gt;
이후 여러 서비스와 데몬이 이 흐름 아래에서 관리된다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;실제로 &lt;code class=&quot;language-text&quot;&gt;pstree&lt;/code&gt; 명령어를 쳐보면, 대부분의 프로세스의 부모 프로세스가 systemd 인것을 확인할 수 있다.&lt;/p&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/510859639ff9788b397279daa036857e/2876f/pstree.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 67.05882352941177%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAABYlAAAWJQFJUiTwAAABtElEQVR42pVTWVbDMBDjCtA9zebs+9qkaSnl/qcaRgPmNS3wHh+up44tayT5qWhG6o8XKtqR6n6ipGip6o5UcV00A1kqJi8qKMxqUlFOQVqRn5RS792QljtnNp4sL+EPEflxScN0pfH8TnHeUpBU5MUF2UEqoG6Qke0n5PgpqTDnOqWt5T0Cvmwsel6bchsYNYeTsMDBKGvkosXWlj16r66x/gC4Mlz5AKZZ1VMznMhUES34ADbgML4vtg6tDEXYvzK4vgP6BsQPDpjcVjuchWHDc14fZGQ8sF6yxjHrC/bLX8DmgKwjDMFhmBOmNetYskGTXAJAy4v/BJsBYnPNB4fTVUyBORE7i/YdNsRhc3a2/w9AbhksEBm06bEZmLvxVcxCrLQRt2bc1zMNs3oQ/brxIiyhIdqFBIfpTS5Z7xXHxRdzdA0MzBvTm7dctkcBRNjBCmx7BoKeisMNjREjhNzlLHpSN5LJMK8ltzPA7IYRGJYMiCyuOS737en/ek3XNxomoiFMgW6YAQ7dtHa6/hzmz8HWgHsnpLTohF359a7lLXPg4TLeLt40ZrSrwowM5/EtfwALSG3AdUw5vgAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;pstree&apos; title=&apos;&apos; src=&apos;/static/510859639ff9788b397279daa036857e/ca1dc/pstree.png&apos; srcset=&apos;/static/510859639ff9788b397279daa036857e/e7570/pstree.png 170w,
/static/510859639ff9788b397279daa036857e/f46e7/pstree.png 340w,
/static/510859639ff9788b397279daa036857e/ca1dc/pstree.png 680w,
/static/510859639ff9788b397279daa036857e/2876f/pstree.png 968w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;systemd의-특징&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemd%EC%9D%98-%ED%8A%B9%EC%A7%95&quot; aria-label=&quot;systemd의 특징 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemd의 특징&lt;/h3&gt;
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Red Hat 계열에서 도입되었고, 현재는 Ubuntu를 포함한 대부분의 주요 리눅스 배포판에서 사용된다.&lt;/li&gt;
&lt;li&gt;운영 중인 서비스의 상태를 판단할 때 사실상 기준점 역할을 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;운영 환경에서는 systemd를 기준으로 이 서비스가 살아있는지를 확인&lt;/strong&gt;한다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;systemctl-서비스-제어-인터페이스&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemctl-%EC%84%9C%EB%B9%84%EC%8A%A4-%EC%A0%9C%EC%96%B4-%EC%9D%B8%ED%84%B0%ED%8E%98%EC%9D%B4%EC%8A%A4&quot; aria-label=&quot;systemctl 서비스 제어 인터페이스 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemctl: 서비스 제어 인터페이스&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;systemctl&lt;/code&gt;은 &lt;strong&gt;systemd를 제어하기 위한 CLI 도구&lt;/strong&gt;이다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;주요-명령어&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A3%BC%EC%9A%94-%EB%AA%85%EB%A0%B9%EC%96%B4&quot; aria-label=&quot;주요 명령어 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;주요 명령어&lt;/h3&gt;
&lt;br&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# 상태 확인&lt;/span&gt;
systemctl status &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;service&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 시작 / 중지&lt;/span&gt;
systemctl start &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;service&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
systemctl stop &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;service&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 재시작&lt;/span&gt;
systemctl restart &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;service&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 부팅 시 자동 실행&lt;/span&gt;
systemctl &lt;span class=&quot;token builtin class-name&quot;&gt;enable&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;service&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
systemctl disable &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;service&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;systemctl-status로-서비스-상태-확인하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#systemctl-status%EB%A1%9C-%EC%84%9C%EB%B9%84%EC%8A%A4-%EC%83%81%ED%83%9C-%ED%99%95%EC%9D%B8%ED%95%98%EA%B8%B0&quot; aria-label=&quot;systemctl status로 서비스 상태 확인하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;systemctl status로 서비스 상태 확인하기&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/43530313bbc2c62e7b9cae1c32fb9322/f6f12/systemctl_status.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 31.76470588235294%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAABYlAAAWJQFJUiTwAAAA/UlEQVR42nWRaXKDMAyFuUIbwhbMYjAGjDFLgCT3v9er7E4z00758Y08lvz0ZHlCGeh5RzutGNYd4/2BeXtBDjNKoZCJDqzvkfMOiZAIiwp+lMOP/8e7FQ0aNWE8nlDbjkqN4M0ALgckuXDEhK0L0hJ+UpyKvQWV2RwtuUqyGh9B6vgM2S8uUeYeXeLsXDC4lahajbozyOsOheiRVS3ClCNi/B0jildyZ7FvridOPTtuJTWa3kCqGf24ktMFvblD0J3N2/+su9HlGW+/xyfRv+4t3rgcUNMGTVHPByZaiF4eMOvTLcvxU0NnQZPYhnYSxiXKhhZHTSJWIc5qfAHzL6hIHWYH5wAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;systemctl status&apos; title=&apos;&apos; src=&apos;/static/43530313bbc2c62e7b9cae1c32fb9322/ca1dc/systemctl_status.png&apos; srcset=&apos;/static/43530313bbc2c62e7b9cae1c32fb9322/e7570/systemctl_status.png 170w,
/static/43530313bbc2c62e7b9cae1c32fb9322/f46e7/systemctl_status.png 340w,
/static/43530313bbc2c62e7b9cae1c32fb9322/ca1dc/systemctl_status.png 680w,
/static/43530313bbc2c62e7b9cae1c32fb9322/02d09/systemctl_status.png 1020w,
/static/43530313bbc2c62e7b9cae1c32fb9322/9d567/systemctl_status.png 1360w,
/static/43530313bbc2c62e7b9cae1c32fb9322/f6f12/systemctl_status.png 2158w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;이 출력에서 특히 중요하게 봐야 하는 항목은 세 가지다.&lt;/p&gt;
&lt;h4 id=&quot;1-Active&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-Active&quot; aria-label=&quot;1 Active permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. Active&lt;/h4&gt;
&lt;p&gt;현재 서비스 상태를 보여준다.&lt;br&gt;
서비스가 죽었는지, 살아 있는지를 가장 먼저 판단하는 기준이다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;active (running)&lt;/code&gt;: 정상 실행 중&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;failed&lt;/code&gt;: 실패 상태&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;inactive&lt;/code&gt;: 실행 중이 아님&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;2-Main-PID&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-Main-PID&quot; aria-label=&quot;2 Main PID permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. Main PID&lt;/h4&gt;
&lt;p&gt;실제로 이 서비스를 대표해서 실행 중인 프로세스의 PID다.&lt;br&gt;
운영 중 프로세스 트리나 리소스 사용량을 볼 때 연결점이 된다.&lt;/p&gt;
&lt;h4 id=&quot;3-최근-로그&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-%EC%B5%9C%EA%B7%BC-%EB%A1%9C%EA%B7%B8&quot; aria-label=&quot;3 최근 로그 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3. 최근 로그&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;systemctl status&lt;/code&gt; 하단에는 최근 로그 몇 줄이 같이 붙는 경우가 많다.&lt;br&gt;
이 부분이 장애 원인을 빠르게 추정하는 데 매우 유용하다.&lt;/p&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;systemctl status&lt;/code&gt;를 통해 &lt;strong&gt;현재 상태 + 실패 힌트&lt;/strong&gt;를 함께 확인할 수 있다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;Unit-File-서비스-운영-정책-문서&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Unit-File-%EC%84%9C%EB%B9%84%EC%8A%A4-%EC%9A%B4%EC%98%81-%EC%A0%95%EC%B1%85-%EB%AC%B8%EC%84%9C&quot; aria-label=&quot;Unit File 서비스 운영 정책 문서 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Unit File: 서비스 운영 정책 문서&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;Unit File은 서비스가 어떤 운영 정책 아래 움직이는지를 판단할 수 있는 문서이다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;Unit&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Unit&quot; aria-label=&quot;Unit permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Unit&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;systemd를 이해하려면 &lt;strong&gt;Unit&lt;/strong&gt; 개념도 알아야 한다.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Unit은 systemd가 관리하는 시스템 구성 요소&lt;/strong&gt;를 의미한다.&lt;br&gt;
서비스뿐 아니라 마운트 지점, 소켓, 타겟 등도 모두 Unit으로 표현된다.&lt;/p&gt;
&lt;p&gt;즉, systemd는 서비스만 관리하는 것이 아니라,&lt;br&gt;
&lt;strong&gt;시스템 자원과 동작 단위&lt;/strong&gt;를 &lt;strong&gt;유닛(Unit)&lt;/strong&gt; 이라는 공통 개념으로 관리한다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;systemctl list-units&lt;/code&gt; 명령어를 통해 모든 유닛들을 조회할 수 있다. 그중 서비스 유닛만을 출력해봤다.&lt;/p&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/f71bb8e77c8bdb57500b667c9b33da91/66205/units.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 51.17647058823529%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAABYlAAAWJQFJUiTwAAABjElEQVR42m2S63KCMBSEeYXWKioCIje5E+Kt7fs/13Y3Wjo6/XFmAkm+7Nk9XjOcMHUG0b7AJsqwDtO5Pjaxq3c/QpRWOHYT8npEVg2oOouiGbHjvVWQzGe9sp1gCS2SAm9+iMU6musPGCIpWvTTDXV/cuB2vKDhOskbxHxsud3fgTVhZjyjyCpswwNWj43lA/YHbNCZK2GWKgeuL8ipVP93STkLcMCLvaHkRqiWCXQKX4AHKeQ5nZfK8fzlvvV/G+fOLpVX88WTOSMvWySHo9vcsf2Aal+Bw+kTzXB2QMF6e0V67BDQx5AqddfT5nT5htHLeY317oAlTfYfrc/A8hdID+n7QKB8FFD+CujzrlfRYEP5prfOxw1/rghZ/ONhP11dumVj0HGttgumHqVHl7aC8ZSYXusYTNca5EkxJ/YEZJqC6LzGpmUoje4wqKzqOWbZHSiFamVkKxUVrl5gTyk7hZObP61VSlxjE9A/zSM9tLBqWd5Q+ivsKRR797BkJwpFQuTtNs4cTNPxA/moHd+qMfHQAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;units&apos; title=&apos;&apos; src=&apos;/static/f71bb8e77c8bdb57500b667c9b33da91/ca1dc/units.png&apos; srcset=&apos;/static/f71bb8e77c8bdb57500b667c9b33da91/e7570/units.png 170w,
/static/f71bb8e77c8bdb57500b667c9b33da91/f46e7/units.png 340w,
/static/f71bb8e77c8bdb57500b667c9b33da91/ca1dc/units.png 680w,
/static/f71bb8e77c8bdb57500b667c9b33da91/02d09/units.png 1020w,
/static/f71bb8e77c8bdb57500b667c9b33da91/9d567/units.png 1360w,
/static/f71bb8e77c8bdb57500b667c9b33da91/66205/units.png 2548w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;Unit-File-서비스의-실행-정의&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Unit-File-%EC%84%9C%EB%B9%84%EC%8A%A4%EC%9D%98-%EC%8B%A4%ED%96%89-%EC%A0%95%EC%9D%98&quot; aria-label=&quot;Unit File 서비스의 실행 정의 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Unit File: 서비스의 실행 정의&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;“everything is a file” 이라는 리눅스의 철학처럼,&lt;br&gt;
systemd의 &lt;strong&gt;서비스 운영 정책도 파일 형태로 정의&lt;/strong&gt;된다.&lt;br&gt;
그 파일이 바로 &lt;strong&gt;Unit File&lt;/strong&gt;이다.&lt;/p&gt;
&lt;p&gt;실무에서는 아예 새 unit file을 처음부터 만드는 일보다,&lt;br&gt;
&lt;strong&gt;기존 서비스의 unit file을 읽고 해석하거나 일부 수정&lt;/strong&gt;하는 일이 더 자주 생긴다.&lt;/p&gt;
&lt;p&gt;따라서 unit file을 통해 이 서비스가 어떤 운영 정책 아래 움직이는지를 판단할 수 있어야 한다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;Unit의-종류&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Unit%EC%9D%98-%EC%A2%85%EB%A5%98&quot; aria-label=&quot;Unit의 종류 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Unit의 종류&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;유닛 유형&lt;/th&gt;
&lt;th&gt;확장자&lt;/th&gt;
&lt;th&gt;설명&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;service&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;.service&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;시스템 서비스, 보통 데몬&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;device&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;.device&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;커널이 인식한 디바이스&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;mount&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;.mount&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;파일 시스템 마운트 지점&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;path&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;.path&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;파일 또는 디렉터리 경로 감시&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;socket&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;.socket&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;프로세스 간 통신에 사용하는 소켓&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;snapshot&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;.snapshot&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;저장된 시스템 상태&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;target&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;.target&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;여러 unit을 묶는 논리적 그룹&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;h3 id=&quot;Unit-File의-위치&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Unit-File%EC%9D%98-%EC%9C%84%EC%B9%98&quot; aria-label=&quot;Unit File의 위치 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Unit File의 위치&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;Unit file은 보통 다음 디렉토리들에서 관리된다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;디렉토리&lt;/th&gt;
&lt;th&gt;설명&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;/usr/lib/systemd/system/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;패키지 설치 시 함께 제공되는 기본 unit file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;/run/systemd/system/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;런타임에 생성되는 임시 unit file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;/etc/systemd/system/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;운영자가 override 하거나 enable 설정에 의해 반영되는 영역. 우선순위가 가장 높다&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;운영 관점에서는 &lt;code class=&quot;language-text&quot;&gt;/etc/systemd/system/&lt;/code&gt;이 특히 중요하다.&lt;br&gt;
기본 설정 위에 운영자 의도가 덮어씌워지는 위치이기 때문이다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;Unit-File-구조-읽기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Unit-File-%EA%B5%AC%EC%A1%B0-%EC%9D%BD%EA%B8%B0&quot; aria-label=&quot;Unit File 구조 읽기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Unit File 구조 읽기&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;unit file은 보통 세 개의 블록으로 나뉜다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ini&quot;&gt;&lt;pre class=&quot;language-ini&quot;&gt;&lt;code class=&quot;language-ini&quot;&gt;&lt;span class=&quot;token section&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token section-name selector&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;My Service&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;After&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;network.target&lt;/span&gt;

&lt;span class=&quot;token section&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token section-name selector&quot;&gt;Service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;ExecStart&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;/usr/bin/my-app&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;WorkingDirectory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;/app&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;appuser&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;Environment&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;ENV=prod&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;Restart&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;always&lt;/span&gt;

&lt;span class=&quot;token section&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token section-name selector&quot;&gt;Install&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;WantedBy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;multi-user.target&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;각 블록의 역할은 다음과 같다.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;[Unit]&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;서비스의 메타 정보와 의존성을 정의한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;[Service]&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;가장 중요한 블록으로, 실제로 &lt;strong&gt;어떻게 실행할 것인가&lt;/strong&gt;가 정의된다.&lt;/li&gt;
&lt;li&gt;핵심 항목
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;ExecStart&lt;/code&gt;: 실제 실행 명령&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;WorkingDirectory&lt;/code&gt;: 실행 위치&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;User&lt;/code&gt; / &lt;code class=&quot;language-text&quot;&gt;Group&lt;/code&gt;: 실행 계정&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Environment&lt;/code&gt; / &lt;code class=&quot;language-text&quot;&gt;EnvironmentFile&lt;/code&gt;: 환경 변수 주입&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Restart&lt;/code&gt;: 재시작 정책&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;운영자가 이 블록에서 반드시 파악해야 하는 것은 보통 다음 세 가지다.
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;어떤 명령으로 실행되는가&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;어떤 계정으로 실행되는가&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;죽었을 때 어떤 정책으로 다시 뜨는가&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;[Install]&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;이 서비스가 enable 되었을 때 어느 target에 연결될지를 정의한다.&lt;/li&gt;
&lt;li&gt;쉽게 말해 &lt;strong&gt;부팅 시 자동 시작 설정과 연결&lt;/strong&gt;되는 영역이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;Unit-File-확인-방법&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Unit-File-%ED%99%95%EC%9D%B8-%EB%B0%A9%EB%B2%95&quot; aria-label=&quot;Unit File 확인 방법 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Unit File 확인 방법&lt;/h3&gt;
&lt;h4 id=&quot;1-서비스의-unit-file-보기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-%EC%84%9C%EB%B9%84%EC%8A%A4%EC%9D%98-unit-file-%EB%B3%B4%EA%B8%B0&quot; aria-label=&quot;1 서비스의 unit file 보기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. 서비스의 unit file 보기&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl &lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;service&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;2-로드된-unit-위치-확인하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-%EB%A1%9C%EB%93%9C%EB%90%9C-unit-%EC%9C%84%EC%B9%98-%ED%99%95%EC%9D%B8%ED%95%98%EA%B8%B0&quot; aria-label=&quot;2 로드된 unit 위치 확인하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. 로드된 unit 위치 확인하기&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl status &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;service&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;출력 중 &lt;code class=&quot;language-text&quot;&gt;Loaded&lt;/code&gt; 항목을 보면 어느 파일이 현재 로드되었는지 알 수 있다.&lt;/p&gt;
&lt;p&gt;예를 들어, 아래 결과는 현재 &lt;code class=&quot;language-text&quot;&gt;sshd.service&lt;/code&gt;가 어느 위치에서 로드되었는지 보여준다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ini&quot;&gt;&lt;pre class=&quot;language-ini&quot;&gt;&lt;code class=&quot;language-ini&quot;&gt;Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; preset: enabled)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;h3 id=&quot;실제-예시로-보는-Unit-File&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%A4%EC%A0%9C-%EC%98%88%EC%8B%9C%EB%A1%9C-%EB%B3%B4%EB%8A%94-Unit-File&quot; aria-label=&quot;실제 예시로 보는 Unit File permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;실제 예시로 보는 Unit File&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/f0170beec01ae9600147db87b5a8ae2d/2d324/systemctl_cat.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 57.64705882352942%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAABYlAAAWJQFJUiTwAAABbUlEQVR42p2S7W6CMBSGuQadH0NAQL7bAi1Whpma6f1f07vTOo1xy8L248kJIXnP26d1ZH9BIw/g7TsYIfUH5O6MQgzg6oCyfsN0ucbL6ziccBjgcYZUKGSVQpw3CFOBtGyx3jDMVzFmbjg+MDp1SI4aZa8h5A6cMLNWPapmi4JLbHKBpRdT0+CB9dP3FSfVHUR7DTIBrNVIyppaVvDj3M6lv8HCi6jtFRN+m26Q2P83nEb3qE1Y3UFuB6jdnnzqOxWpEDQZLbPNv9qb5l6UIzKLaZrlflzA8QU5yziCqECUsTvBprTtVmFm3czcNbUKrU/DnJgs/G842emEqOkwdQNMlv6PXgwm9Pn7GbPUiY8KyWGLhFyWcmt9CjpSq/fQw9G2NJvH3/JZI+4VeKPp2bR0oxwZa62zQnRW/tgwGxhTYDn0aLrBtnk82mQR/CnMBnpKYsXYXf5vjsYd+XJC2EgEYW4fcMkVwqT6d+AnLDZM1cSYXJAAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;systemctl cat&apos; title=&apos;&apos; src=&apos;/static/f0170beec01ae9600147db87b5a8ae2d/ca1dc/systemctl_cat.png&apos; srcset=&apos;/static/f0170beec01ae9600147db87b5a8ae2d/e7570/systemctl_cat.png 170w,
/static/f0170beec01ae9600147db87b5a8ae2d/f46e7/systemctl_cat.png 340w,
/static/f0170beec01ae9600147db87b5a8ae2d/ca1dc/systemctl_cat.png 680w,
/static/f0170beec01ae9600147db87b5a8ae2d/02d09/systemctl_cat.png 1020w,
/static/f0170beec01ae9600147db87b5a8ae2d/2d324/systemctl_cat.png 1306w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;ExecStart=/usr/sbin/sshd -D $OPTIONS&lt;/code&gt;&lt;br&gt;
→ 실제로 어떤 명령으로 SSH 데몬이 실행되는지 알 수 있다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;EnvironmentFile=-/etc/sysconfig/sshd&lt;/code&gt;&lt;br&gt;
→ 별도 환경 파일을 통해 옵션이 주입될 수 있음을 알 수 있다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Restart=on-failure&lt;/code&gt;&lt;br&gt;
→ 실패 시 자동 재시작 정책이 걸려 있음을 알 수 있다.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h3 id=&quot;Unit-File-수정-후-꼭-해야-하는-작업&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Unit-File-%EC%88%98%EC%A0%95-%ED%9B%84-%EA%BC%AD-%ED%95%B4%EC%95%BC-%ED%95%98%EB%8A%94-%EC%9E%91%EC%97%85&quot; aria-label=&quot;Unit File 수정 후 꼭 해야 하는 작업 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Unit File 수정 후 꼭 해야 하는 작업&lt;/h3&gt;
&lt;br&gt;
&lt;p&gt;unit file을 수정한 뒤에는 아래 명령이 필요하다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl daemon-reload
systemctl restart &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;service&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이유는 다음과 같다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;systemd는 unit file을 읽어 내부적으로 로드해 둔다.&lt;/li&gt;
&lt;li&gt;따라서 파일만 수정하고 끝내면 변경 내용이 바로 반영되지 않을 수 있다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;따라서 아래 두 단계가 함께 가는 경우가 많다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;daemon-reload&lt;/code&gt;: 설정 다시 읽기&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;restart&lt;/code&gt;: 실제 서비스 재기동&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&quot;왜-kill-했는데-프로세스가-다시-뜰까&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-kill-%ED%96%88%EB%8A%94%EB%8D%B0-%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EA%B0%80-%EB%8B%A4%EC%8B%9C-%EB%9C%B0%EA%B9%8C&quot; aria-label=&quot;왜 kill 했는데 프로세스가 다시 뜰까 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 kill 했는데 프로세스가 다시 뜰까?&lt;/h2&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;p&gt;운영하다 보면 프로세스를 죽였는데 다시 살아나는 상황을 자주 겪는다.&lt;/p&gt;
&lt;p&gt;이 글을 통해 &lt;strong&gt;리눅스 운영의 중심이 프로세스가 아니라 서비스&lt;/strong&gt;라는 점을 이해했다면,&lt;br&gt;
그 원인도 자연스럽게 파악할 수 있을 것이다.&lt;/p&gt;
&lt;p&gt;해당 프로세스가 &lt;strong&gt;systemd&lt;/strong&gt;에 의해 서비스로 관리되고 있어서,&lt;br&gt;
프로세스를 종료해도 서비스 정책에 따라 다시 실행된 것이다.&lt;/p&gt;
&lt;p&gt;그래서 실무에서는 장애가 났다고 해서 바로  &lt;code class=&quot;language-text&quot;&gt;kill&lt;/code&gt;하는 것이 아니라,&lt;br&gt;
먼저 &lt;strong&gt;어떤 서비스가 이 프로세스를 관리하고 있는지 확인&lt;/strong&gt;한 뒤 &lt;strong&gt;systemd&lt;/strong&gt;를 통해 조치한다.&lt;/p&gt;
&lt;p&gt;보통은 아래와 같은 흐름으로 대응한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;1. status 확인
2. 로그 확인
3. restart로 복구 시도&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;리눅스 운영에서는 프로세스 하나가 아니라,&lt;br&gt;
&lt;strong&gt;프로세스를 관리하는 서비스 단위로 시스템을 이해&lt;/strong&gt;하는 것이 중요하다!&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item><item><title><![CDATA[Amazon Athena]]></title><description><![CDATA[한줄요약 S3 데이터에 쿼리하는 서버리스 서비스 What is it? 표준 SQL을 사용해서 Amazon S…]]></description><link>https://jiu-jung.github.io/amazon-athena/</link><guid isPermaLink="false">https://jiu-jung.github.io/amazon-athena/</guid><pubDate>Mon, 23 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;br&gt;
&lt;h4 id=&quot;한줄요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%9C%EC%A4%84%EC%9A%94%EC%95%BD&quot; aria-label=&quot;한줄요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;한줄요약&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;S3 데이터에 쿼리하는 서버리스 서비스&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;What-is-it&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-is-it&quot; aria-label=&quot;What is it permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What is it?&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;표준 SQL&lt;/strong&gt;을 사용해서 &lt;strong&gt;Amazon S3에 있는 데이터를 쉽게 분석&lt;/strong&gt;할 수 있는 대화형 쿼리 서비스&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;서버리스&lt;/strong&gt; 서비스로, 관리할 인프라가 없고 실행한 쿼리에 대해서 비용 지불.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;자동으로 확장&lt;/strong&gt;되며, 쿼리를 &lt;strong&gt;병렬 실행&lt;/strong&gt;하여 빠르게 결과를 반환&lt;/li&gt;
&lt;li&gt;S3 데이터를 in-place 조회하므로, &lt;strong&gt;별도 적재 없이 ad hoc 쿼리&lt;/strong&gt;에 적합&lt;/li&gt;
&lt;li&gt;AWS Glue Data Catalog, 외부 Hive metastore, federated query와 연계해 메타데이터를 관리할 수 있음&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;When-use-it&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#When-use-it&quot; aria-label=&quot;When use it permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;When use it?&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;S3에 저장된&lt;/strong&gt; 정형/반정형/비정형 데이터 분석 (CSV, JSON, Parquet 등)&lt;/li&gt;
&lt;li&gt;S3 데이터에 대해 &lt;strong&gt;간단한 ad hoc SQL 쿼리&lt;/strong&gt;를 &lt;strong&gt;빠르게&lt;/strong&gt; 실행하고 싶을 때&lt;/li&gt;
&lt;li&gt;인프라나 클러스터를 &lt;strong&gt;직접 구축/운영하고 싶지 않을 때&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;로그 분석, 리포팅, 탐색적 주문처럼 주문형 조회가 필요할 때&lt;/li&gt;
&lt;li&gt;S3 Inventory, AWS Cost and Usage Report, 각종 AWS 서비스 로그를 SQL로 조회하고 싶을 때&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;Key-points-for-SAA&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Key-points-for-SAA&quot; aria-label=&quot;Key points for SAA permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Key points for SAA&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;S3에 있는 데이터&lt;/strong&gt;를 &lt;strong&gt;최소 변경, 최소 운영&lt;/strong&gt;으로 &lt;strong&gt;SQL 조회&lt;/strong&gt; → Athena&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S3 + SQL + 서버리스 + ad hoc 쿼리 + 운영 오버헤드 최소화&lt;/strong&gt; → Athena&lt;/li&gt;
&lt;li&gt;이미 데이터가 S3에 저장되어 있다면 Athena를 가장 먼저 떠올리기&lt;/li&gt;
&lt;li&gt;보통 Glue Data Catalog와 함께 출제됨&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;참고자료&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0%EC%9E%90%EB%A3%8C&quot; aria-label=&quot;참고자료 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고자료&lt;/h4&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.aws.amazon.com/athena/latest/ug/what-is.html&quot;&gt;https://docs.aws.amazon.com/athena/latest/ug/what-is.html&lt;/a&gt;
&lt;a href=&quot;https://docs.aws.amazon.com/athena/latest/ug/when-should-i-use-ate.html&quot;&gt;https://docs.aws.amazon.com/athena/latest/ug/when-should-i-use-ate.html&lt;/a&gt;
&lt;a href=&quot;https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-inventory-athena-query.html&quot;&gt;https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-inventory-athena-query.html&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Amazon S3 Transfer Acceleration]]></title><description><![CDATA[한줄요약 전 세계 클라이언트가 먼 S3 버킷에 대용량 데이터를 빠르게 업로드하도록 돕는 S3 기능 What is it? 전 세계 어디서든 멀리 떨어진 중앙 S3 버킷으로 더 빠르게 업로드할 수 있게 해주는 S…]]></description><link>https://jiu-jung.github.io/amazon-s3-transfer-acceleration/</link><guid isPermaLink="false">https://jiu-jung.github.io/amazon-s3-transfer-acceleration/</guid><pubDate>Mon, 23 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;br&gt;
&lt;h4 id=&quot;한줄요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%9C%EC%A4%84%EC%9A%94%EC%95%BD&quot; aria-label=&quot;한줄요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;한줄요약&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;전 세계 클라이언트가 먼 S3 버킷에 대용량 데이터를 빠르게 업로드하도록 돕는 S3 기능&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;What-is-it&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-is-it&quot; aria-label=&quot;What is it permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What is it?&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;전 세계 어디서든&lt;/strong&gt; 멀리 떨어진 &lt;strong&gt;중앙 S3 버킷&lt;/strong&gt;으로 더 &lt;strong&gt;빠르게 업로드&lt;/strong&gt;할 수 있게 해주는 &lt;strong&gt;S3 버킷 기능&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;사용자는 가까운 &lt;strong&gt;CloudFront 엣지 로케이션&lt;/strong&gt;에 먼저 업로드하고, 이후 &lt;strong&gt;AWS 글로벌 백본 네트워크&lt;/strong&gt;를 통해 대상 S3 버킷으로 전달됨&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;장거리 인터넷 구간&lt;/strong&gt;의 비효율을 줄여 업로드 성능을 개선함&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;When-use-it&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#When-use-it&quot; aria-label=&quot;When use it permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;When use it?&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;여러 국가·대륙&lt;/strong&gt;의 사용자 또는 지사에서 &lt;strong&gt;하나의 S3 버킷&lt;/strong&gt;으로 데이터를 &lt;strong&gt;빠르게&lt;/strong&gt; 모아야 할 때&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GB~TB 규모의 대용량 데이터&lt;/strong&gt;를 장거리로 업로드할 때&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;공용 인터넷&lt;/strong&gt;만으로는 장거리 전송 속도와 안정성이 떨어질 수 있을 때&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;운영 복잡도 증가 없이&lt;/strong&gt; S3 업로드 성능을 개선하고 싶을 때&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;Key-points-for-SAA&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Key-points-for-SAA&quot; aria-label=&quot;Key points for SAA permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Key points for SAA&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;글로벌 업로드 가속&lt;/strong&gt;이 필요하면 가장 먼저 떠올릴 것&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;단일 S3 버킷으로 직접 업로드&lt;/strong&gt;하는 구조에 적합&lt;/li&gt;
&lt;li&gt;별도 서버나 복잡한 중계 아키텍처 없이 사용 가능&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;멀티파트 업로드와 함께&lt;/strong&gt; 쓰면 대용량 파일 업로드에 더 유리함&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;참고자료&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0%EC%9E%90%EB%A3%8C&quot; aria-label=&quot;참고자료 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고자료&lt;/h4&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration.html?utm_source=chatgpt.com&quot;&gt;https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration.html&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[리눅스 가상머신 SSH로 접속하기]]></title><description><![CDATA[RHEL 10을 Minimal Install로 설치한 뒤 CLI 환경에서 실습을 시작했는데, 터미널 스크롤이 되지 않아 이전 출력 내용을 확인하기가 불편했다. 그래서 VM 안에 SSH 서버를 설치하고, macOS의 iTerm…]]></description><link>https://jiu-jung.github.io/rhel-ssh/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-ssh/</guid><pubDate>Sat, 21 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;RHEL 10을 &lt;strong&gt;Minimal Install&lt;/strong&gt;로 설치한 뒤 CLI 환경에서 실습을 시작했는데,&lt;br&gt;
터미널 스크롤이 되지 않아 이전 출력 내용을 확인하기가 불편했다.&lt;/p&gt;
&lt;p&gt;그래서 &lt;strong&gt;VM 안에 SSH 서버를 설치하고, macOS의 iTerm으로 접속해서 작업하는 방식&lt;/strong&gt;으로 환경을 바꿨다.&lt;/p&gt;
&lt;p&gt;이번 글에서는 그 설정 과정을 순서대로 정리한다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-ssh/#1-%EC%9D%BC%EB%B0%98-%EC%82%AC%EC%9A%A9%EC%9E%90-%EC%83%9D%EC%84%B1&quot;&gt;일반 사용자 생성&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-ssh/#2-SSH-%EC%84%9C%EB%B2%84-%EC%84%A4%EC%B9%98-%EB%B0%8F-%EC%8B%A4%ED%96%89&quot;&gt;SSH 서버 설치 및 실행&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-ssh/#3-%EB%B0%A9%ED%99%94%EB%B2%BD-%EC%83%81%ED%83%9C-%ED%99%95%EC%9D%B8&quot;&gt;방화벽 상태 확인&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-ssh/#4-VM-IP-%EC%A3%BC%EC%86%8C-%ED%99%95%EC%9D%B8&quot;&gt;VM IP 주소 확인&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-ssh/#5-iTerm%EC%97%90%EC%84%9C-SSH-%EC%A0%91%EC%86%8D&quot;&gt;iTerm에서 SSH 접속&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br&gt;
&lt;h3 id=&quot;1-일반-사용자-생성&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-%EC%9D%BC%EB%B0%98-%EC%82%AC%EC%9A%A9%EC%9E%90-%EC%83%9D%EC%84%B1&quot; aria-label=&quot;1 일반 사용자 생성 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. 일반 사용자 생성&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;SSH 접속을 위한 사용자를 생성한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useradd&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;passwd&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;usermod&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-aG&lt;/span&gt; wheel &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;각 명령어의 의미는 다음과 같다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;useradd -m &amp;lt;user_name&gt;&lt;/code&gt; : &lt;code class=&quot;language-text&quot;&gt;&amp;lt;user_name&gt;&lt;/code&gt; 사용자를 생성하고 홈 디렉터리도 함께 만든다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;passwd &amp;lt;user_name&gt;&lt;/code&gt; : &lt;code class=&quot;language-text&quot;&gt;&amp;lt;user_name&gt;&lt;/code&gt; 사용자의 비밀번호를 설정한다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;usermod -aG wheel &amp;lt;user_name&gt;&lt;/code&gt; : &lt;code class=&quot;language-text&quot;&gt;&amp;lt;user_name&gt;&lt;/code&gt; 사용자를 &lt;code class=&quot;language-text&quot;&gt;wheel&lt;/code&gt; 그룹에 추가한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;wheel&lt;/code&gt; 그룹&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;RHEL 계열에서는 보통 &lt;code class=&quot;language-text&quot;&gt;wheel&lt;/code&gt; 그룹 사용자에게 &lt;code class=&quot;language-text&quot;&gt;sudo&lt;/code&gt; 권한을 부여하므로, 이후 &lt;code class=&quot;language-text&quot;&gt;&amp;lt;user_name&gt;&lt;/code&gt; 계정으로 로그인하더라도 필요할 때 관리자 권한 명령을 실행할 수 있다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h3 id=&quot;2-SSH-서버-설치-및-실행&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-SSH-%EC%84%9C%EB%B2%84-%EC%84%A4%EC%B9%98-%EB%B0%8F-%EC%8B%A4%ED%96%89&quot; aria-label=&quot;2 SSH 서버 설치 및 실행 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. SSH 서버 설치 및 실행&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;VM 내부에 SSH 서버를 설치하고 바로 실행한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; dnf &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-y&lt;/span&gt; openssh-server
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl &lt;span class=&quot;token builtin class-name&quot;&gt;enable&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--now&lt;/span&gt; sshd
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl status sshd&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;dnf install -y openssh-server&lt;/code&gt; : SSH 서버 패키지 설치&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;systemctl enable --now sshd&lt;/code&gt; : 부팅 시 자동 시작 + 지금 바로 실행&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;systemctl status sshd&lt;/code&gt; : 서비스 상태 확인&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;sshd&lt;/code&gt;가 &lt;code class=&quot;language-text&quot;&gt;active (running)&lt;/code&gt; 상태로 보이면 정상적으로 실행된 것이다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;3-방화벽-상태-확인&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-%EB%B0%A9%ED%99%94%EB%B2%BD-%EC%83%81%ED%83%9C-%ED%99%95%EC%9D%B8&quot; aria-label=&quot;3 방화벽 상태 확인 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3. 방화벽 상태 확인&lt;/h3&gt;
&lt;hr&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl status firewalld
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; firewall-cmd &lt;span class=&quot;token parameter variable&quot;&gt;--permanent&lt;/span&gt; --add-service&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;ssh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;ssh&lt;/code&gt; 서비스가 이미 허용되어 있어서 &lt;code class=&quot;language-text&quot;&gt;already enabled&lt;/code&gt;가 출력되었다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;4-VM-IP-주소-확인&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-VM-IP-%EC%A3%BC%EC%86%8C-%ED%99%95%EC%9D%B8&quot; aria-label=&quot;4 VM IP 주소 확인 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;4. VM IP 주소 확인&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;SSH로 접속하려면 VM의 IP 주소가 필요하다.
아래 명령어로 현재 IP를 확인한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ip&lt;/span&gt; addr&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;출력 결과에서 네트워크 인터페이스에 붙은 &lt;code class=&quot;language-text&quot;&gt;inet&lt;/code&gt; 주소를 확인하면 된다.&lt;br&gt;
이 IP가 나중에 iTerm에서 접속할 때 사용할 주소이다.&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;5-iTerm에서-SSH-접속&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#5-iTerm%EC%97%90%EC%84%9C-SSH-%EC%A0%91%EC%86%8D&quot; aria-label=&quot;5 iTerm에서 SSH 접속 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;5. iTerm에서 SSH 접속&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;이제 macOS에서 iTerm을 열고 아래처럼 접속한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ssh&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;@&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;vm_ip&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;처음 접속할 때는 fingerprint 확인 메시지가 뜰 수 있는데, &lt;code class=&quot;language-text&quot;&gt;yes&lt;/code&gt;를 입력하면 된다.&lt;br&gt;
이후 비밀번호를 입력하면 VM의 RHEL 환경에 SSH로 접속된다.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;&lt;strong&gt;접속 성공!&lt;/strong&gt;
&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/ab44a45ed7cc8f1c4502a1f67a737e24/3a95e/success.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 73.52941176470587%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAABYlAAAWJQFJUiTwAAACD0lEQVR42p2T207bQBCGU1CVBlrSxE5sZ31YO16fY4ckOJagqtRe8iqFd+MRuMSvg5QLtNV0xuAQolYKtfRpdi/2239m5U4Hv5vSP7u+Fqz4UbCqqliBmEIchmkygbUsy7NO+31Lo7vVZQhhuXicL8tNUpxvuAg3rog2brDD/h7xgvgxSHPw4/Su9fVsL3pwpjEMlLHs9k6gP1BANzno1hRGEw7jF0bMfa6Gs8Wwp5JxAYblPZCLhCfJbFEHSQ6qxqTBOPjRDIJ0DlykwHgAjp/gQR9MN0BCUFHUoui2pEs1y6vJ1Qi5SOowWwAmlRNHNIdMFFlYSUhwlFpuBJYXgWZ6MNQskj0LMfkboe2FtRfOwAsyiYBICpji3o9oNjkmjMEN0qZyhKSEix1gcqnuJwyTos4XFYh0Lmfna0iKFUSzZdN2kq9QWjTt06UuXkhruozGgG1jy5iQ8d2W4xpllEp6YdakoWS0FlhppiYO3plG9AjNQ1Hb7QzHuM6Ki7cJF+srTLOUOrNBRCl8VTQYjvQGWn/uK3DaH8KXwaid3VZI8vXl91ehqlk1DZbi0zwmjr89tHv4b7TCi+rqVYgvVpNI0S2p6A6+4L8FBwtpsE3CA0X7wt2WPw3H7F41KKH9hPx+DxjmicJk89U9uUj4sdvt/uz1Tm+RX8jNO6Ezt8foIFf7P39AjpDj/+Tohc4fwp813K5JjXwAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;success&apos; title=&apos;&apos; src=&apos;/static/ab44a45ed7cc8f1c4502a1f67a737e24/ca1dc/success.png&apos; srcset=&apos;/static/ab44a45ed7cc8f1c4502a1f67a737e24/e7570/success.png 170w,
/static/ab44a45ed7cc8f1c4502a1f67a737e24/f46e7/success.png 340w,
/static/ab44a45ed7cc8f1c4502a1f67a737e24/ca1dc/success.png 680w,
/static/ab44a45ed7cc8f1c4502a1f67a737e24/02d09/success.png 1020w,
/static/ab44a45ed7cc8f1c4502a1f67a737e24/9d567/success.png 1360w,
/static/ab44a45ed7cc8f1c4502a1f67a737e24/3a95e/success.png 1558w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h3 id=&quot;이후-접속-방법&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9D%B4%ED%9B%84-%EC%A0%91%EC%86%8D-%EB%B0%A9%EB%B2%95&quot; aria-label=&quot;이후 접속 방법 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;이후 접속 방법&lt;/h3&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li&gt;UTM에서 VM 실행&lt;/li&gt;
&lt;li&gt;VM이 부팅될 때까지 기다리기
&lt;ul&gt;
&lt;li&gt;로그인 화면이나 셸 프롬프트가 뜰 때까지 기다린다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;sudo systemctl enable --now sshd&lt;/code&gt;를 실행해두었다면, 부팅 시 &lt;code class=&quot;language-text&quot;&gt;sshd&lt;/code&gt;도 자동으로 함께 시작된다.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;UTM 콘솔에서 상태 확인
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl status sshd  
&lt;span class=&quot;token function&quot;&gt;ip&lt;/span&gt; addr&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;sshd&lt;/code&gt;가 &lt;code class=&quot;language-text&quot;&gt;active (running)&lt;/code&gt; 인지 확인&lt;/li&gt;
&lt;li&gt;현재 VM IP가 무엇인지 확인&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;iTerm에서 접속
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ssh&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;@&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;vm_ip&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;br&gt;
&lt;h3 id=&quot;명령어-정리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AA%85%EB%A0%B9%EC%96%B4-%EC%A0%95%EB%A6%AC&quot; aria-label=&quot;명령어 정리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;명령어 정리&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;VM 내부에서 실행한 명령어&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useradd&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;passwd&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;usermod&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-aG&lt;/span&gt; wheel &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; dnf &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-y&lt;/span&gt; openssh-server
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl &lt;span class=&quot;token builtin class-name&quot;&gt;enable&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--now&lt;/span&gt; sshd
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl status sshd

&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl status firewalld
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; firewall-cmd &lt;span class=&quot;token parameter variable&quot;&gt;--permanent&lt;/span&gt; --add-service&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;ssh

&lt;span class=&quot;token function&quot;&gt;ip&lt;/span&gt; addr&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;iTerm에서 실행한 명령어&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ssh&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;user_name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;@&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;vm_ip&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content:encoded></item><item><title><![CDATA[Red Hat Enterprise Linux 10.0 Minimal 설치하기]]></title><description><![CDATA[엔터프라이즈 환경의 리눅스를 실습해보고 싶어서, UTM을 이용해 RHEL 10 가상머신을 설치했다. 이번 글에서는 아래 순서로 설치 과정을 정리한다. 환경 세팅 (UTM VM 생성) RHEL 설치 및 초기 설정 Red Hat 구독 등록…]]></description><link>https://jiu-jung.github.io/rhel-installation/</link><guid isPermaLink="false">https://jiu-jung.github.io/rhel-installation/</guid><pubDate>Fri, 20 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;엔터프라이즈 환경의 리눅스를 실습해보고 싶어서, &lt;strong&gt;UTM&lt;/strong&gt;을 이용해 &lt;strong&gt;RHEL 10&lt;/strong&gt; 가상머신을 설치했다.&lt;/p&gt;
&lt;p&gt;이번 글에서는 아래 순서로 설치 과정을 정리한다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-installation/#1-%ED%99%98%EA%B2%BD-%EC%84%B8%ED%8C%85&quot;&gt;환경 세팅 (UTM VM 생성)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-installation/#2-RHEL-%EC%84%A4%EC%B9%98-%EB%B0%8F-%EC%B4%88%EA%B8%B0-%EC%84%A4%EC%A0%95&quot;&gt;RHEL 설치 및 초기 설정&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jiu-jung.github.io/rhel-installation/#3-%EA%B5%AC%EB%8F%85-%EB%93%B1%EB%A1%9D&quot;&gt;Red Hat 구독 등록&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br&gt;
&lt;h2 id=&quot;0-설치-환경&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#0-%EC%84%A4%EC%B9%98-%ED%99%98%EA%B2%BD&quot; aria-label=&quot;0 설치 환경 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;0. 설치 환경&lt;/h2&gt;
&lt;hr&gt;
&lt;ul&gt;
&lt;li&gt;MacBook pro M5 (10 코어, 24GB 메모리, 512GB 스토리지)&lt;/li&gt;
&lt;li&gt;UTM&lt;/li&gt;
&lt;li&gt;RHEL 10 (&lt;code class=&quot;language-text&quot;&gt;rhel-10.0-aarch64-dvd.iso&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h2 id=&quot;1-환경-세팅&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-%ED%99%98%EA%B2%BD-%EC%84%B8%ED%8C%85&quot; aria-label=&quot;1 환경 세팅 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1. 환경 세팅&lt;/h2&gt;
&lt;hr&gt;
&lt;h4 id=&quot;1-UTM-설치&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-UTM-%EC%84%A4%EC%B9%98&quot; aria-label=&quot;1 UTM 설치 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1) UTM 설치&lt;/h4&gt;
&lt;p&gt;먼저 &lt;a href=&quot;https://mac.getutm.app/&quot;&gt;UTM 다운로드 페이지&lt;/a&gt;에서 UTM을 설치한다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;UTM은 macOS에서 다른 운영체제를 손쉽게 설치하고 실행할 수 있도록 도와주는 가상머신 도구이다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h4 id=&quot;2-RHEL-이미지-다운로드&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-RHEL-%EC%9D%B4%EB%AF%B8%EC%A7%80-%EB%8B%A4%EC%9A%B4%EB%A1%9C%EB%93%9C&quot; aria-label=&quot;2 RHEL 이미지 다운로드 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2) RHEL 이미지 다운로드&lt;/h4&gt;
&lt;p&gt;RHEL 이미지는 &lt;a href=&quot;https://developers.redhat.com/&quot;&gt;Red Hat Developers&lt;/a&gt;에 가입한 뒤 &lt;a href=&quot;https://developers.redhat.com/products/rhel/download#publicandprivatecloudreadyrhelimages&quot;&gt;공식 다운로드 페이지&lt;/a&gt;에서 받을 수 있다.&lt;/p&gt;
&lt;p&gt;아래 이미지를 다운받았다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;rhel-10.0-aarch64-dvd.iso&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;M 시리즈 맥에서는 &lt;code class=&quot;language-text&quot;&gt;aarch64&lt;/code&gt; 이미지를 선택해야 한다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h4 id=&quot;3-UTM에서-VM-생성&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-UTM%EC%97%90%EC%84%9C-VM-%EC%83%9D%EC%84%B1&quot; aria-label=&quot;3 UTM에서 VM 생성 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3) UTM에서 VM 생성&lt;/h4&gt;
&lt;p&gt;UTM을 실행한 뒤 아래 순서대로 가상머신을 만든다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Create a New Virtual Machine → Virtualize → Linux&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;옵션은 다음과 같이 설정했다.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Memory&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;4096 MiB&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Enable display output&lt;/code&gt; 체크&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Enable hardware OpenGL acceleration&lt;/code&gt; 체크 해제&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Use Apple Virtualization&lt;/code&gt; 체크 해제&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Boot from ISO image&lt;/code&gt; 선택&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Boot ISO Image&lt;/code&gt;에 다운로드한 &lt;code class=&quot;language-text&quot;&gt;rhel-10.0-aarch64-dvd.iso&lt;/code&gt; 선택&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Storage&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;64 GiB&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Shared Directory&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Share is read only&lt;/code&gt; 체크 해제&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Save&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;가볍게 실습할 목적이라 4GB 메모리, 64GB 스토리지로 설정했다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;기본적인 VM 생성이 끝났다.&lt;/p&gt;
&lt;br&gt;
&lt;h2 id=&quot;2-RHEL-설치-및-초기-설정&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-RHEL-%EC%84%A4%EC%B9%98-%EB%B0%8F-%EC%B4%88%EA%B8%B0-%EC%84%A4%EC%A0%95&quot; aria-label=&quot;2 RHEL 설치 및 초기 설정 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2. RHEL 설치 및 초기 설정&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;설치 과정은 잘 정리된 &lt;a href=&quot;https://velog.io/@calintzcs/%EC%84%A4%EC%B9%98-Red-Hat-Enterprise-Linux-8.x-Minimal-%EC%84%A4%EC%B9%98LegacyUEFI&quot;&gt;블로그&lt;/a&gt;를 참고하여 진행했다.&lt;/p&gt;
&lt;h4 id=&quot;1-설치-시작&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-%EC%84%A4%EC%B9%98-%EC%8B%9C%EC%9E%91&quot; aria-label=&quot;1 설치 시작 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1) 설치 시작&lt;/h4&gt;
&lt;p&gt;부팅 후 설치 메뉴가 뜨면 다음 항목으로 들어간다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Install Red Hat Enterprise Linux 10.0&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;2-Software-Selection&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-Software-Selection&quot; aria-label=&quot;2 Software Selection permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2) Software Selection&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Minimal Install&lt;/code&gt; 선택&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;필요한 것만 직접 추가하면서 환경을 구성해보기 위해 &lt;code class=&quot;language-text&quot;&gt;Minimal Install&lt;/code&gt;을 선택했다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h4 id=&quot;3-Installation-Destination&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-Installation-Destination&quot; aria-label=&quot;3 Installation Destination permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3) Installation Destination&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Storage Configuration&lt;/code&gt;에서 &lt;code class=&quot;language-text&quot;&gt;Custom&lt;/code&gt; 선택&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;파티션 구성을 직접 확인해보기 위해 &lt;code class=&quot;language-text&quot;&gt;Custom&lt;/code&gt;으로 진행했다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h4 id=&quot;4-Manual-Partitioning&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-Manual-Partitioning&quot; aria-label=&quot;4 Manual Partitioning permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;4) Manual Partitioning&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;New mount points will use the following partitioning scheme&lt;/code&gt;&lt;br&gt;
→ &lt;code class=&quot;language-text&quot;&gt;Standard Partition&lt;/code&gt; 선택&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Click here to create them automatically&lt;/code&gt; 클릭&lt;/li&gt;
&lt;li&gt;기본값 그대로 두고 &lt;code class=&quot;language-text&quot;&gt;Done&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h4 id=&quot;5-Network--Host-Name&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#5-Network--Host-Name&quot; aria-label=&quot;5 Network  Host Name permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;5) Network &amp;#x26; Host Name&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Configure&lt;/code&gt; 클릭&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;General&lt;/code&gt; 탭
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Connect automatically with priority&lt;/code&gt; 값은 &lt;code class=&quot;language-text&quot;&gt;-999&lt;/code&gt; 유지&lt;/li&gt;
&lt;li&gt;자동 연결 체크 유지&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;IPv4 Settings&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;DHCP&lt;/code&gt; 유지&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;별도로 고정 IP를 지정해야 하는 환경이 아니라면 기본 DHCP 설정으로 충분하다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h4 id=&quot;6-Root-Account&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#6-Root-Account&quot; aria-label=&quot;6 Root Account permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;6) Root Account&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Enable root account&lt;/code&gt; 체크&lt;/li&gt;
&lt;li&gt;root 비밀번호 지정&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;학습용 환경이라 root 계정을 바로 활성화해두었다.
실제 운영 환경이라면 root 직접 사용보다 일반 사용자 + sudo 방식이 더 권장된다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h4 id=&quot;7-설치-완료-및-재부팅&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#7-%EC%84%A4%EC%B9%98-%EC%99%84%EB%A3%8C-%EB%B0%8F-%EC%9E%AC%EB%B6%80%ED%8C%85&quot; aria-label=&quot;7 설치 완료 및 재부팅 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;7) 설치 완료 및 재부팅&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;설치 완료 후 &lt;code class=&quot;language-text&quot;&gt;Reboot System&lt;/code&gt; 선택&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;설치에는 약 1분 정도 소요되었다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h4 id=&quot;8-설치-성공&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#8-%EC%84%A4%EC%B9%98-%EC%84%B1%EA%B3%B5&quot; aria-label=&quot;8 설치 성공 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;8) 설치 성공!&lt;/h4&gt;
&lt;p&gt;&lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; margin-bottom: 16px;&apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/d8a593822787194fa257a6bd3df1eaed/9ddde/success.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 68.23529411764706%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAu0lEQVR42u3TywqCQBSA4aO4GLy0MBfeMEIEERtsRqJND+XOgdQ3FloKA9MxbF1ZyxbfXBbn3x248JTV57LPadXSiom8pGKXZmKf5S+leSFwThQVb2l96g+cM0ji8JoksfKDUPpBoMIoUlvPU6Zlvce2lWU70nY287sDQsyOEKIMw5g0TZO6rsv5BoBPTEihHjDQLx+53Gs8Z4d/8B9cGRx+FXy08GjmzUAjuq00LlvWYBhcxNDxS3PDvQMOQPwrnJ9VLAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;success&apos; title=&apos;&apos; src=&apos;/static/d8a593822787194fa257a6bd3df1eaed/ca1dc/success.png&apos; srcset=&apos;/static/d8a593822787194fa257a6bd3df1eaed/e7570/success.png 170w,
/static/d8a593822787194fa257a6bd3df1eaed/f46e7/success.png 340w,
/static/d8a593822787194fa257a6bd3df1eaed/ca1dc/success.png 680w,
/static/d8a593822787194fa257a6bd3df1eaed/02d09/success.png 1020w,
/static/d8a593822787194fa257a6bd3df1eaed/9d567/success.png 1360w,
/static/d8a593822787194fa257a6bd3df1eaed/9ddde/success.png 2784w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
위처럼 터미널 창이 나오면 설치가 제대로 된 것이다. 로그인을 진행하면 된다.&lt;/p&gt;
&lt;br&gt;
&lt;h2 id=&quot;2-트러블슈팅&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-%ED%8A%B8%EB%9F%AC%EB%B8%94%EC%8A%88%ED%8C%85&quot; aria-label=&quot;2 트러블슈팅 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2*. 트러블슈팅&lt;/h2&gt;
&lt;hr&gt;
&lt;h4 id=&quot;1-display-output-is-not-active&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-display-output-is-not-active&quot; aria-label=&quot;1 display output is not active permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;1) display output is not active&lt;/h4&gt;
&lt;p&gt;처음에는 display output 설정이 잘못된 줄 알고 UTM 설정을 여러 번 수정했다.&lt;br&gt;
그런데 실제로는 오류가 아니라, &lt;strong&gt;몇 초 기다리면 정상적으로 설치 화면이 나타났다.&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;display output is not active&lt;/code&gt; 문구가 보이면 기다리면 된다!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;h4 id=&quot;2-재부팅-후-다시-설치-화면이-뜨는-문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-%EC%9E%AC%EB%B6%80%ED%8C%85-%ED%9B%84-%EB%8B%A4%EC%8B%9C-%EC%84%A4%EC%B9%98-%ED%99%94%EB%A9%B4%EC%9D%B4-%EB%9C%A8%EB%8A%94-%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;2 재부팅 후 다시 설치 화면이 뜨는 문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;2) 재부팅 후 다시 설치 화면이 뜨는 문제&lt;/h4&gt;
&lt;p&gt;설치가 끝난 뒤 재부팅했는데, 다시 RHEL 설치 화면으로 들어가는 문제가 있었다.&lt;/p&gt;
&lt;p&gt;이 문제의 원인은 &lt;strong&gt;UTM이 계속 ISO 파일로 부팅&lt;/strong&gt;하고 있기 때문이다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;UTM에서는 설치용 ISO가 removable drive처럼 연결된 상태로 남아 있다.&lt;/li&gt;
&lt;li&gt;따라서 설치가 끝난 뒤에도 VM이 가상 디스크가 아니라 설치용 ISO를 다시 먼저 읽어서, installer 화면으로 돌아가게 된다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;해결 방법&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;사이드바에서 해당 VM 우클릭&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Edit&lt;/code&gt; → &lt;code class=&quot;language-text&quot;&gt;Drives&lt;/code&gt; → &lt;code class=&quot;language-text&quot;&gt;USB Drive&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Path&lt;/code&gt;에 연결된 ISO 경로를 &lt;code class=&quot;language-text&quot;&gt;Clear&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;Save&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;h2 id=&quot;3-구독-등록&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-%EA%B5%AC%EB%8F%85-%EB%93%B1%EB%A1%9D&quot; aria-label=&quot;3 구독 등록 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;3. 구독 등록&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;RHEL은 패키지 설치와 업데이트를 위해 Red Hat 계정 구독 등록이 필요하다.&lt;/p&gt;
&lt;p&gt;터미널에서 아래 명령어를 실행해서 계정 정보를 입력하면 된다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;subscription-manager register&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;RHEL 10.0 환경에서는 위 명령어만으로 별도 추가 설정 없이 등록이 완료되었다.&lt;/p&gt;
&lt;p&gt;이후에는 아래 명령어로 시스템 정보와 구독 상태를 확인하고, 패키지를 업데이트했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# 시스템 정보 확인&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt; /etc/redhat-release

&lt;span class=&quot;token comment&quot;&gt;# 구독 상태 확인&lt;/span&gt;
subscription-manager status

&lt;span class=&quot;token comment&quot;&gt;# 패키지 메타데이터 갱신 및 업데이트&lt;/span&gt;
dnf check-update  
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; dnf update &lt;span class=&quot;token parameter variable&quot;&gt;-y&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content:encoded></item></channel></rss>