<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>life_dev</title>
        <link>https://velog.io/</link>
        <description>안녕하세요! 개발공부를 하고 있습니다. 감사히 배우겠습니다. ;)</description>
        <lastBuildDate>Sat, 14 Aug 2021 16:43:35 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <copyright>Copyright (C) 2019. life_dev. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/tak_4242" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[ft_printf] Final : Bonus part]]></title>
            <link>https://velog.io/@tak_4242/ftprintf-Final-bonus-part</link>
            <guid>https://velog.io/@tak_4242/ftprintf-Final-bonus-part</guid>
            <pubDate>Sat, 14 Aug 2021 16:43:35 GMT</pubDate>
            <description><![CDATA[<h2 id="🔮-ft_printf_bonusc">🔮 <code>ft_printf_bonus.c</code></h2>
<ul>
<li><p><code>int printchar_num(const char **str, va_list ap)</code> - <code>ft_printf</code>함수와 마찬가지로, str 문자열안에 cxXdiup%에 해당하는 문자를 프린트한다. 파라미터가 <code>**str</code>인 이유는 문자열<code>*str</code>를 <code>int ft_printf(const char *str, ...)</code>로 부터 받기 위해 문자열을 가리키는 포인터를 사용했다.</p>
</li>
<li><p><code>void putchar_inside(const char *c, int    *count)</code>- 학교 norm에 맞추기 위해서, 원래는 생성하지 않았던 함수 인데, norm에 맞추기 위해 생성하였다. 파라미터로 <code>const char *c</code>를 넣으므로써, 문자 하나 하나를 읽을때마다 그에 해당하는 문자 길이를 리턴한다. </p>
</li>
<li><p><code>int ft_printf(const char *str, ...)</code> - 실 printf함수 처럼, <code>% widthcxXdiup%</code> 해당하는 문자열을 읽고, 그 길이 값을 리턴한다. </p>
</li>
</ul>
<h2 id="🔮-ft_printf_width_bonusc">🔮 <code>ft_printf_width_bonus.c</code></h2>
<ul>
<li><p><code>int print_space(const char *pos_flag, va_list ap)</code> - 문자열 str안의 해당하는 width발견시, 조건에 맞게 계산하여 그 값에 해당하는 space를 리턴한다. 이 함수 안에서 이미 <code>argument</code>와 <code>width</code>의 조건들을 계산하였다. </p>
</li>
<li><p><code>static int get_hexdec_len(unsigned long n)</code>  - 16 진법을 사용하는 x, X, p의 길이 값을 리턴할 때 쓰인다. </p>
</li>
<li><p><code>int get_arg_len(char c, va_list ap)</code> - <code>cxXdiup</code> argument의 길이를 프린트 할때 쓰인다. </p>
</li>
<li><p><code>static int get_arg_len_di(va_list ap)</code>  -원래 <code>int get_arg_len(char c, va_list ap)</code> 함수안에 포함 되어 있었으나, 학교 norm (하나의 함수가 25라인을 넘으면 안됨)에 의해, 새로운 함수로 만들었다.  </p>
</li>
<li><p><code>static int get_arg_len_u (va_list ap)</code>- 원래 <code>int get_arg_len(char c, va_list ap)</code> 함수안에 포함 되어 있었으나, 학교 norm (하나의 함수가 25라인을 넘으면 안됨)에 의해, 새로운 함수로 만들었다.  </p>
</li>
</ul>
<h2 id="🔮-ft_printf_num_bonusc">🔮 <code>ft_printf_num_bonus.c</code></h2>
<ul>
<li><p><code>int print_di(const char **str, va_list ap)</code> - 문자열 str에서 d와 i를 발견하면, 해당 문자값을 프린트함. <code>ft_itoa</code>를 사용하면서 malloc을 사용하기 때문에 <code>free</code>를 반드시 해주어야 한다. 그렇게 하지 않을시, memory leaks가 발생한다. </p>
</li>
<li><p><code>int print_u(const char **str, va_list ap)</code>- 문자열 str에서 u를 발견하면, 해당 문자값을 프린트함. <code>ft_utoa</code> 를 사용하면서 malloc을 사용하기 때문에 <code>free</code>를 반드시 해주어야 한다. 그렇게 하지 않을시, memory leaks가 발생한다. </p>
</li>
<li><p><code>int ft_putnbr(size_t nbr, char *base)</code> - putnbr를 사용하여, 16 진수를 표현하도록 하였다. </p>
</li>
<li><p><code>int printf_pointer(const char **str, va_list ap)</code> - 문자열 str안에 p가 보이면, ft_putnbr내장함수를 이용하여 해당 값을 프린트한다.</p>
</li>
<li><p><code>int printf_num(const char **str, va_list ap)</code> - 문자열 str안에 x,X 값이 보이면, ft_putnbr내장함수를 이용하여 해당 값을 프린트한다.</p>
</li>
</ul>
<h2 id="🔮-ft_printf_string_bonusc">🔮 <code>ft_printf_string_bonus.c</code></h2>
<ul>
<li><p><code>int ft_isdigit(int c)</code> - 문자열 str안에 숫자가 있는지 확인하는 함수. <code>int ft_printf</code>함수안에서 <code>%</code>뒤에 숫자가 보이면 그것을 <code>width</code>로 간주해, <code>width</code>에 해당하는 조건들을 프린트 하도록 한다. </p>
</li>
<li><p><code>size_t ft_strlen(const char *str)</code> - str 문자열의 길이를 구하는 함수</p>
</li>
<li><p><code>int write_null(void)</code> - string 함수에서 null이 나올경우, null을 적고 해당 length를 6을 리턴한다.</p>
</li>
<li><p><code>int printpercent(const char **str)</code> - 문자열 str에서 % 가 보이면, 
%를 적고, 해당 length인 1을 리턴한다. </p>
</li>
<li><p><code>int print_s(const char **str, va_list ap)</code> - 문자열 str에서 s가 보이면, 해당 값을 프린트하고, s길이값을 리턴한다.  </p>
</li>
</ul>
<h2 id="🔮-ft_printf_utils_bonusc">🔮 <code>ft_printf_utils_bonus.c</code></h2>
<ul>
<li><p><code>static int ft_untlen(unsigned int n)</code> - <code>ft_utoa</code>에 필요한 함수 (malloc시, 해당 길이에 해당 하는 값을 메모리에 저장해야 하기 때문)</p>
</li>
<li><p><code>char *ft_utoa(unsigned int n)</code> - 문자열 str에 보이는 u를 프린트 할때,<code>unsigned int</code>가 파라미터로 사용되어야 하기 때문에 <code>itoa</code>의 변형인 <code>utoa</code> 함수를 생성함.</p>
</li>
<li><p><code>char ft_atoi(const char *str)</code>- <code>print_space</code>함수에서 <code>%</code>이후에 argument의 길이를 구할때 쓰임. </p>
</li>
<li><p><code>static int ft_intlen(int n)</code> - <code>ft_untlen</code>과는 다르게 <code>int n</code>을 파라미터로 받으며, <code>ft_itoa</code>함수에서 malloc 동적 할당시 사용함 </p>
</li>
<li><p><code>ft_itoa(int n)</code> - 파라미터는 <code>int n</code>이며,  문자열 str에서 d나 i를 출력하는 함수를 사용할때  <code>ft_itoa</code>를 사용함. </p>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ft_printf] Final : Mandatory part]]></title>
            <link>https://velog.io/@tak_4242/ftprintf-final-Mandatory-part</link>
            <guid>https://velog.io/@tak_4242/ftprintf-final-Mandatory-part</guid>
            <pubDate>Sat, 14 Aug 2021 16:39:12 GMT</pubDate>
            <description><![CDATA[<h2 id="🔮-ft_printfc">🔮 <code>ft_printf.c</code></h2>
<ul>
<li><p><code>int pritchar_num(const char **str, va_list ap)</code> - 문자열에 csxXidup% 해당되는 문자가 있으면, 해당 값을 프린트 하는 함수</p>
</li>
<li><p><code>int ft_printf(const char *str, ...)</code> - 과제에서 요구한  ft_printf() 최종 함수 </p>
</li>
</ul>
<h2 id="🔮-ft_printf_numc">🔮 <code>ft_printf_num.c</code></h2>
<ul>
<li><p><code>int print_di(const char **str, va_list ap)</code> - 문자열 str에서 d와 i를 발견하면, 해당 문자값을 프린트함</p>
</li>
<li><p><code>int print_u(const char **str, va_list ap)</code>- 문자열 str에서 u를 발견하면, 해당 문자값을 프린트함</p>
</li>
<li><p><code>int ft_putnbr(size_t nbr, char *base)</code> - putnbr를 사용하여, 16 진수를 표현하도록 하였다. </p>
</li>
<li><p><code>int printf_pointer(const char **str, va_list ap)</code> - 문자열 str안에 p가 보이면, ft_putnbr내장함수를 이용하여 해당 값을 프린트한다.</p>
</li>
<li><p><code>int printf_num(const char **str, va_list ap)</code> - 문자열 str안에 x,X 값이 보이면, ft_putnbr내장함수를 이용하여 해당 값을 프린트한다</p>
</li>
</ul>
<h2 id="🔮-ft_printf_stringc">🔮 <code>ft_printf_string.c</code></h2>
<ul>
<li><p><code>int write_null(void)</code> - string 함수에서 null이 나올경우, null을 적고 해당 length를 6을 리턴한다.</p>
</li>
<li><p><code>int printpercent(const char **str)</code> - 문자열 str에서 % 가 보이면, 
%를 적고, 해당 length인 1을 리턴한다. </p>
</li>
<li><p><code>int print_s(const char **str, va_list ap)</code> - 문자열 str에서 s가 보이면, 해당 값을 프린트하고, s길이값을 리턴한다.  </p>
</li>
</ul>
<h2 id="🔮-ft_printf_utilsc">🔮 <code>ft_printf_utils.c</code></h2>
<ul>
<li><p><code>static int ft_untlen(unsigned int n)</code> - ft_utoa에 필요한 함수 (malloc시, 해당 길이에 해당 하는 값을 메모리에 저장해야 하기 때문)</p>
</li>
<li><p><code>char *ft_utoa(unsigned int n)</code> - 문자열 str에 보이는 u를 프린트 할때,<code>unsigned int</code>가 파라미터로 사용되어야 하기 때문에 <code>itoa</code>의 변형인 <code>utoa</code> 함수를 생성함.</p>
</li>
<li><p><code>size_t ft_strlen(const char *str)</code> - str 문자열의 길이를 구하는 함수</p>
</li>
<li><p><code>static int ft_intlen(int n)</code> -  <code>ft_untlen</code>과는 다르게 <code>int n</code>을 파라미터로 받으며, <code>ft_itoa</code>함수에서 malloc 동적 할당시 사용함 </p>
</li>
<li><p><code>ft_itoa(int n)</code> - 파라미터는 <code>int n</code>이며,  문자열 str에서 d나 i를 출력하는 함수를 사용할때  ft_itoa를 사용함. </p>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[JavaScript] functions]]></title>
            <link>https://velog.io/@tak_4242/JavaScript-functions</link>
            <guid>https://velog.io/@tak_4242/JavaScript-functions</guid>
            <pubDate>Mon, 09 Aug 2021 13:30:27 GMT</pubDate>
            <description><![CDATA[<h2 id="🔮-what-is-a-functions">🔮 What is a functions?</h2>
<p>Functions are one of the fundamental building blocks in JavaScript. A function is a set of statements that performs a particular task of the program. This task could be just a little part of a program or even the whole program.</p>
<h3 id="💡declaring-a-function-in-js">💡Declaring a function in JS</h3>
<ul>
<li>The function <strong>declaration</strong> is the process of <strong>creating function</strong>, but not executing it. </li>
</ul>
<pre><code class="language-js">function sayHi()
{
  console.log(&#39;Hello!&#39;);
}</code></pre>
<ul>
<li>The process of <strong>executing(calling)</strong> the function is known as function <strong>invocation</strong></li>
</ul>
<p>==&gt; as many as times as you invoke the function, that many times it will execute the code between the curly braces. 
<code>( in our case: &#39;Hello!&#39;);</code></p>
<pre><code class="language-js">sayHi();</code></pre>
<h3 id="💡-function-syntax">💡 Function Syntax</h3>
<pre><code class="language-js">// keyword  function   parameters (if any)
// ^         name  ________|
// |          |   |
function sayHello() {
  // the code or so called the body of the function
  // return an expression (if needed)
}</code></pre>
<h3 id="💡-arguments-and-parameters">💡 Arguments and Parameters</h3>
<pre><code class="language-js">// function declaration with a parameter
function sayHello(language) {
  switch (language) {
    case &#39;fr&#39;:
      console.log(&#39;Bonjour!&#39;);
      break;
    case &#39;ger&#39;:
      console.log(&#39;Hallo!&#39;);
      break;
    case &#39;esp&#39;:
      console.log(&#39;Hola!&#39;);
      break;
    default:
      console.log(&#39;Hello!&#39;);
  }
}

// function invocation with or without an argument
sayHello(&#39;ger&#39;); // =&gt; Hallo!
sayHello(&#39;fr&#39;); // =&gt; Bonjour!
sayHello(&#39;esp&#39;); // =&gt; Hola!
sayHello(); // =&gt; Hello!</code></pre>
<blockquote>
<p>-
<strong>Parameter</strong> is the variable between the parentheses which is part of the function declaration. In the case above: The <code>language</code> variable. Note that this word is a placeholder and can be any word possible. </p>
</blockquote>
<ul>
<li><strong>Argument</strong> is the value passed to the function at the moment of its invocation. In the case above: The different strings <code>ger</code>, <code>fr</code>, or <code>esp</code> that are passed and stored in the parameter.</li>
</ul>
<pre><code class="language-js">// we passed argument &quot;ger&quot;
//                      |
//           -----------
//          |
sayHello(&#39;ger&#39;); // =&gt; Hallo!

// we passed argument &quot;fr&quot;
sayHello(&#39;fr&#39;); // =&gt; Bonjour!

// we passed argument &quot;esp&quot;
sayHello(&#39;esp&#39;); // =&gt; Hola!

// we didn&#39;t pass any arguments, so the default part was executed
sayHello(); // =&gt; Hello!</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[[JavaScript] Loops and iterations
]]></title>
            <link>https://velog.io/@tak_4242/JavaScript-Loops-and-iterations</link>
            <guid>https://velog.io/@tak_4242/JavaScript-Loops-and-iterations</guid>
            <pubDate>Mon, 09 Aug 2021 13:08:45 GMT</pubDate>
            <description><![CDATA[<h2 id="loops"><code>Loops</code></h2>
<p>Using a loop simply means : <strong>Repeat this code until some condition is true</strong></p>
<h3 id="🔮-while-loop">🔮 <code>while loop</code></h3>
<pre><code class="language-js">while (condition) {
  // code to be executed while the condition is true
}</code></pre>
<blockquote>
<h3 id="the-while-loop-in-js">The while loop in JS</h3>
</blockquote>
<ul>
<li>the *<em>condition *</em>: once the condition is <code>false</code>, the loop will end;</li>
<li>the ** code to execute** : the purpose of the loop is to run some code a certain number of times. </li>
</ul>
<pre><code class="language-js">let counter = 1;

while (counter &lt;= 10){
  console.log(counter);
  counter += 1;
} </code></pre>
<h3 id="while-loop-in-grpah"><code>While loop in grpah</code></h3>
<p><img src="https://images.velog.io/images/tak_4242/post/4a2ca433-d88c-4e93-9f39-730df5833901/image.png" alt=""></p>
<h3 id="🔮-for-loop">🔮 <code>for loop</code></h3>
<ul>
<li>A <code>for</code>loop is much like the <code>while</code>loop, except that some of the functionalities you had to do on your ownn are included in it. </li>
<li><code>for loop</code> :  <code>i</code> will be started from <code>1</code> and incremented <code>1</code> until the <code>10</code>.</li>
</ul>
<pre><code class="language-js">for (let i = 1; i &lt;= 10; i++)
{
    console.log(i);
}</code></pre>
<p><img src="https://images.velog.io/images/tak_4242/post/ae00b790-473b-4449-a40b-91af45e28d65/image.png" alt=""></p>
<h3 id="🔮-nested-loops">🔮 <code>Nested loops</code></h3>
<p>Fizbuzz</p>
<pre><code class="language-js">//  Creating the loop...
for (let i = 1; i &lt;= 50; i++) {
  //  when at least one condition is true, run the code
  if (i % 10 === 0 || i % 15 === 0) {
    console.log(&#39;Donkey!&#39;);
  }

  // when both conditions are true, run the code
  if (i % 2 !== 0 &amp;&amp; (i - 1) % 10 !== 0) {
    console.log(&#39;Monkey!&#39;);
  }

  //  on numbers divisible by 5, continue to the next iteration
  if (i % 5 === 0) {
    continue;
  }

  //  ... and console.log the variable i
  console.log(i);
}</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[[JavaScript] Conditional statement]]></title>
            <link>https://velog.io/@tak_4242/JavaScript-conditinal-statement</link>
            <guid>https://velog.io/@tak_4242/JavaScript-conditinal-statement</guid>
            <pubDate>Mon, 09 Aug 2021 11:36:05 GMT</pubDate>
            <description><![CDATA[<h2 id="conditional-statement">Conditional statement</h2>
<h3 id="🔮if--else-statement">🔮<code>if -else</code> statement</h3>
<p>The <code>else</code> statement is executed when the <code>if</code>statement condition is false.</p>
<pre><code class="language-js">if (condition) {
  // statements
} else {
  // statements
}</code></pre>
<h3 id="🔮-the--else-if-statement">🔮 The  <code>else if</code> statement</h3>
<p>To be able to chain multiple conditions, we use<code>else if</code>statements. The <code>else if</code> statement is executed when the previous <code>if</code> or <code>else if</code> statement condition is false. </p>
<pre><code class="language-js">if (condition1) {
  // statements
} else if (condition2) {
  // statements
} else if (condition3) {
  // statements
} else {
  // if all above turn to be false,
  // this block of code will be executed
}</code></pre>
<blockquote>
<p> ✏️ One very important syntax rule to follow when writing your <code>if, else if</code> and <code>else</code> statements is:</p>
</blockquote>
<ul>
<li><code>if</code> and <code>else if</code> statements *<em>always require a condition *</em>in order to work,</li>
<li><code>else</code> statements <strong>do not need a condition</strong>, as it means to run the block of code in every other possible case.</li>
</ul>
<h3 id="🔮-switch">🔮 <code>Switch</code></h3>
<p>The value of the variable <code>pet</code> is actually “dog”, so it will find if “dog” is one of the cases in the switch block and execute the statement inside.</p>
<pre><code class="language-js">JSResult Skip Results Iframe
EDIT ON
let pet = &quot;dog&quot;;

switch (pet) {
  case &quot;cat&quot;:
    console.log(&quot;I will be break a lot of things but hey, I&#39;m adorable ... &quot;)
    break;
  case &quot;dog&quot;:
    console.log(&quot;I will be very annoying but I&#39;m your best friend ... &quot;)
    break;
  case &quot;hamster&quot;:
    console.log(&quot;I will be impossible to find but I&#39;m reeeeaaaally cute ... &quot;)
    break;
  default:
    console.log(&quot;I&#39;m a special pet!&quot;)
    break;
}</code></pre>
<h3 id="🔮-break">🔮 <code>break</code></h3>
<ul>
<li>The <code>break</code> statement finshes a block execution such as conditionl blocks or loop blocks, and continues with the execution of the program. </li>
<li>In programming, you will use <code>break</code> very rarelym because you should be able to control the flow of your program instead of break in it.</li>
</ul>
<h3 id="switch-break-cheatsheet"><code>Switch break cheatsheet</code></h3>
<p><img src="https://images.velog.io/images/tak_4242/post/851dc923-afb6-49d7-89d3-b6bb76ef9fa1/image.png" alt=""></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ft_print] Printf_Mandatory 함수 구현 과정 ]]></title>
            <link>https://velog.io/@tak_4242/ftprint-PrintfMandatory-%ED%95%A8%EC%88%98-%EA%B5%AC%ED%98%84-%EA%B3%BC%EC%A0%95</link>
            <guid>https://velog.io/@tak_4242/ftprint-PrintfMandatory-%ED%95%A8%EC%88%98-%EA%B5%AC%ED%98%84-%EA%B3%BC%EC%A0%95</guid>
            <pubDate>Wed, 04 Aug 2021 11:57:39 GMT</pubDate>
            <description><![CDATA[<h2 id="ft_printf-함수-구현-과정">Ft_printf 함수 구현 과정</h2>
<ol>
<li><p><code>int    ft_printf(const char *str, ...)</code> 함수 안에서 <code>%</code>를 찾는 즉시, 해당되는 type 형태에 <code>cspdiuxX%</code>따라 해당 값을 출력한다. (먼저, 모든 type값을 출력하는 하나의 함수를 만든 후, optimize 필요 여부에 따라 함수들을 쪼개는 형식으로 진행 했다.)</p>
</li>
<li><p>과제에서 주어진 <code>int ft_printf(const char *str, ...)</code>를 사용하기 위해서, type에 따라 출력되는 함수에 <code>int printchar(const char **str, va_list ap)</code>를 거의 적용하였다. </p>
</li>
</ol>
<ul>
<li><code>**str</code> : 문자열의 포인터</li>
<li><code>va_list</code> : 가변 인자 목록 포인터 </li>
</ul>
<ol start="3">
<li><code>printf</code> 함수의 반환 type은 <code>int</code>이며, 출력되는 문자의 개수를 반환한다. 출력되는 문자의 개수는 <code>공백()</code>, <code>개행(\n)</code>, <code>가로 탭(\t)</code>등을 포함한다. </li>
</ol>
<p>❗️ <code>va_arg</code> 가변 인자 포인터 값을  이용하여, <code>printf</code>와 같은 리턴값을 출력했다.</p>
<p>❗️ 주의점, <code>printf</code>는 <code>\n</code>을   1바이트로 인식하고 반환시 값을 포함한다. <code>%d</code>와 같이 <code>%</code> 의 값은 바이트로도 인식하지 않고, 반환시 값을 포함하지도 않는다.</p>
<p>❗️ 내가 작성한 <code>ft_printf</code>함수는 <code>%d</code> 값이 있을시, <code>퍼센트</code>와 해당 <code>type</code>의 바이트를 인식해줘야 하기 때문에, 반환 값 출력시, 해당 바이트인 <code>2바이트</code>를 항상 빼줘야 한다. </p>
<ol start="4">
<li><code>malloc</code>을 써준 함수들은 memory leaks 와 같은 오류를 방지하기 위해 <code>free</code>를 꼭 해줘야 한다. </li>
</ol>
<h4 id="💡-printf--반환값-예시">💡 printf  반환값 예시</h4>
<pre><code class="language-c">#include &lt;stdio.h&gt;
int main(void)
{
    int re; // printf의 리턴type은 int다!
    int se;
    char c = &#39;H&#39;;
    char *s = &quot;FOUR&quot;;

    printf(&quot;**********print  C********\n&quot;);
    re = printf(&quot;%c\n&quot;,c);
    printf(&quot;re: %d\n&quot;, re);

    se = ft_printf(&quot;%c\n&quot;,c);
    printf(&quot;se: %d\n&quot;, se);

    int ke;
    int te;

    printf(&quot;********print S********\n&quot;);
    te = printf(&quot;Real%s\n&quot;, s); // &#39;\n&#39; = 1 byte 
    printf(&quot;te: %d\n&quot;, te);

    ke = ft_printf(&quot;Mine%s\n&quot;, s); // 내 함수는 % (1 byte), s (1 byte)로 받으므로 %s 에 해당하는 2바이트를 -2로 빼줘야 한다.
    printf(&quot;ke: %d\n&quot;, ke);

    return (0);
    }</code></pre>
<h4 id="💡-출력값">💡 출력값</h4>
<pre><code class="language-c">**********print  C********
H
re: 2
H
se: 2
********print S********
RealFOUR
te: 9
MineFOUR
ke: 9</code></pre>
<h3 id="ft_printfc-함수">ft_printf.c 함수</h3>
<pre><code class="language-c">
#include &quot;ft_printf.h&quot;

int    printchar(const char **str, va_list ap) // **str = *str의(문자열) 포인터
{
    int        i;

    while (**str)
    {
        if ((char) **str == &#39;c&#39;)
        {
            i = va_arg(ap, int); // 가변인자 포인터에서 특정 자료형 크기만큼 값을 가져옴. 여기서는 int의 크기를 가져옴.
            write(1, &amp;i, 1);
            (*str)++;
            return (1); // return(1)은 c 의 1바이트를 의미한다. 
        }
        else if ((char)**str == &#39;s&#39;)
            return (print_s(str, ap));
        else if ((char)**str == &#39;x&#39; || (char)**str == &#39;X&#39; || (char)**str == &#39;p&#39;)
            return (print_num(str, ap));
        else if ((char)**str == &#39;d&#39; || (char)**str == &#39;i&#39;)
            return (print_di(str, ap));
        else if ((char)**str == &#39;u&#39;)
            return (print_u(str, ap));
        else
            return (printpercent(str));
    }
    return (0);
}

int    ft_printf(const char *str, ...)
{
    va_list ap; // argument pointer 가변인자 목록 포인터 (가변인자의 메모리 주소저장.)
    int        len;

    va_start(ap, str); // 가변인자 목록 포인터 설정
    len = ft_strlen(str); // str의 길이
    while (*str) // *str 끝까지 반복한다. 
    {
        if (*str == &#39;%&#39;) // &#39;%&#39;를 발견하는 즉시, printchar를 출력한다.
        {
            str++;
            len += printchar(&amp;str, ap) - 2; // -2는 (%d, %c 등 %와 알파벳을 포함한 2바이트를 의미한다)
        }
        else // str == %를 찾지 못한경우, str를 ++ 하면서 찾는다. 
        {
            write(1, str, 1);
            str++;
        }
    }
    va_end(ap); // 가변인자 처리가 끝났을떄 포인터를 null로 초기화.
    return (len); // printf 의 리턴값은 int (길이) 이므로
}</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ft_print]  Makefile 과 컴파일]]></title>
            <link>https://velog.io/@tak_4242/ftprint-Makefile-%EA%B3%BC-%EC%BB%B4%ED%8C%8C%EC%9D%BC</link>
            <guid>https://velog.io/@tak_4242/ftprint-Makefile-%EA%B3%BC-%EC%BB%B4%ED%8C%8C%EC%9D%BC</guid>
            <pubDate>Wed, 28 Jul 2021 10:07:36 GMT</pubDate>
            <description><![CDATA[<p>ft_printf 과제의 경우 <code>Makefile</code>을 이용해 정적 라이브러리 파일을 만들고, 라이브러리 파일과 함께 <code>main.c</code> 파일을 컴파일해야 한다. </p>
<h2 id="makefile">Makefile</h2>
<ul>
<li>ft_printf에서는 libft함수를 포함하여 사용 할 수 있어, 기존의<code>Makefile</code>생성방법과는 약간 다르다.</li>
<li>Makefile안에, <code>libft</code>의 make 파일과 그 경로를 불러오는 코드를 적어야 한다. </li>
</ul>
<p><code>${NAME}: ${OBJS} $(call libft_call, all)</code> : 이런 식으로, <code>call</code>을 사용하여 libft 폴더안에 있는 함수를 불러와야 한다. </p>
<pre><code class="language-c">SRCS    = ft_printf.c

SRCS_B    =

OBJS    = ${SRCS:.c=.o}

OBJS_B    = ${SRCS_B:.c=.o}

NAME    = libftprintf.a

RM         = rm -f

AR        = ar rc

define libft_call
        cd libft &amp;&amp; $(MAKE) $(1) &amp;&amp; cd ..
endef

.c.o:
        gcc -Wall -Wextra -Werror -c $&lt; -o ${&lt;:.c=.o}

all:    ${NAME}

${NAME}:    ${OBJS}
        $(call libft_call, all)
        ${AR} ${NAME} ${OBJS}

bonus:         ${OBJS_B}
        $(call libft_call, all)
        ${AR} ${NAME} ${OBJS_B}

clean:
        $(call libft_call, clean)
        ${RM} ${OBJS} ${OBJS_B}

fclean:        clean
        $(call libft_call, fclean)
        ${RM}    ${NAME}

re:         fclean all

.PHONY:     all bonus clean fclean re</code></pre>
<h2 id="compile">Compile</h2>
<h4 id="컴파일-옵션--외부-정적-라이브러리를-이용한-컴파일">컴파일 옵션 : 외부 정적 라이브러리를 이용한 컴파일</h4>
<p>libft 함수를 포함하여 함께 컴파일을 할때는 하기와 같이 컴파일한다. </p>
<p><code>gcc -Wall -Wextra -Werror -L. -lftprintf -Llibft -lft ft_printf.c</code></p>
<h4 id="사용하는-gcc-플래그-목록과-상세-설명">사용하는 gcc 플래그 목록과 상세 설명</h4>
<ul>
<li><code>L</code> (대문자) : 외부 라이브러리를 사용한다는 의미. 라이브러리의 위치를 정해주는 옵션.</li>
<li><code>L 뒤에 붙은 .</code> : 사용할 외부 라이브러리의 경로 (붙여서 씀)</li>
<li><code>l (소문자)</code> : 링크할 라이브러리 파일을 지정한다. 예를 들어 <code>lftprintf</code>로 사용할 외부 라이브러리의 파일명을 지정 할 수 있는데, 이렇게 하면 <code>**lib**ftpritnf.**a**</code>파일을 사용한다. </li>
</ul>
<p>출처 :<a href="http://seyong.me/study/learn-with-printf/">http://seyong.me/study/learn-with-printf/</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[JavaScript] Boolean]]></title>
            <link>https://velog.io/@tak_4242/JavaScript-Boolean</link>
            <guid>https://velog.io/@tak_4242/JavaScript-Boolean</guid>
            <pubDate>Wed, 28 Jul 2021 06:52:49 GMT</pubDate>
            <description><![CDATA[<h2 id="what-is-a-boolean">What is a <code>Boolean</code>?</h2>
<ul>
<li><p>Boolean is a type of data that can have two different values: <strong>true</strong> or <strong>false</strong>.</p>
</li>
<li><p>Do you like cat? <strong>YES</strong></p>
</li>
<li><p>Do you like beer? <strong>NO</strong></p>
</li>
</ul>
<h3 id="comparison-operators">Comparison operators</h3>
<p><img src="https://images.velog.io/images/tak_4242/post/2afa9ecc-34d8-43dd-b006-aad8568614c0/image.png" alt=""></p>
<h3 id="logical-operators--and-or-and-not">Logical operators : <code>AND</code>, <code>OR</code>, and <code>NOT</code></h3>
<p><img src="https://images.velog.io/images/tak_4242/post/d07b5e89-ecb6-4f78-87f6-edbc2b2b4e17/image.png" alt=""></p>
<h3 id="truthy-and-falsy">Truthy and Falsy</h3>
<p>JavaScript, and many other languages, support boolean data types that could be true or false. In addition to that, everything in JavaScript has an implicit boolean value that can be truthy or falsy. When you say that a value is truthy in JavaScript, it doesn’t mean that the value is true. <strong>Instead, it means that the value will result as true when evaluated in a boolean context.</strong>
Correspondingly, when you say a value is falsy in JavaScript, it means the value translates to false when evaluated in a Boolean context.</p>
<blockquote>
<p>3 different data types in JS </p>
</blockquote>
<ul>
<li><code>undefined</code> is a value, automatically set by JS, to a variable that was declared, but not initialized with a value.</li>
<li><code>null</code> is a type of data in JS that points, generally intentional, to a non-existing value.</li>
<li><code>NaN</code> or Not a Number is commonly the result of trying to apply Number methods to data types that are not numbers.</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[JavaScript] String]]></title>
            <link>https://velog.io/@tak_4242/JavaScript-String</link>
            <guid>https://velog.io/@tak_4242/JavaScript-String</guid>
            <pubDate>Tue, 27 Jul 2021 10:01:38 GMT</pubDate>
            <description><![CDATA[<h2 id="introduction">Introduction</h2>
<blockquote>
<p>A <strong>string</strong> in any programming language is simply *<em>a sequence of characters *</em>between quotes. A <code>character</code> can be a letter, number, punctuation, or even new lines and tabs. It just needs to be between quotes.</p>
</blockquote>
<p>You can use any of the following types of quotes when creating a string:</p>
<ul>
<li>&quot;&quot; - double quotes,</li>
<li>&#39;&#39; - single quotes and</li>
<li>`` - backticks (in most keyboards, it is placed above the tab on the left corner).</li>
</ul>
<p>Using the <code>backticks</code> will be useful if you want to:</p>
<ul>
<li>interpolate variables into the strings or</li>
<li>have a multiline string.</li>
</ul>
<blockquote>
<p><strong>String interpolation *<em>is a common practice that allows you to *</em>add the value of a variable directly inside a string</strong>. It is only available when using <code>backticks</code> and is achieved by wrapping a variable inside <code>${}</code> and adding it to the string, check the code below and it will make more sense!</p>
</blockquote>
<h4 id="example-1">Example 1)</h4>
<p>Input: </p>
<pre><code class="language-js">let language = &#39;JavaScript&#39;;
console.log(`I am learning ${language}!`);
</code></pre>
<p>Output:</p>
<pre><code class="language-js">&quot;I am learning JavaScript!&quot;</code></pre>
<h4 id="example-2">Example 2)</h4>
<p>Input : </p>
<pre><code class="language-js">const voyage = `
- Italy for a coffee
- UK for a shopping &amp; musicals
- Spain for a churros 
- Vienna for a coffee also!`

console.log(`I REALLY want to go for a voyage... ${voyage}`);</code></pre>
<p>Output :</p>
<pre><code>&quot;I REALLY want to go for a voyage... 
- Italy for a coffee
- UK for a shopping &amp; musicals
- Spain for a churros 
- Vienna for a coffee also!&quot;</code></pre><h2 id="string-tips--tricks">String tips &amp; tricks</h2>
<h3 id="concatenation">Concatenation</h3>
<p>❗️ You can easily <strong>concatenate or add characters to strings with the + or += operator.</strong> </p>
<pre><code class="language-js">let emptyCon = &quot;heyyy &quot;;
emptyCon += &quot;G&#39;day mate!&quot;;

console.log(emptyCon);</code></pre>
<p><code>&quot;heyyy G&#39;day mate!&quot;</code></p>
<p>❗️ In JavaScript, you <strong>can concatenate numbers with strings:</strong></p>
<pre><code class="language-js">Result Skip Results Iframe
EDIT ON
let age = 21;
console.log(`I am ${age} years old`);
console.log(&quot;How old are you? Seriously ...&quot;);
console.log(`I am ${age+12} years old.`);</code></pre>
<h3 id="the-length-property">The <code>.length</code> property</h3>
<p>❗️ To use the <code>.length</code> property, need to use the backticks(``)! </p>
<pre><code class="language-js">const fact = `I love Takroux!`;
console.log(`&quot;${fact} is a string and the length is ${fact.length}&quot;`)</code></pre>
<pre><code>&quot;&#39;I love Takroux! is a string and the length is 15&#39;&quot;</code></pre><h3 id="the-touppercase-method">The <code>.toUpperCase()</code> method</h3>
<blockquote>
<p><code>.toUppercase()</code> is a method of <code>string</code> data types in JS that allows you to change all the letters in a string to their Uppercase version</p>
</blockquote>
<p>Apply <code>.toUpperCase()</code> code :</p>
<pre><code class="language-js">let name = &quot;Yooyoo&quot;;
let up = name.toUpperCase();
console.log(up);</code></pre>
<p>output : 
<code>YOOYOO</code></p>
<blockquote>
<p> ❌  <strong>Doesn&#39;t work in this way</strong> ❌ </p>
</blockquote>
<pre><code class="language-js">let catName = &quot;Tak roux&quot;;
console.log(.toUpperCase(catName));</code></pre>
<p>As you can see, to use <code>.toUpperCase()</code> and any other <strong>methods in JS we always need to use () at the end</strong>. However, when we use <code>.length</code>and other attributes, <strong>we do not use the <del>parentheses</del>.</strong></p>
<h3 id="accessing-a-single-character-of-a-string-using-its-index">Accessing a single character of a string using its <code>index</code></h3>
<p>You can access characters inside of strings with their index number.
The index determines the character order in the word, from left to right, *<em>but be aware the index always starts at 0. *</em> To access a character via its index you can use <code>[]</code> like shown in the example below.</p>
<pre><code class="language-js">const greeting = &quot;Hello&quot;;
console.log(greeting[0]); // =&gt; H
console.log(greeting[4]); // =&gt; o
console.log(greeting[9]); // =&gt; undefined
console.log(greeting[-2]); // =&gt; undefined</code></pre>
<h3 id="accessing-a-substring">Accessing a substring</h3>
<h4 id="--indexofsubstring">- <code>.indexOf(substring)</code></h4>
<blockquote>
<p>JavaScript has a cool <code>indexOf()</code> method that returns the index of a particular character/string occurrence. If the substring was not found, it returns <strong>-1</strong>. To use it you just need to put the character or characters string you want to know the index of inside the <code>()</code> of <code>indexOf()</code> as shown below.</p>
</blockquote>
<pre><code class="language-js">const favoritePhrase = &quot;Don&#39;t be evil&quot;;

console.log(favoritePhrase.indexOf(&quot;Don&#39;t&quot;)); // =&gt; 0

console.log(favoritePhrase.indexOf(&quot;e&quot;)); // =&gt; 7 because indexOf prints the FIRST occurance

console.log(favoritePhrase.indexOf(&quot;z&quot;)); // -1 since it&#39;s not found</code></pre>
<p>❗️  If a word has the same character/substring two or more times, the indexOf() method will return the index of the first occurrence.</p>
<h4 id="--slicestart-end">- <code>.slice(start, end)</code></h4>
<ul>
<li>the <strong>slice()</strong> method extracts a part of a string and returns it as a new string, without modifying the original string.</li>
</ul>
<pre><code class="language-js">
let statement = &quot;I am the Ironhacker and I can&#39;t wait for this course to start!!!&quot;;

// it is zero indexed ==&gt; starts with zero
let test1 = statement.slice(0, 19);
console.log(test1); // =&gt; I am the Ironhacker

// if the second parameter is not passed, it will capture 
// from the character found on the position that corelates with passed number 
// to the end of the string
let test2 = statement.slice(24);
console.log(test2); // =&gt; I can&#39;t wait for this course to start!!!

// if negative nuber is passed, the count starts from the end of the string
let test3 = statement.slice(-8);
console.log(test3); // =&gt; start!!!</code></pre>
<h3 id="based-on-what-weve-learnedexercise">Based on what we&#39;ve learned...Exercise!</h3>
<pre><code class="language-js">let turtle1 = &#39;Leonardo&#39;;
let turtle2 = &#39;Raphael&#39;;
let turtle3 = &#39;Donatello&#39;;
let turtle4 = &#39;Michelangelo&#39;;

let allTurtles = &#39; &#39;;
allTurtles += turtle1;
allTurtles += &#39; &#39; + turtle2;
allTurtles += &#39; &#39; + turtle3;
allTurtles += &#39; &#39; + turtle4;
console.log(allTurtles);
console.log(allTurtles.indexOf(&#39;Donatello&#39;));
console.log(allTurtles.length);

const like = `
- Coffee
- Tak Roux
- peace
`
console.log(`My favorites are: ${like}` + allTurtles);</code></pre>
<p>Output</p>
<pre><code>18
40
&quot;My favorites are: 
- Coffee
- Tak Roux
- peace
 Leonardo Raphael Donatello Michelangelo&quot;</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[JavaScript] Numbers]]></title>
            <link>https://velog.io/@tak_4242/JavaScript-Numbers</link>
            <guid>https://velog.io/@tak_4242/JavaScript-Numbers</guid>
            <pubDate>Tue, 27 Jul 2021 09:06:18 GMT</pubDate>
            <description><![CDATA[<h2 id="basic-operators">Basic Operators</h2>
<pre><code class="language-js">console.log(2 + 2);
console.log(4 - 2);
console.log(3 * 2);
console.log(6 / 2);</code></pre>
<h3 id="exponentitation">Exponentitation</h3>
<blockquote>
<p>Exponentitation is the process of taking quantity <code>b</code> (the base) to the power of another quantity <code>e</code> (the exponent). Or in simpler words: it is the process of multiplying <code>b</code> (the base) by itself as many times as indicated by <code>e</code> (the exponent).</p>
</blockquote>
<pre><code class="language-js">console.log(2 ** 3); // =&gt; (2 * 2 * 2) result: 8</code></pre>
<h3 id="modulo">Modulo</h3>
<blockquote>
<p><strong>Modulo (%)</strong> is the remainder operator. </p>
</blockquote>
<pre><code class="language-js">// 4 / 2 = 2
console.log(4 / 2);
//With a remainder of 0
console.log(4 % 2);

// 7 / 2 = 3.5
console.log(7 / 2);
//With a remainder of 1
console.log(7 % 2);

// If a number modulus other number is equal to 0
// it is a multiple of &quot;other number&quot;

// 8 is indeed a multiple of 2!
console.log(8 % 2 === 0);
// 9 is NOT a multiple of 2!
console.log(9 % 2 === 0);</code></pre>
<h3 id="assignment-operators-table">Assignment Operators Table</h3>
<p><img src="https://images.velog.io/images/tak_4242/post/24230f36-3253-49f4-b0be-0f3dcbac57f8/image.png" alt=""></p>
<h3 id="operator-precedence">Operator Precedence</h3>
<p>In mathematics and computer programming, the order of operations (or operator precedence) is a collection of rules that define which procedures <strong>to perform first to evaluate a given mathematical expression.</strong></p>
<p><img src="https://images.velog.io/images/tak_4242/post/3d857f3b-82f9-4dff-a399-0f7508d8721a/image.png" alt=""></p>
<pre><code class="language-js">const i = 10 + (5 * 2 ** 3) / 4 - 6;
//  === 10 + 5 * 8 / 4 - 6 &lt;== start with the exponents (2 ** 3)
//  === 10 + 5 * 2 - 6 &lt;== then multiplication (5 * 8)
//  === 10 + 10 - 6 &lt;== then division (40 / 4)
//  === 10 + 4 &lt;== then addition (10 + 10 )
//  ==&gt; 14 &lt;== and finally finish with subtraction (20 - 6)</code></pre>
<p><img src="https://images.velog.io/images/tak_4242/post/ece89f4c-a14f-40c3-8d3f-45bceebb60fc/image.png" alt=""></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Exam_rang02] Inter]]></title>
            <link>https://velog.io/@tak_4242/Examrang02-Inter</link>
            <guid>https://velog.io/@tak_4242/Examrang02-Inter</guid>
            <pubDate>Sat, 24 Jul 2021 13:21:29 GMT</pubDate>
            <description><![CDATA[<h3 id="💡--inter-subject-이해">💡  Inter Subject 이해</h3>
<ul>
<li>Inter은 <code>.\a.out</code>을 제외한 첫번째 argument와 두번째 argument 안에서 확인되는 같은 글자를 출력한다. </li>
<li>첫번째 argument와 두번째 argument에서의  중복되는 글자는 무시한다.
(예시: <code>ddd</code>, <code>fffffddfdfdfd</code>)</li>
</ul>
<pre><code>.\a.out &quot;first_argument&quot;, &quot;second_argument&quot;</code></pre><pre><code>Assignment name  : inter
Expected files   : inter.c
Allowed functions: write
--------------------------------------------------------------------------------

Write a program that takes two strings and displays, without doubles, the
characters that appear in both strings, in the order they appear in the first
one.

The display will be followed by a \n.

If the number of arguments is not 2, the program displays \n.

Examples:

$&gt;./inter &quot;padinton&quot; &quot;paqefwtdjetyiytjneytjoeyjnejeyj&quot; | cat -e
padinto$
$&gt;./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
df6ewg4$
$&gt;./inter &quot;rien&quot; &quot;cette phrase ne cache rien&quot; | cat -e
rien$
$&gt;./inter | cat -e
$</code></pre><h3 id="💡inter-함수-구현방식">💡Inter 함수 구현방식</h3>
<ul>
<li><code>int i</code>는 첫번째 argument안을 커서처럼 움직일 예정이다.</li>
<li><code>int j</code>는 두번째 argument안을 커서처럼 움직일 예정이다.</li>
<li><code>static int tab[256]</code> : (union subject과 같이) ascii 테이블을 <code>static int tab[256]</code> static 으로 사용해 줌으로써, default 값을 0으로 하여, 0으로 테이블을 채웠다. </li>
</ul>
<ul>
<li>첫번째 argument와 두번째 argument의 요소가 일치하는지 알아볼 것이며, 만약 그렇다면
<code>if (tab[(int)av[1][i]])</code>안에 들어간다.</li>
<li><code>tab[(int)av[1][i]] == 0</code> : tab을 이용하여, argument의 문자를 하나하나씩 확인하는 과정이다.(0 =switch off)</li>
<li>만약, 첫번째 argument과 두번째 argument에서 동일한 글자를 찾았을경우,
<code>tab[(int)av[1][i]] = 1</code>  table에 1을 써주고 (1 = switch on) 을 써주고 if loop 을 나온다.
<code>j++</code> 와 <code>i++</code>를 해주면서, 상기와 같은 방법으로 계속 테스트 해준뒤, while loop을 나온다. </li>
</ul>
<pre><code class="language-c">if (av[1][i] == av[2][j])
{
    if (tab[(int)av[1][i]] == 0)
    {
           write(1, &amp;av[1][i], 1);
       tab[(int)av[1][i]] = 1;
    }
}</code></pre>
<blockquote>
<p> 💡  *<em>table 원리 이해 방법  (switch off/on) *</em>
즉, 256개의 table 안에 0으로 꽉 차있는데 (switch off 상태), 첫번째 argument과 두번째 argument에 동시에 나타나는 문자를 1로 써주면서 table을 switch on 상태로 만들어준 뒤, 최종적으로 switch on 에 해당하는 문자들을 출력하여 리턴한다.   </p>
</blockquote>
<h3 id="💡inter-함수-구현">💡Inter 함수 구현</h3>
<pre><code class="language-c">#include &lt;unistd.h&gt;

int    main(int ac, char *av[])
{
    int            i;
    int            j;
    static int    tab[256];

    if (ac == 3)
    {
        i = 0;
        while (av[1][i])
        {
            j = 0;
            while (av[2][j])
            {
                if (av[1][i] == av[2][j])
                {
                    if (tab[(int)av[1][i]] == 0)
                    {
                        write(1, &amp;av[1][i], 1);
                        tab[(int)av[1][i]] = 1;
                    }
                }
                j++;
            }
            i++;
        }
    }
    write(1, &quot;\n&quot;, 1);
    return (0);
}
</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Exam_rang02] Union]]></title>
            <link>https://velog.io/@tak_4242/Examrang02-Union</link>
            <guid>https://velog.io/@tak_4242/Examrang02-Union</guid>
            <pubDate>Thu, 22 Jul 2021 11:54:41 GMT</pubDate>
            <description><![CDATA[<p>Ecole42에 입학한 이후에 처음으로 시험을 치게 되는데, 시험 대비를 하면서 코딩 과정을 정리해보았다. 참고로, 시험을 칠 때는 norminette을 생각하지 않아도 된다. </p>
<h2 id="union-subject-이해">Union Subject 이해</h2>
<ul>
<li>Union은, <code>.\a.out</code> 을 제외한 첫번째 argument의 글자를 출력하고, 첫번째 argument 안에 반복되는 문자가 있으면 반복하지 않는다.</li>
<li>첫번째 argument에 없는 문자가 두번째 argument에 있다면, 그 문자를 함께 출력한다. </li>
<li>문제와 예시는 하기와 같다. </li>
</ul>
<pre><code>.\a.out &quot;first_argument&quot;, &quot;second_argument&quot;</code></pre><pre><code>Assignment name  : union
Expected files   : union.c
Allowed functions: write
--------------------------------------------------------------------------------

Write a program that takes two strings and displays, without doubles, the
characters that appear in either one of the strings.

The display will be in the order characters appear in the command line, and
will be followed by a \n.

If the number of arguments is not 2, the program displays \n.

Example:

$&gt;./union zpadinton &quot;paqefwtdjetyiytjneytjoeyjnejeyj&quot; | cat -e
zpadintoqefwjy$
$&gt;./union ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
df6vewg4thras$
$&gt;./union &quot;rien&quot; &quot;cette phrase ne cache rien&quot; | cat -e
rienct phas$
$&gt;./union | cat -e
$
$&gt;
$&gt;./union &quot;rien&quot; | cat -e
$
$&gt;</code></pre><h2 id="union-코딩-단계">Union 코딩 단계</h2>
<h2 id="1-intro-argument들을-연결하기">1. [Intro] argument들을 연결하기</h2>
<ul>
<li><p>결국, 두 문자열을 출력해야 하는 것이기 때문에, <code>./a.out</code> 을 제외한 첫번째 argument와 두번째 argument을 연결하여, 함수 구현을 통하여 어떻게 접근해야 하는지 생각해보았다.</p>
</li>
<li><p>프로그램을 작성해야 하는것이기 때문에, main 함수에 직접 <code>int ac, char *av[]</code>를 넣어 함수를 구현 하기로 하였다. </p>
</li>
</ul>
<pre><code class="language-c">#include &lt;unistd.h&gt;

int main(int ac, char*av[])
{
    int    i;

    if (ac == 3)
    {
        i = 0; //==&gt; 첫번째 함수를 읽고 출력한다.
        while (av[1][i])
        {
            write(1, &amp;av[1][i],1);
            i++;
        }
        i = 0; // ==&gt; 두번째 함수를 읽고 출력하며, 라인을 줄이기 위해 다시 i=0 함으로써, 두번째 함수를 읽고 출력한다.
        while (av[2][i])
        {
            write(1, &amp;av[2][i], 1);
            i++;
        }
    }
    write(1, &quot;\n&quot;, 1);
    return (0);
}</code></pre>
<h2 id="2-process-tab을-이용하여-union-함수-구현">2. [Process] tab을 이용하여 union 함수 구현</h2>
<h3 id="💡-함수-구현을-위한-기본-개념">💡 함수 구현을 위한 기본 개념</h3>
<ul>
<li><p><code>static variables</code> 은 해당 파일내에서의 함수내에서만 호출되고 쓰인다는 용도도 있으며, 항상 default 값으로 0 을 가진다. </p>
</li>
<li><p><strong>Static</strong> : If your array is declared as static or is global, all the elements in <strong>the array already have default value 0.</strong></p>
</li>
</ul>
<ul>
<li><code>static int tab[256]</code>은 256개의 아스키 문자를 담은 tab이며, default 이므로 tab안은 0만이 존재한다.  </li>
</ul>
<blockquote>
<p>❗️❗️❗️ 하기 두개는 완전히 다른 개념이다. ❗️❗️❗️
<code>static int tab[256]</code> ==&gt;  tab안에 있는 값들은 모두 0 이다.
<code>int tab[256] ={0}</code>  ==&gt; tab[256] 안의 첫 값은 0 으로 시작한다.</p>
</blockquote>
<blockquote>
<ul>
<li><strong>💡 ascii 문자의 총 개수가 256인 이유?</strong>
<strong>ascii</strong> is a user-written package, developed by Adrian Mande that merely returns numbers of ASCII characters in SMCL markup language. ASCII (pronunced /askee/), abbreviated from <strong>&quot;American Standard Code for Information Interchange&quot;</strong> which is a is a character-encoding scheme. The complete list of ascii table is printed below.</li>
</ul>
</blockquote>
<p><img src="https://images.velog.io/images/tak_4242/post/0cd9553f-416d-4179-88a9-125d31d75cc0/image.png" alt=""></p>
<h3 id="💡-함수-로직">💡 함수 로직</h3>
<p>간단히 말하면, 출력가능한 문자의 아스키 코드를 <code>static int tab[256]</code>( default 값: 0) 안에 담고, 조건에 해당하는 문자를 발견했으면, 0 을 1로 바꾸고, 이미 1로 바꾼 문자가 다시 나오면, 0으로 남겨두고 argument이 끝날때 까지 while loop을 통하여 반복한다. </p>
<ul>
<li><code>static int tab[256]</code>  이미 tab 안에는 256개의 아스키 문자가 0으로 표시 되어 있다. </li>
<li><code>(tab[(int)av[1][i]] == 0)</code> : tab을 이용하여, argument의 문자를 하나하나씩 확인하는 과정이다. (on va tester le cas, quand le char n&#39;a pas encore été vu (=switch off)) 해당 문자가 보여지지 않았을경우, if loop안에 들어간다. </li>
<li><code>tab[(int)av[1][i]] = 1</code> 그리고 1 (= switch on) 을 써주고 if loop 을 나온다. </li>
<li><code>i++</code> 를 해주면서, 상기와 같은 방법으로 계속 테스트 해준다. </li>
<li>마찬 가지로 <code>av[2][i]</code>에 적용 시켜 준다. </li>
</ul>
<pre><code class="language-c">#include &lt;unistd.h&gt;

int    main(int ac, char*av[])
{
    int            i;
    static int    tab[256];

    if (ac == 3)
    {
        i = 0;
        while (av[1][i])
        {
            if (tab[(int)av[1][i]] == 0)
            {
                write(1, &amp;av[1][i], 1);
                tab[(int)av[1][i]] = 1;
            }
            i++;
        }
        i = 0;
        while (av[2][i])
        {
            if (tab[(int)av[2][i]] == 0)
            {
                write(1, &amp;av[2][i], 1);
                tab[(int)av[2][i]] = 1;
            }
            i++;
        }
    }
    write(1, &quot;\n&quot;, 1);
    return (0);
}</code></pre>
<h2 id="3-final-optimize-the-code">3. [Final] Optimize the code</h2>
<p>2번의 코드중에 반복되는 코드의 부분이 있어서, 반복되는 부분을 optimize 해주었다. </p>
<ul>
<li><code>int j = 1</code>를 2번 반복해주는 loop을 만들어주었다. <strong>Why?</strong>  <code>./a.out</code>을 제외한 first argument와 second argument의 문자열을 각각 확인해줘야 하므로. </li>
</ul>
<pre><code class="language-c">#include &lt;unistd.h&gt;

int    main(int ac, char*av[])
{
    int            i;
    int            j;
    static int    tab[256];

    if (ac == 3)
    {
        j = 1;
        while (j &lt;= 2)
        {
            i = 0;
            while (av[j][i])
            {
                if (tab[(int)av[j][i]] == 0)
                {
                    write(1, &amp;av[j][i], 1);
                    tab[(int)av[j][i]] = 1;
                }
                i++;
            }
            j++;
        }
    }
    write(1, &quot;\n&quot;, 1);
    return (0);
}</code></pre>
<p>출처 : </p>
<ol>
<li>ascii code
<a href="http://www.haghish.com/statistics/stata-blog/stata-programming/ascii_characters_mobile.php">http://www.haghish.com/statistics/stata-blog/stata-programming/ascii_characters_mobile.php</a></li>
</ol>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ft_printf] 가변인자 ( variadic functions)]]></title>
            <link>https://velog.io/@tak_4242/ftprintf-%EA%B0%80%EB%B3%80%EC%9D%B8%EC%9E%90</link>
            <guid>https://velog.io/@tak_4242/ftprintf-%EA%B0%80%EB%B3%80%EC%9D%B8%EC%9E%90</guid>
            <pubDate>Wed, 21 Jul 2021 11:29:39 GMT</pubDate>
            <description><![CDATA[<h3 id="💡---가변인자-variadic-functions">💡   가변인자 (Variadic Functions)</h3>
<p>가변인자라는 개념이 생소하여, printf과제를 할때 생긴 첫 의문점은   &quot;ft_printf 과제를 수행하는데, <strong>가변인자가 무엇인지, 그리고 가변인자를 왜 알아야 하는가?</strong>&quot; 이었다. </p>
<ul>
<li><p>printf 함수는 인자를 1개만 넣어도 작동하고, 2개를 넣어도 작동하고, 3개,4개 혹은 그 이상을 넣어도 잘만 작동한다. *<em>여러개의 인자를 넣어도 함수가 작동하도록 가능하게 하는 인자를 가변 인자라고 한다. *</em></p>
</li>
<li><p>printf, scanf처럼, 매개변수의 개수가 정해지지 않은 함수가 있으며, *<em>함수에 들어가는 인자(argument)의 개수가 변하는것을 가변인자 (가변인수, variable argument)라고 함. *</em></p>
</li>
<li><p>함수에서 가변인자를 정의할때는 고정 매개 변수가 한개 이상 있어야하며, 고정 매개변수 뒤에 <code>...</code>을 붙여 매개변수의 개수가 정해지지 않았다는 표시를 해준다. 단, <code>...</code> 뒤에는 다른 매개변수를 지정할 수 없다.  </p>
</li>
<li><p>printf 함수의 원형은 하기와 같다. </p>
<pre><code class="language-c">printf format [arguments, ...]</code></pre>
</li>
</ul>
<h3 id="💡-가변-인자-함수-만들기-variable-argument-lists">💡 가변 인자 함수 만들기 variable argument lists</h3>
<p><strong>#include &lt;stdarg.h&gt;</strong></p>
<p>The called function must declare an object of type <em>va_list</em> which is used by the macros *<em>va_start(), va_arg(), and va_end(). *</em></p>
<p> <code>va_list ap</code>: 가변인자 목록 포인터. 가변인자의 메모리 주소를 저장하는 포인터</p>
<ul>
<li>ap (argument pointer)</li>
</ul>
<p><code>va_start(ap, args)</code>: 가변인자를 가져올 수 있도록 포인터를 설정.</p>
<ul>
<li>va_arg()을 사용하기 전에 va_start로 ap(arguemt pointer)를 declare 해줘야 한다.<br>The <strong>va_start()</strong> macro initializes <strong>ap</strong> for subsequent use by <strong>va_arg()</strong> and <strong>va_end(),</strong> and must be called first.</li>
</ul>
<p><code>va_arg (ap, type)</code> : 가변인자 포인터에서 특정 자료형 크기만큼 값을 가져옴.</p>
<ul>
<li>va_arg() 매크로를 부를때마다, ap는 next argument로 움직인다. </li>
<li>The argument <strong>ap</strong> is the <strong>va_list ap *<em>initialized by *</em>va_start()</strong>. Each call to <strong>va_arg() *<em>modifies *</em>ap</strong> so that the next call returns the next argument. </li>
<li>💡 <code>ap</code> 가변인자 포인터 타입에 따라, type에 <code>int</code> , <code>char *</code> 등을 넣어준다. 💡 </li>
</ul>
<p><code>va_end(ap)</code> : 가변인자 처리가 끝났을때 포인터를 NULL로 초기화.</p>
<h3 id="✏️-void-함수로-만드는법">✏️ void 함수로 만드는법</h3>
<ul>
<li>void 함수로 만들때는, void 함수 안에 <code>printf()</code>를 넣어 줌으로써, main함수에는 반환값 자료형 함수이름만을 호출하도록 하였다. </li>
</ul>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdarg.h&gt; // va_list, va_start, va_arg, va_end 가 정의된 헤더파일

// void function으로, printf를 포함하여  variadic function을 만드는  방법
void printNumbers(int args, ...) // 가변 인자의 개수를 받음, ...로 가변 인자 설정
{
    va_list ap; // 가변 인자 목록 포인터 (ap : argument pointer)

    va_start(ap, args); // 가변 인자 목록 포인터 설정
    for (int i = 0; i &lt; args ; i++) //args 가변 인자 개수 만큼 반복
    {
        int num = va_arg(ap, int); // int 크기만큼 가변 인자 목록 포인터에서 값을 가져옴, ap를 int 크기만큼 순방향으로 이동
        printf(&quot;%d&quot;, num); // 가변 인자 값 출력
    }
    va_end(ap); // 가변 인자 목록 포인터를 NULL로 초기화
    printf(&quot;\n&quot;); // 줄바꿈
}

int main(void)
{
    printNumbers(1, 10);
    printNumbers(2, 10, 20);
    printNumbers(3, 10, 20, 30);
    printNumbers(4, 10, 20, 30, 40);
    return (0);
}</code></pre>
<h3 id="🔨-실행결과">🔨 실행결과</h3>
<pre><code class="language-c">10
10 20
10 20 30
10 20 30 40 </code></pre>
<h3 id="💡-가변-인자-step-by-step">💡 가변 인자 step by step</h3>
<h3 id="step-1">step 1.</h3>
<pre><code class="language-c">va_list ap; // 가변 인자 목록 포인터
va_start(ap, args); // 가변 인자 목록 포인터 설정 </code></pre>
<p><strong>va_start로 ap준비  (ap 는 argument pointer)</strong></p>
<p><img src="https://images.velog.io/images/tak_4242/post/4450f0f0-7af4-4a9f-b6a5-c9877f281da0/image.png" alt=""></p>
<h3 id="step-2">step 2.</h3>
<p>이제 반복문으로 가변 인자 개수만큼 반복하면서  va_arg 매크로로 값을 가져오면 된다. 
이때 va_arg에는 가변 인자의 자료형을 지정해 준다.</p>
<pre><code class="language-c">for(int i = 0; i &lt; args; i++)  // 가변 인자 개수만큼 반복
{    
    int num = va_arg(ap, int); // int 크기만큼 가변 인자 목록 포인터에서 값을 가져옴.
                      // ap를 int 크기만큼 순방향으로 이동
        printf(&quot;%d&quot;, num);    // 가변 인자 값 출력 
}</code></pre>
<p><code>int num = va_arg(ap, int)</code>를 실행하면 현재 ap에서 4바이트 (int 크기)만큼 역참조하여 값을 가져온 뒤 ap를 4바이트만큼 순 방향으로 이동 시킨다. </p>
<p>va_arg로 ap에서 값을 가져온 뒤 포인터 이동.
즉, 반복문에서 반복할 때마다 ap는 4 바이트만큼 순방향으로 이동하므로 10, 20, 30, 40을 순서대로 가져올 수 있다. </p>
<p><img src="https://images.velog.io/images/tak_4242/post/8b969451-8403-4e61-aafe-79f5a4e291c5/image.png" alt=""></p>
<h3 id="step-3">step 3.</h3>
<p>마지막으로 <code>va_end</code> 매크로를 사용하여 ap를 null로 초기화한다.
(다른 플랫폼에서는 문제가 생길 수도 있으므로 호환성을 위해서 <code>va_end</code>로 마무리를 해주는것이 좋다.)</p>
<p><code>va_end(ap)</code> 가변 인자 목록 포인터를 null로 초기화</p>
<h3 id="✏️---int-함수로-만드는법">✏️   int 함수로 만드는법</h3>
<ul>
<li><code>addNumbers(int args, ...)</code> : 각각의 가변인자를 더해주는 함수</li>
<li><code>minNumbers(int args, ...)</code>: 각각의 가변인자를 <code>-</code>하여 더해주는 함수</li>
</ul>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdarg.h&gt;

int    addNumbers(int args, ...)
{
    va_list ap;
    int i;
    int sum = 0;
    va_start(ap, args);
    for(i = 0; i &lt; args ; i++)
        sum+= va_arg(ap, int);
    va_end(ap);
    return (sum);
}


int minNumbers(int args, ...)
{
    va_list ap; 
    int i;
    int min = 0;

    va_start(ap, args);
    for (i = 0; i &lt; args; i++)
        min-= va_arg(ap, int);
    va_end(ap);
    return (min);
}

int main(void)
{
    printf(&quot;the sum is : %d\n&quot;, addNumbers(3, 100, 200, 300));
    printf(&quot;the minus is :%d\n&quot;, minNumbers(3, 1, 2, 3));
    return (0);
}</code></pre>
<h3 id="🔨-실행결과-1">🔨 실행결과</h3>
<pre><code>the sum is: 600
the minus is : -6</code></pre><blockquote>
<p>💡 Lessons learned </p>
</blockquote>
<ul>
<li>가변인자란 무엇인지. </li>
<li>가변함수가 어떻게 쓰이는지.</li>
</ul>
<p>참고 출처 : </p>
<p><a href="http://seyong.me/study/printf_sapjil/">http://seyong.me/study/printf_sapjil/</a>
<a href="https://42kchoi.tistory.com/13">https://42kchoi.tistory.com/13</a>
<a href="https://dojang.io/mod/page/view.php?id=577">https://dojang.io/mod/page/view.php?id=577</a>
<a href="https://linux.die.net/man/3/va_arg">https://linux.die.net/man/3/va_arg</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ft_printf] subject와 printf 함수 이해 ]]></title>
            <link>https://velog.io/@tak_4242/ftprintf-subject-%EC%9D%B4%ED%95%B4%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@tak_4242/ftprintf-subject-%EC%9D%B4%ED%95%B4%ED%95%98%EA%B8%B0</guid>
            <pubDate>Mon, 19 Jul 2021 16:12:47 GMT</pubDate>
            <description><![CDATA[<h2 id="💡printf-함수란-">💡printf 함수란 ?</h2>
<h3 id="printf-함수의-원형">printf 함수의 원형</h3>
<p><code>int printf(const char *format, ...)</code></p>
<ul>
<li>printf 첫번째 입력 매개변수  <code>const char *</code> </li>
<li>printf 두번째 입력 매개변수 <code>...</code> :  가변인자. printf는 매개변수의 개수가 정해지지 않는다. 즉 여러개의 인자를 넣어도 함수가 작동한다. </li>
<li><em>❗️❗️❗️ printf 반환값은 : <code>int</code>다 ❗️❗️❗️ *</em></li>
</ul>
<h3 id="printf-출력-방식">printf 출력 방식</h3>
<ul>
<li><p>printf의 첫번째 인자: 어떤 형태로 출력할것인지 표현함.
예시) <code>%d, %s, %c</code> (정수, 문자열, 문자.. )</p>
</li>
<li><p>printf 두번째 인자: 출력할 데이터들이 옴. </p>
</li>
</ul>
<p><strong>printf 함수 원리</strong></p>
<pre><code class="language-c">int main(void)
{
    int re;

    re = printf(&quot;hi%d\n&quot;, 123); // ==&gt; hi123
    printf(&quot;re: %d \n&quot;, re); // ==&gt; re: 6
    return (0);
}</code></pre>
<p>*<em>실행 결과 *</em></p>
<pre><code class="language-c">hi123
re: 6</code></pre>
<ul>
<li>위 예제를 보면 <code>hi123</code> [개행문자] 를 출력한 뒤에 반환값 <code>6</code>을 다시 출력 하고 있다. - printf 함수는 출력한 문자의 개수를 반환하는데 공백이나 탭, 개행문자(엔터)도 하나의 문자로 취급한다.</li>
<li>따라서, 실제 출력한 문자 개수는 6개 이며, <strong>printf함수의 결과값으로 6 (int, 정수)을 반환받음</strong>을 알 수 있다. </li>
<li>printf 함수의 반환 값은 출력되는 문자의 개수이다. 출력되는 문자의 개수는 공백( )과 이스케이프 시퀀스인 개행(\n), 가로 탭(\t) 등을 포함한다.</li>
</ul>
<h2 id="ft_printf--문제-이해하기">ft_printf  문제 이해하기</h2>
<p>Write a library that contains ft_printf, a function that will mimic the real printf. </p>
<h2 id="mandatory-part">Mandatory part</h2>
<p><img src="https://images.velog.io/images/tak_4242/post/cc112513-addc-4af4-957a-0bc7f033b3a6/image.png" alt=""></p>
<ul>
<li><p>prototype of <strong>ft_printf:</strong></p>
<pre><code class="language-c">int ft_printf(const char*, ...)</code></pre>
</li>
<li><p>You have to recode the <strong>libc&#39;s printf function</strong></p>
</li>
<li><p>It must not do the buffer management like the real <strong>printf</strong></p>
</li>
<li><p>It will manage the following conversions: <strong>cspdiuxX%</strong></p>
</li>
<li><p>It will be compared with the real <strong>printf</strong></p>
</li>
<li><p>You must use the command <strong>ar</strong> to cerate your library, using the command libtool is forbidden.</p>
</li>
</ul>
<ul>
<li>%c  : 문자 (character)  출력</li>
<li>%s  : 문자열 (string) 출력</li>
<li>%p  : void* 포인터를 hexadecimal로 출력</li>
<li>%d  : decimal (base 10) 숫자를 출력</li>
<li>%i  : integer (base 10) 숫자를 출력</li>
<li>%u  : unsigned decimal (base 10) 10진수 정수를 출력</li>
<li>%x  : hexadecimal (base 16) 숫자를 출력, 알파벳은 소문자로 표현</li>
<li>%%  : 퍼센트 사인을 출력.</li>
</ul>
<pre><code class="language-c">// 다양한 포멧을 지정하여 출력

#include &lt;stdio.h&gt;

int main(void)
{
    printf(&quot;============cspdiuxX퍼센트=========\n&quot;);
    printf(&quot;1.c 문자 출력 : %c\n&quot;, &#39;a&#39;);
    printf(&quot;2.s 문자열 출력: %s\n&quot;, &quot;Hello World&quot;);
    printf(&quot;3.p 메모리 주소 출력: %p\n&quot;, &quot;Hi&quot;);
    printf(&quot;4.d 십진수로 출력: %d\n&quot;, 123);
    printf(&quot;5.i 부호있는 십진수로 출력: %i\n&quot;, 123);
    printf(&quot;6.u 부호없는 십진수로 출력: %u\n&quot;, 123);
    printf(&quot;7.x 부호없는 16진수로 출력(소문자): %x\n&quot;,123);
      printf(&quot;8.X 부호없는 16진수로 출력(대문자): %X\n&quot;, 123);
    printf(&quot;9.퍼센트 문자 출력: %%\n&quot;);
    return (0);
}</code></pre>
<h3 id="출력-결과">출력 결과</h3>
<pre><code class="language-c">============cspdiuxX퍼센트=========
1.c 문자 출력 : a
2.s 문자열 출력: Hello World
3.p 메모리 주소 출력: 0x10a925eb9
4.d 십진수로 출력: 123
5.i 부호있는 십진수로 출력: 123
6.u 부호없는 십진수로 출력: 123
7.x 부호없는 16진수로 출력(소문자): 7b
8.X 부호없는 16진수로 출력(대문자): 7B
9.퍼센트 문자 출력: %</code></pre>
<blockquote>
<p> <strong>16진수(16진법)이란?</strong> 
16진법이란, 0<del>9 까지의 10개의 숫자를 사용하고 남는 자리는 A</del>F 까지 6개의 문자를 사용해서 수를 표현한다.</p>
</blockquote>
<h2 id="bonus-part">Bonus part</h2>
<ul>
<li>Manage any combination of the following flags: ’-0.’ and minimum field width with all conversions</li>
</ul>
<ul>
<li>&#39;#&#39;, &#39;+&#39; : Manage all the following flages (yes, one of them is a space). </li>
</ul>
<h3 id="the-zero-flag--0">The Zero flag : 0</h3>
<p>Using <code>0</code> will force the number to be padded with 0s. This only really matters if you use the width settin to ask for minimal width for your number. </p>
<p><code>printf( &quot;%05d\n&quot;, 10 );</code></p>
<p>출력결과 : <code>00010</code></p>
<p>출처 : </p>
<ol>
<li>printf 함수의 기능
<a href="https://ehpub.co.kr/24-printf-%ED%95%A8%EC%88%98/">https://ehpub.co.kr/24-printf-%ED%95%A8%EC%88%98/</a></li>
<li>16진수
<a href="https://itbeginner2020.tistory.com/17">https://itbeginner2020.tistory.com/17</a></li>
<li>Printf definition 
<a href="https://www.cypress.com/file/54441/download">https://www.cypress.com/file/54441/download</a>
<a href="https://www.cprogramming.com/tutorial/printf-format-strings.html">https://www.cprogramming.com/tutorial/printf-format-strings.html</a></li>
</ol>
]]></description>
        </item>
        <item>
            <title><![CDATA[[JavaScript] Variables]]></title>
            <link>https://velog.io/@tak_4242/JavaScript-Variables</link>
            <guid>https://velog.io/@tak_4242/JavaScript-Variables</guid>
            <pubDate>Mon, 19 Jul 2021 09:33:47 GMT</pubDate>
            <description><![CDATA[<h2 id="what-is-a-variable">What is a variable?</h2>
<p>Let&#39;s start with an example from real life. 
You decided to pack all your stuff into different boxes and place them into some storage. You put labels on each box so you can easier find it later, and obviously, the name is descrptive, so you know what is in that box. </p>
<p>Analogy: </p>
<ul>
<li>Storage is the memory,</li>
<li>the box is the variable, </li>
<li>the box lbel is the variable&#39;s name,</li>
<li>the box content is the variable&#39;s value. </li>
</ul>
<p><img src="https://images.velog.io/images/tak_4242/post/35bcdf96-ff50-47e2-a9f0-0afac5e7992d/image.png" alt=""></p>
<blockquote>
<p>The main purpose of <strong>variable</strong> is to <strong>store some information</strong> in them. These variables are <strong>labeled</strong> so whenever we need the information inside we can easily access them. A very common way of saying - access to variable - is *<em>reference a variable by its name. *</em></p>
</blockquote>
<h2 id="variable-declaration-and-initialization">Variable declaration and initialization</h2>
<h3 id="variable-declaration">Variable declaration</h3>
<ul>
<li>Creating a variable and giving it a name is the first step of variable declaration. </li>
<li>Variable declartion is the act of just creating and labeling an empty box that will later be filled with some information (its value). </li>
</ul>
<blockquote>
<p>To declare of define a variable, we can use the keyword <code>let</code> or <code>const</code> and <code>var</code> (in oler version of js). </p>
</blockquote>
<h3 id="variable-declaration-with-let">Variable declaration with <code>let</code></h3>
<ul>
<li><strong>Variable declaration</strong> : We put the name/label on the boxes. The value/information will be added to it later. </li>
</ul>
<pre><code class="language-js">let age; // &lt;== this is a variable declaration </code></pre>
<pre><code class="language-js">let name, email, address; // &lt;== even able to decalre multiple variables in the same line while separating them with a comma. </code></pre>
<h3 id="variable-initialization-with-let">Variable initialization with <code>let</code></h3>
<ul>
<li><p>After we declared a variable, the next step is to store some value in it. This process is called <strong>Variable initialization</strong></p>
</li>
<li><p>To put some data into the variablem we use the <code>assignment operator =</code>.</p>
</li>
</ul>
<pre><code class="language-js">let name; // &lt;== this is a variable declaration
name = &#39;Hello&#39;; // &lt;== this is a variable initialization</code></pre>
<h3 id="variable-declaration-with-const">Variable declaration with <code>const</code></h3>
<p><code>const</code> is used when declaring a variable in which the value will be <strong>constant</strong></p>
<ul>
<li>this means that the value we assigned to a variable won&#39;t ever change (in the case of strings, numbers, booleans). </li>
</ul>
<pre><code class="language-js">const name = &#39;Lina&#39;;
name = &#39;Maria&#39;;

// console:
// unknown: &quot;name&quot; is read-only</code></pre>
<blockquote>
<p>To summarize, we can use <code>let</code> when we expect that the variable will change its value. However, use <code>const</code> when you’re sure that the type of the variable will remain unchanged.</p>
</blockquote>
<h3 id="naming-a-variable">Naming a variable</h3>
<p>A <strong>name</strong> is simply a reference for a variable. </p>
<pre><code class="language-js">let companyName = &#39;Apple&#39;;
let age = 3;</code></pre>
<h4 id="variable-value">Variable value</h4>
<ul>
<li>A value can be any of the JavaScript value types: <code>String</code>, <code>number</code>, <code>array</code>, <code>object</code>, etc. </li>
</ul>
<blockquote>
<h4 id="naming-rules">Naming Rules</h4>
</blockquote>
<ol>
<li>Names can contain letters (uppercase and lowercase), numbers, and the symbols _ and $.</li>
<li>The first character of the name can’t be a number.</li>
<li>When creating a variable with more than one word, we use the &quot;<strong>camelCase</strong>&quot; style. </li>
<li>Although we said you could use any English or non-English word, still there’s a bit constraint: there are some reserved keywords that can’t be used, for example: let, class, return, and function are reserved.<pre><code class="language-js">let let = &#39;hello&#39;; // &lt;== error, you can&#39;t name variable &quot;let&quot;</code></pre>
</li>
</ol>
<h4 id="changing-values">Changing Values</h4>
<p>The value of a variable declared with let can be changed whenever you want. 
To change a value, we juste need to reference the variable by its name and assign a new value: </p>
<pre><code class="language-js">let favoriteFood;
favoriteFood = &quot;Steak&quot;;
console.log(favoriteFood); // &lt;== &quot;Steak&quot;

favoriteFood = &quot;Burger&quot;;
console.log(favoriteFood); // &lt;== &quot;Burger&quot;</code></pre>
<p><strong>Basic(primitive) data types in JavaScript:</strong></p>
<ul>
<li>string,</li>
<li>number,</li>
<li>boolean (True / False)</li>
</ul>
<p><strong>Non-primitive data types:</strong></p>
<ul>
<li>object,</li>
<li>array. </li>
</ul>
<p>To see what is the data type of any variable, you can use the JavaScript operator, <code>typeof</code></p>
<pre><code class="language-js">let favoriteFood;

favoriteFood = &#39;Steak&#39;;
console.log(&#39;Value: &#39;, favoriteFood, &#39; Type: &#39;, typeof favoriteFood);

favoriteFood = 20;
console.log(&#39;Value: &#39;, favoriteFood, &#39; Type: &#39;, typeof favoriteFood);

// console:
// Value:  Steak  Type:  string
// Value:  20     Type:  number</code></pre>
<blockquote>
<p>💡💡 REMEMBER 💡💡</p>
</blockquote>
<ul>
<li>You can only reassign the variable and changes its value and type if you use <code>let</code> when declaring a variable.</li>
<li>To help yourself and others who work or will work on the same code, try to use <code>cosnt</code> whenever there is a chance to do so. </li>
</ul>
<h3 id="important-naming-rules">Important naming rules</h3>
<p>Naming variables is hard, and it is, in fact, one of the hardest in programming. You should try yourbest to name variables in a meaningful way. </p>
<p>Variable names like i, j, k, (some exceptions to these), something, object, or variable do not give any indication as to what the value of that variable is. <strong>You are more than likely not going to be the only person reading your code.</strong></p>
<p>Wrong naming rules 😟</p>
<pre><code class="language-js">let x, y, z, zz;

x = 1;
y = 2;
z = (x + y) / 2;
zz = &quot;The average of two numbers is &quot; + z;
console.log(zz); </code></pre>
<p>Good naming rules 😁</p>
<pre><code class="language-js">var firstNum, secondNum, average, message;

firstNum = 1;
secondNum = 2;
average = (firstNum + secondNum) / 2;
message = &quot;The average of the two numbers is &quot; + average;
console.log(message);</code></pre>
<blockquote>
<p>Lessons learned 🎉</p>
</blockquote>
<ul>
<li>what a variable is,</li>
<li>how to declare variables,</li>
<li>how to name variables correctly.</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[JavaScript] Introduction and syntax]]></title>
            <link>https://velog.io/@tak_4242/Java-Script-Introduction-and-syntax</link>
            <guid>https://velog.io/@tak_4242/Java-Script-Introduction-and-syntax</guid>
            <pubDate>Mon, 19 Jul 2021 08:55:53 GMT</pubDate>
            <description><![CDATA[<h3 id="what-is-javascript">What is JavaScript?</h3>
<ul>
<li>JavaScript is an object oriented and dynamic programming language created in 1995. </li>
<li>In the frontend, JavaScript is what adds the interactivity and allows you to create a variety of features for your apps.</li>
<li>In the backend, JavaScript is what makes it possible to define logic and develop each app&#39;s functionality. </li>
</ul>
<h3 id="basic-js-syntax">Basic JS Syntax</h3>
<blockquote>
<p>The Syntax of a programming language is the set of rules that needs to be respected by programmers (who write the code) to be successfully interpreted by machines (that execute that code). </p>
</blockquote>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Born2beroot] Main references]]></title>
            <link>https://velog.io/@tak_4242/Born2beroot-main-references</link>
            <guid>https://velog.io/@tak_4242/Born2beroot-main-references</guid>
            <pubDate>Wed, 14 Jul 2021 15:33:50 GMT</pubDate>
            <description><![CDATA[<h3 id="main-references">Main references</h3>
<h3 id="born2beroot-과제를-실천하면서-하기-사이트들애서-도움을-많이-받았습니다">Born2beroot 과제를 실천하면서 하기 사이트들애서 도움을 많이 받았습니다.</h3>
<h4 id="1-debian-설치">1. Debian 설치</h4>
<p>appti 님이 하나 하나 스크립 캡쳐를 해주셔서 debian 과 vm설치에 도움을 많이 받았습니다. </p>
<p><a href="https://velog.io/@appti/born2beroot-Virtualbox-Debian-%EC%84%A4%EC%B9%98">https://velog.io/@appti/born2beroot-Virtualbox-Debian-%EC%84%A4%EC%B9%98</a></p>
<h4 id="2-born2beroot-project">2. born2beroot project</h4>
<p>tbonelee 님이 상세하게 설명을 해주셔서, 프로젝트 과제를 참고하는데 도움이 많이 되었습니다.
과제를 실천할때 발생한 몇몇개의 오류를 dig 님이 수정해 주셔서, 참고 하였습니다.</p>
<p><a href="https://tbonelee.tistory.com/m/16">https://tbonelee.tistory.com/m/16</a>
<a href="https://blog.naver.com/digitalnomad00/222414374887">https://blog.naver.com/digitalnomad00/222414374887</a></p>
<h4 id="3-lighttpd-php-mariadb-설치">3. lighttpd, php, mariadb 설치</h4>
<p><a href="https://nostressdev.tistory.com/11">https://nostressdev.tistory.com/11</a>
<a href="https://www.howtoforge.com/how-to-install-lighttpd-with-php-and-mariadb-on-debian-10/">https://www.howtoforge.com/how-to-install-lighttpd-with-php-and-mariadb-on-debian-10/</a></p>
<h4 id="4-bonus-part">4. Bonus part</h4>
<ul>
<li>install wp on lighttp</li>
</ul>
<p><a href="https://www.how2shout.com/linux/install-wordpress-on-lighttpd-web-server-ubuntu/">https://www.how2shout.com/linux/install-wordpress-on-lighttpd-web-server-ubuntu/</a></p>
<ul>
<li>free service (mail set up)
<a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-debian-10">https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-debian-10</a></li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Born2beroot] Peer to peer evaluation ]]></title>
            <link>https://velog.io/@tak_4242/Born2beroot-peertopeer-evaluation</link>
            <guid>https://velog.io/@tak_4242/Born2beroot-peertopeer-evaluation</guid>
            <pubDate>Thu, 08 Jul 2021 13:58:55 GMT</pubDate>
            <description><![CDATA[<h2 id="project-overview">Project Overview</h2>
<h3 id="1-what-is-virtual-machine-vm">1. What is Virtual Machine (VM)?</h3>
<ul>
<li>실재하는 컴퓨터 상에 소프트웨어로 논리적으로 만들어낸 컴퓨터</li>
<li>하나의 물리자원(컴퓨터)위에 하나의 환경(OS)만 있는것을 효율화하고자 가상화 층을 만들고 그 위에 OS를 새로 설치하는 기법 (하나의 컴퓨터로 서로 다른 운영체제를 실행하고자 할때 소프트웨어로 하드웨어 기능을 시뮬레이션하여 실행한다.).</li>
<li>쉽게 말해, 현재 내가 쓰고 있는 컴퓨터의 OS가 윈도우인데, 이 컴퓨터에서 리눅스도 동시에 쓰고 싶다면 가상머신을 이용하면 된다. </li>
</ul>
<h3 id="2-choice-of-os-why-did-you-choose-debian">2. Choice of OS (why did you choose Debian)?</h3>
<ul>
<li>리눅스 초보 사용자에게는 접근하기 쉬운 Debian이 더 용이함. </li>
</ul>
<h3 id="3-centos-vs-debian">3. Centos vs Debian?</h3>
<h3 id="centos--community-enterprise-operating-system-">Centos ( Community Enterprise Operating System )</h3>
<ul>
<li>Red Hat이 공개한 RHEL (Red Hat Enterprise Linux) 을 그대로 가져와서 Red Hat의 브랜드와 로고만 제거하고 배포한 배포본. </li>
<li>무료로 사용 가능 하나, 문제 발생시 회사가 아닌 커뮤니티를 통해 지원이 되므로 패치가 느리다. </li>
<li>서버용 운영체제로 인기가 매우 높다. </li>
</ul>
<h3 id="debian">Debian</h3>
<ul>
<li>온라인 커뮤니티에서 제작하여 레드햇보다 더 먼저 배포되어 시장을 선점함. </li>
<li>무료 개인사용자 서버용으로 인기가 매우 높다. </li>
<li>넓은 유저층을 갖고 있는 데비안 계열은, 사용법이 온라인 웹사이트나 커뮤니티에 자세히 기술되어 있어 진입장벽이 낮아 초보 리눅스 유저들이 접근하기 쉬운 OS임. </li>
</ul>
<h3 id="4-debian---apt--aptitude--apparmor-">4. Debian - Apt / Aptitude / APPArmor ?</h3>
<h3 id="apt-vs-aptitude">Apt vs Aptitude</h3>
<h3 id="1-apt-low-level-패키지-매니저">1) Apt (low-level 패키지 매니저)</h3>
<ul>
<li>apt는 다른 하이레벨 패키지 매니저에 의해 사용될 수 있음.</li>
</ul>
<h3 id="2-aptitude-high-level-패키지-매니저">2) Aptitude (High-level 패키지 매니저)</h3>
<ul>
<li>aptitude는 사용하지 않는 패키지를 자동적으로 제거해준다. 반면 apt는 추가적 옵션이 필요함(ex. auto-remove) </li>
<li>aptitude는 why와 why-not 커맨드를 통해 특정 패키지를 설치할때 어떤것이 요구되고, 어떤것과 충돌하는지 확인할 수 있다. </li>
<li>설치, 제거,업데이트 과정에서 충돌이 있는 경우 다른 대안을 제시해줌. apt는 그냥 안된다고만 함. </li>
</ul>
<h3 id="3-apparmor">3) APPArmor</h3>
<p>앱아머는 정책파일을 통해 어떤 어플리케이션이 어떤 파일/경로에 접근 가능한지 허용해준다. enforce모드와 complain모드 두가지가 존재함.</p>
<ul>
<li>enforce모드 : 허가되지 않은 파일에 접근하는것을 거부하는 모드</li>
<li>complain모드 : 실질적으로 보안을 제공하는것은 아님. 대신 어플리케이션이 해야 할 행동이 아닌 다른 행동을 하는 경우에 앱아머는 로그를 남겨준다. </li>
</ul>
<p>Apparmor 확인 </p>
<pre><code class="language-c">$sudo aa-status</code></pre>
<blockquote>
<p>** AppArmor (Mandatory Access Control Framework)
**When enabled, AppArmor confines programs according to a set of rules that specify what files a given program can access. This proactive approach helps protect the system against both known and unknown vulnerabilities.</p>
</blockquote>
<h4 id="5-script-must-display-all-information-all-every-5-min">5. Script must display all information all every 5 min.</h4>
<pre><code class="language-c">crontab -e : script확인 및 수정가능</code></pre>
<blockquote>
<p>혹, crontab 수정 불가할시, monitoring.sh의 권한을 실행 및 작성 가능하도록 바꾼다. </p>
</blockquote>
<pre><code class="language-c">$sudo chmod 755 monitoring.sh</code></pre>
<p>주어진 주제에서는 10분마다  script가 display되도록 요구했다.</p>
<pre><code class="language-c">*/10 * * * */home/ytak/monitoring.sh | wall</code></pre>
<p> (defense중) 하기와 같이 5분마다 script가 display되도록 수정하면 된다. </p>
<pre><code class="language-c">*/5 * * * */home/ytak/monitoring.sh | wall </code></pre>
<blockquote>
<p><strong>Wall command in Linux</strong>
Wall command in Linux system is used to write a message to all users. This command displays a message, or the contents of a file, or otherwise its standard input, on the terminals of all currently logged in users.</p>
</blockquote>
<h3 id="simple-setup">Simple setup</h3>
<p><strong>1. Ensure that the machine does not have a graphical environment at launch. A password will be requested before attempting to connect to this machine. Connect with a user which is not a root.</strong></p>
<p><strong>2. Pay attention to the password chosen, it must follow the rules imposed in the subject :</strong></p>
<hr>
<p>*<em>Password policy
*</em></p>
<ul>
<li>Your password has to expire every 30days</li>
<li>The minimum number of days allowed before the modification of a password will be set to 2.</li>
<li>The user has to receive a warning message 7 days before their password expires.</li>
<li>Your password must be at least 10 characters long. It must contain an uppercase letter and a number. Also, it must not contain more than 3 consecutive identical characters</li>
<li>The password must not include the name of the user</li>
<li>The following rule does not apply to the root password. The password must have at least 7 characters that are not part of the former password.</li>
<li>Of course, your root password has to comply with this policy. </li>
</ul>
<hr>
<h3 id="passowrd-period">&lt; Passowrd period &gt;</h3>
<pre><code class="language-c">$ sudo vi /etc/login.defs : 비밀번호 정책 설정 및 확인 가능.</code></pre>
<pre><code class="language-c">PASS_MAX_DAYS 30 : 비밀번호 최대 사용기간. 최대 30일동안 유효.
PASS_MIN_DAYS 2 : 비밀번호 최소 사용기간. 최소 2일동안 사용. 2일 이후에 비밀번호 변경 가능 
PASS_WARN_AGE 7 : 경고 메세지 기간 설정. 비밀번호 만료 7일전부터 경고 메세지 출력
PASS_MIN_LEN 10 : 비밀번호 최소 길이는 10자. </code></pre>
<pre><code class="language-c">$ sudo vi /etc/shadow : root 와 ytak에서 비밀번호가 변경 된 것 확인 가능 (2 : 30: 7 로 확인 가능). shadow 파일에서는 비밀번호 관련 설정들이 저장됨. </code></pre>
<p><img src="https://images.velog.io/images/tak_4242/post/c6a14dd1-dea8-415e-8d41-a17aeca679ba/image.png" alt=""></p>
<h3 id="password-rules">&lt; Password rules &gt;</h3>
<p>하기 커맨드를 통해 비밀번호 정책 설정 가능. </p>
<pre><code class="language-c">$ sudo vi /etc/pam.d/common-password</code></pre>
<pre><code class="language-c">password requisite pam_pwquality.so retry=3 minlen=10 difok=7 ucredit=-1 lcredit=-1 dcredit=-1 reject_username enforce_for_root maxrepeat=3</code></pre>
<p>retry=3</p>
<ul>
<li>비밀번호 입력 횟수 설정</li>
<li>최대 3회 입력 가능</li>
</ul>
<p>minlen=10</p>
<ul>
<li>비밀번호 최소 길이</li>
<li>최소 10글자</li>
</ul>
<p>difok=7</p>
<ul>
<li>이전 비밀번호와 달라야 하는 문자 수</li>
<li>이전의 비밀번호와 비교했을 때 최소 7글자는 달라야 함</li>
<li>root의 경우 이전 비밀번호를 저장하지 않기 때문에 root에는 적용되지 않음</li>
</ul>
<p>ucredit=-1</p>
<ul>
<li>대문자 제한</li>
<li>-1 : 최소 한 글자 이상</li>
</ul>
<p>lcredit=-1</p>
<ul>
<li>소문자 제한</li>
<li>-1 : 최소 한 글자 이상</li>
</ul>
<p>dcredit=-1</p>
<ul>
<li>숫자 제한</li>
<li>-1 : 최소 한 글자 이상</li>
</ul>
<p>reject_username</p>
<ul>
<li>유저 이름이 그대로 또는 뒤집혀서 비밀번호에 입력될 수 없음</li>
</ul>
<p>enforce_for_root</p>
<ul>
<li>해당 비밀번호 정책을 root에도 적용</li>
</ul>
<p>maxrepeat=3</p>
<ul>
<li>중복 글자 제한</li>
<li>최대 3글자까지 중복 가능</li>
<li>비밀번호 정책의 경우 정책 설정 이후에 생성된 유저나 비밀번호에 대해서만 적용된다.</li>
</ul>
<p>그렇기 때문에 기존 유저와 root에 대해</p>
<ul>
<li>강화된 비밀번호로 변경</li>
<li>비밀번호 기간 적용
두 가지 사항을 적용 시켜야 한다.</li>
</ul>
<p><img src="https://images.velog.io/images/tak_4242/post/114ad6e1-3733-4533-8571-4475d2f6bce7/image.png" alt=""></p>
<p>*<em>3. Check that the UFW service is started
*</em></p>
<p><code>$ sudo ufw status verbose</code>  : check rules in details</p>
<p><code>$sudo ufw status numbered</code> : verify the numbered ufw rules</p>
<p><code>$sudo ufw delete &lt;rules to be deleted&gt;</code> : to delete ufw rules</p>
<p><strong>4. Check that the SSH service is started</strong>
<code>$sudo  systemctl status ssh</code> : openssh 실행 여부와 사용 포트를 확인 할 수 있음.</p>
<p><code>$ ssh-keygen</code> : ssh key 확인가능 </p>
<p><img src="https://images.velog.io/images/tak_4242/post/c04d312c-cbab-43cc-b9cd-b9552d40bc4e/image.png" alt=""></p>
<p>*<em>5. Check that chosen Operating System (Debian or Centos) *</em>
<code>$ cat /etc/os-release</code> : verify the chosen OS</p>
<p><img src="https://images.velog.io/images/tak_4242/post/6eabcd84-b3de-4da5-be4f-24e42e7e8596/image.png" alt=""></p>
<h3 id="user">User</h3>
<p><strong>1. User with the login of the evalutated student is present on the virtual machine</strong></p>
<p>내 id 확인가능</p>
<pre><code class="language-c">$ whoami</code></pre>
<p><strong>2. Check that it (login of evlauated student) has been added and it belongs to the &quot;sudo&quot; and &quot;user42&quot; groups.</strong></p>
<p>user id 및 속해있는 group 확인 가능</p>
<pre><code class="language-c">$ id &lt;user id&gt;</code></pre>
<p><img src="https://images.velog.io/images/tak_4242/post/f9b7a8ac-5318-4e48-9094-2fbb814de0aa/image.png" alt=""></p>
<blockquote>
<p>** UID and GID in Linux  ** 
Unix-like Operating Systems identify a user by a value called a user identifier(UID) AND Identify group by a group identifer (GID), are used to determine which system resources a user or group can access. 
(유닉스 OS 시스템에서는 user를 UID 또는 GID로 나누어 구분하여, 접근 권한을 결정한다.)</p>
</blockquote>
<blockquote>
</blockquote>
<p><strong>UID (User Identifier) 
UID is a number assigned by Linux to each user on the system.</strong> This number is used to identify the user to the system and to determine which system resources the user can access.</p>
<ul>
<li>UID 0 (zero) is reserved for the root.</li>
<li>UIDs 1–99 are reserved for other predefined accounts.</li>
<li>UID 100–999 are reserved by system for administrative and system accounts/groups.</li>
<li>UID 1000–10000 are occupied by applications account.</li>
<li>UID 10000+ are used for user accounts</li>
</ul>
<blockquote>
<p>*<em>GID (Group Identifier): Groups in Linux are defined by GIDs(group IDs).
*</em></p>
</blockquote>
<ul>
<li>GID 0 (zero) is reserved for the root group.</li>
<li>GID 1–99 are reserved for the system and application use.</li>
<li>GID 100+ allocated for the user’s group.</li>
</ul>
<p><strong>3.  Create a new user and assign it a password of your choice, respecting the subject rules. You must now explain to you how he was able to set up the rules requested in the subejct on their virtual machine. Normally there should be one or two modified files.</strong></p>
<h3 id="1-create-a-new-user">1. Create a new user</h3>
<ul>
<li><p><code>$sudo -v</code> : to check your sudo rights, if no error messages appear, you&#39;re good to go.</p>
</li>
<li><p><code>$sudo adduser &lt;username&gt;</code> : Assign a newuser.</p>
</li>
</ul>
<h3 id="2-create-a-new-group-and-assign-a-user">2. Create a new group and assign a user</h3>
<ul>
<li><p><code>c $sudo groupadd &lt;groupname&gt;</code> : Add a group</p>
</li>
<li><p><code>$sudo usermod -aG &lt;groupname&gt; &lt;username&gt;</code> : Assign a user to the group</p>
</li>
<li><p><code>$sudo id &lt;username&gt;</code> : Check the new username hasbeen assigned to new groupname correctly.</p>
</li>
</ul>
<h3 id="3-verify-the-one-or-two-modified-files">3. Verify the one or two modified files</h3>
<ul>
<li><code>$sudo vi /etc/shadow</code> : 새로 추가된 user의 비밀번호 설정을 확인 할 수 있다. </li>
</ul>
<p><img src="https://images.velog.io/images/tak_4242/post/01ed7dcf-dd07-4d2f-b677-fa8f1e5e3479/image.png" alt=""></p>
<ul>
<li><code>$sudo vi /etc/passwd</code>: 새로 추가된 user의 주소 확인 가능 </li>
</ul>
<p><img src="https://images.velog.io/images/tak_4242/post/1d04d5b4-fe28-4982-ac51-5829d5daefd6/image.png" alt=""></p>
<h3 id="4-delete-the-user-and-the-group">4. Delete the user and the group</h3>
<ul>
<li><code>$sudo deluser &lt;username&gt;</code> : Delete the user</li>
<li><code>$sudo groupdel &lt;groupname&gt;</code> : Delete the group</li>
<li><code>$getent group | grep &lt;groupname to be found&gt;</code> : 그룹 현황 확인 가능 </li>
</ul>
<p>** 5. Advantages and disadvantages of password policy. **</p>
<ul>
<li>Advantages : 비밀번호 정책으로 인해, 강력한 비밀번호 생성가능 (보안성 강화)</li>
<li>Disavantages : 30일 주기로 비밀번호를 바꿔야 하는 불편함, 이전과는 같은 비밀번호를 생성 할 수 없음. </li>
</ul>
<h3 id="hostname-and-partitions">Hostname and partitions</h3>
<ol>
<li>Check that the hostname of the machine is correctly formatted as follows: login42</li>
</ol>
<p><code>$ hostnamectl</code></p>
<ol start="2">
<li>Modify this hostname by replacing login with yours, then restart the machine. </li>
</ol>
<p><code>$ sudo hostnamectl set-hostname &lt;new hostname&gt;</code> : 호스트이름 변경 </p>
<p><code>$ sudo reboot</code> : 시스템 재부팅</p>
<ol start="3">
<li>You can now restore the machine to the original hostname</li>
</ol>
<p><code>$ sudo hostnamectl set-hostname &lt;original hostname&gt;</code> : 기존 호스트이름으로 변경. </p>
<p><code>$ sudo reboot</code> : 시스템 재부팅</p>
<ol start="4">
<li>How to view the partitions for the virtual machine and compare the output with the example given in the subject and explain how LVM wroks and what it is all about.
<code>$ lsblk</code></li>
</ol>
<p><img src="https://images.velog.io/images/tak_4242/post/d663dfa3-ea66-4baa-b021-f057c0dbe037/image.png" alt=""></p>
<h3 id="details-of-partitions">Details of partitions</h3>
<ul>
<li><strong>Root</strong> : Superior category. A 12-20 GB partition for the OS. Non-swap partition where the file system foes and required to boot a Linux system.</li>
</ul>
<ul>
<li><p><strong>Swap</strong> : When the system runs out of RAM, the operating system moves inactive pages from RAM into this partition. To store idle processes when the physical RAM is low (실제 물리적인 램이 부족할때 대신 사용됨).</p>
</li>
<li><p><strong>home</strong> : Holds user and configuration files separate from the operating system files. A  (사용자계정 파티션)</p>
</li>
<li><p><strong>var</strong> : Standard subdirectroy of the root directroy that containes files to which the system writes data during the course of its operation (로그파일 파티션, 시스템 log파일이 저장됨).</p>
</li>
<li><p><strong>srv</strong> : Contains site-specific data which is served by this system. The /srv/ directory contains site-specific data served by your system running Red Hat Enterprise Linux. This directory gives users the location of data files for a particular service, such as FTP, WWW, or CVS. Data that only pertains to a specific user should go in the /home/ directory (프로토콜 -http/https 이용하여 외부사용자의 공유를 위해 사용됨). </p>
</li>
<li><p><strong>tmp</strong> : Global temporary directories. Web browsers periodically write data to the tmp directory during page views and downloads (임시파일들을 저장하거나 시스템에서 임시로 작업을 진행할때 사용하는 파티션). </p>
</li>
<li><p><strong>var/log</strong> : 프로그램 로그파일들이 따로 저장되는 디렉토리</p>
</li>
</ul>
<h3 id="logical-volume-manager-lvm">Logical Volume Manager (LVM)</h3>
<blockquote>
<ul>
<li>Allows for very flexible disk space management</li>
</ul>
</blockquote>
<ul>
<li><p>It provides features like ability to add disk space to a logical volume and its filesystem whie that filesystem is mounted and active and it allows for the collection of multiple physical hard drives and paritioning into a single volume group which can be divided into logical volumes.</p>
</li>
<li><p>Also, allows reducing the amount of disk space allocated to a logical volume. </p>
</li>
<li><p>LVM(Logical Volume Manager)는 리눅스 안에서 하나의 디스크를 여러 파티션으로 분할해서 파일 시스템을 이용해 특정 디렉터리와 연결시켜 사용한다. </p>
</li>
<li><p>파티션을 논리적인 개념인 볼륨으로 나눠서 더 유동적으로 디스크의 용량을 관리할 수도 있다</p>
</li>
<li><p>작은 용량의 하드디스크 여러 개를 큰 용량의 하드디스크 1개처럼 사용한다 (즉, 여러개의 디스크 공간을 합쳐서 하나인양 사용하기 위해).</p>
</li>
<li><p>사용하기 애매한 공간의 디스크 파티션(짜투리)들을 활용하기 위해 사용한다.</p>
</li>
<li><p>기존에 사용중인 디스크의 공간을 확장하기 위해 사용한다. </p>
</li>
<li><p>서버를 운영하면서 대용량의 별도 저장 공간이 필요할때 활용한다 (용량이 목적).</p>
</li>
</ul>
<h3 id="lvm-은-크게-3가지-영역으로-구분됨">LVM 은 크게 3가지 영역으로 구분됨.</h3>
<ul>
<li><p><strong>Physical Volume(PV)</strong> : 리눅스 시스템에 존재하는 물리 파티션 공간임. LVM의 PV로 귀속되면 해당 공간에 여유 공간이 충분해도 물리적으로 파티셔닝 할 수 없음. </p>
</li>
<li><p>*<em>Volume Group (VG) *</em>: PV로 등록된 파티션을 다시 하나의 그룹으로 묶을 수 있음. 이 그룹이 바로 VG임. VG로 묶인 PV파티션은 동일 VG 내에서 모든 용량이 통합됨. 또 다시 논리 파티션으로 나눌때에는 VG에서 전체 가용 공간을 판단하여 할당하게 됨. </p>
</li>
<li><p><strong>Logical Volume (LV)</strong> : VG는 다시 자신이 관리중인 PV에서 논리적으로 공간을 분할 할 수 있음. 이렇게 분할된 파티션을 LV라고 함. </p>
</li>
</ul>
<p>이렇게 LV로 나뉜 파티션은 최종적으로 파일 시스템을 할당받고 특정 디렉토리에 마운트 될 수 있음. </p>
<p><img src="https://images.velog.io/images/tak_4242/post/f9965457-dcaf-44dd-a00e-4b43a47e2e24/image.png" alt=""></p>
<p>파티션은 물리 공간에서 나뉜 각각의 저장공간인 반면, 볼륨의 경우 파티션을 포함한 물리 저장 공간까지 모두 아우르는 개념. </p>
<h3 id="파티션이란-">파티션이란 ?</h3>
<ul>
<li><p><strong>파티셔닝</strong> :
하나의 물리 저장 장치를 시스템 내부에서 여러 디스크 공간으로 나누는 작업을 일컬음. 
물리적으로 나뉜 공간을 primary, 논리적으로 나뉜 공간을 Extended 라고 부름. </p>
</li>
<li><p><strong>파티션</strong> : 
하드디스크 용량을 사용자가 필요에 따라 논리적으로 나눈 구역. 하나의 디스크는 여러개의 파티션을 나눌 수 있음. LVM이라고 부르는 파일 시스템을 통해 하나의 물리 공간을 논리적으로 쪼개어 사용함. 이렇게 나뉜 각각의 저장 공간을 파티션이라고 부름.</p>
</li>
<li><p><em>파티션은 고정적이고 물리적인 개념이 강하며, 한 번 크기를 설정하면 변경하거나 추가하기 힘들고 OS는 각 파티션을 별도의 디스크 처럼 인식한다.*</em> </p>
</li>
<li><p>*<em>Primary 파티션 (주 파티션) *</em>
   1) 파티션 정보를 포함하는 파티션 테이블에는 파티션 정보를 4개 밖에 저장 할수 밖에 없는 제한이 있으며, 이 4개의 파티션을 Primary 파티션 (주 파티션)이라고 부른다.
   2) 4개 이상의 파티션을 사용해야 할 때는 하나의 확장 파티션을 설정하며 확장 파티션 안에 여러개의 논리 파티션을 분할하여 데이터 저장.</p>
</li>
</ul>
<ul>
<li><p><strong>Extended 파티션 (확장 파티션)</strong>
  1) 하나의 물리적 디스크에 1개만 생성 가능, 주 파티션내에 생성. 파티션 번호는 1~4번이 할당. 
  2) 데이터 저장 영역을 위한것이 아니라 논리 파티션을 생성
  3) Extended 파티션은 Primary 파티션 가운데 한개만 쓸 수 있음. 
  4) Extended 파티션에는 사용자가 원하는 만큼의 Logical 파티션을 만들 수 있음. </p>
</li>
<li><p><strong>Logical 파티션 (논리 파티션)</strong>
  1) 확장 파티션 내에 생성
  2) 12개 이상 생성하지 않는것을 권고하며 5번 이후의 파티션 번호가 붙여짐.</p>
</li>
<li><p>*<em>마운트 (mount) *</em>
파티셔닝 된 물리 혹은 논리 공간은 특정 디렉토리에 연결되어 보이는데, 이것을 흔히 마운트 되었다고 표현한다. 즉, 특정 파일 시스템으로 마운트 된 파티션이 특정 디렉토리에 마운트 됨으로써, 사용자는 그 디렉토리를 통해 디스크의 파티션과 상호작용 할 수 있게 됨.<br>하드디스크, 플로피 디스크와 같은 저장 장치를 사용할 수 있도록 설정하는 작업. </p>
</li>
</ul>
<h3 id="볼륨이란-">볼륨이란 ?</h3>
<ul>
<li>파일 시스템으로 포맷된 디스크 상의 저장영역.</li>
<li>볼륨은 디스크, SSD, DVD 등의 물리 저장공간 까지 포괄적으로 볼륨이라고 불리며, 또 각각의 파티션 자체가 곧 볼륨이다. </li>
<li>볼륨은 디스크의 단일 파티션에 상주하게 되며, 파티션보다 논리적으로 유동적이다. </li>
<li>우리는 하나의 디스크를 여러 개의 파티션으로 나누어 사용한다. 이때 볼륨은 파티션마다 하나씩 존재하기도 하고, 여러 파티션에 하나만 존재할 수도 있다. </li>
</ul>
<p>리눅스에서 디스크를 사용하는 가장 기본적인 방법은 디스크를 파티션으로 나누어 각각의 디렉터리에 파일 시스템으로 마운트 한 뒤 지정된 위치에 데이터를 저장해서 사용하는 것이다.
(디스크 → 파티션 → 볼륨그룹 → 논리그룹 → 파일시스템(/home))</p>
<h3 id="sudo-사용의-필요성-및-장점">Sudo 사용의 필요성 및 장점</h3>
<ul>
<li><p>root권한을 최소화 시키는것이 보안의 첫걸음이며, sudo사용은 보안의 기본이라 할 수 있다. </p>
</li>
<li><p>root password를 효율적으로 관리 할 수 있다. 한명이 아닌 여러명의 관리자에 의해 시스템이 운영될 경우에 여러사람이 root패스워드를 공유하면 root 패스워드 정기적인 변경이 어려워짐은 물론, root 패스워드가 외부로 노출될 확률이 높아진다. sudo를 써서 root권한을 사용하는 시간을 최소화하는것은 위협요소로부터 안전한 작업 또는 운영을 하는데 있어서 매우 큰 장점이다.</p>
</li>
<li><p>log 추적이 쉬워진다. su root할 경우가 많아지게 되면, su root가 되어 무슨 작업을 했는지 일일히 확인하는것이 불가능 하다. 심지어 시스템의 일부가 손상되어도 그 사실을 눈치채지 못할 수 있다. sudo를 쓰게 되면 command단위의 loggin이 가능하므로 정확한 기록을 확인할 수 있게 된다. </p>
</li>
<li><p>관리의 권한과 책임이 명확해진다. root 권한을 여러 사람이 공유할때, 어떤 작업이 누구에 의해 행해졌는지는 매우 불분명하다. sudo를 써서 작업한다면 누가 어떤 작업을 했는지가 명확하다.</p>
</li>
</ul>
<h3 id="sudo-사용법">Sudo 사용법</h3>
<ul>
<li>sudo가 설치되어 있다면, sudoers 파일에 원하는 사용자를 등록시킬 수 있다. </li>
<li>문법체크를 해주는 $visudo를 쓰는것을 권장함. </li>
</ul>
<h4 id="1-check-that-the-sudo-program-is-properly-installed-on-the-virtual-machine">1. Check that the &quot;Sudo&quot; program is properly installed on the Virtual Machine</h4>
<p><code>$dpkg -l sudo</code>  sudo 설치 여부 확인</p>
<p>*<em>2. The evaluated student should now show assigning your new user to the &quot;sudo&quot; group. 
*</em></p>
<ul>
<li><p><code>sudo adduser &lt;new username&gt;</code> new user 생성  </p>
</li>
<li><p><code>sudo usermod -aG sudo &lt;new username&gt;</code> sudo그룹에 new user 할당</p>
</li>
<li><p><code>getent group</code> 커맨드로 그룹 현황 확인 해 볼것 </p>
</li>
</ul>
<ul>
<li>**<code>deluser &lt;user&gt; &lt;group&gt;</code>  to remove user from a group </li>
<li>*</li>
</ul>
<h4 id="3-the-student-must-first-explain-the-value-and-operation-of-sudo-using-examples-of-their-choice"><strong>3. The student must first explain the value and operation of sudo using examples of their choice.</strong></h4>
<p>=&gt; show how sudo works</p>
<h4 id="4-verify-that-the--varlogsudo-folder-exists-and-has-at-least-one-file-check-the-contents-of-the-files-in-this-folder-and-you-should-see-a-history-of-the-commands-used-with-sudo">4. Verify that the &quot; /var/log/sudo/&quot; folder exists and has at least one file. Check the contents of the files in this folder and you should see a history of the commands used with sudo.</h4>
<ul>
<li><code>su -</code> root계정으로 로그인</li>
<li><code>cd /var/log/sudo/00/00</code> 으로 접근</li>
<li><code>ls</code> 로 들어있는 log 파일들을 확인 </li>
</ul>
<h4 id="5-run-a-command-via-sudo-see-if-the-files-in-the-varlogsudo-folder-have-been-updated">5. Run a command via sudo. See if the file(s) in the &quot;/var/log/sudo&quot; folder have been updated.</h4>
<p><code>sudo ls</code> 등 sudo와 관련된 아무 커맨드나 확인하고, 새로운 log 파일이 생겼는지 확인한다. </p>
<h3 id="ufw-uncomplicated-firewall">UFW (Uncomplicated FireWall)</h3>
<blockquote>
<p><strong>UFW is a program for managing a netfilter firewall designed to be easy to use.</strong></p>
</blockquote>
<h4 id="1-check-that-the-ufw-program-is-properly-installed-on-the-virtual-machine-check-that-it-is-working-properly">1. Check that the &quot;UFW&quot; program is properly installed on the virtual machine. Check that it is working properly.</h4>
<p><code>sudo ufw status verbose</code> : ufw 상태 상세 확인 </p>
<h4 id="2-should-explain-what-ufw-is-and-the-value-of-using-it">2. Should explain what UFW is and the value of using it.</h4>
<p><strong>UFW이란, 데비안 계열 빛 다양한 리눅스 환경에서 작동되는 사용하기 쉬운 방화벽 관리 프로그램이다.</strong> UFW는 사용하기 쉽게 설계된 넷필터 (리눅스 커널 내부의 네트워크 관련 프레임 워크) 방화벽을 관리하는 프로그램이다. 간단한 명령 및 명령수가 적은 명령줄 인터페이스를 사용하는것이 특징이며, 프로그램 구성에는 iptables을 사용한다. ufw는 기본적으로 8.04 LTS 이후의 모든 데비안 및 우분투에서 사용할 수 있다. </p>
<h4 id="방화벽--firewall이란">방화벽 / Firewall이란?</h4>
<p>방화벽 또는 Firewall은 네트워크를 통해 들어오는 트래픽(패킷)을 모니터링하고 제어하는 보안 시스템이다. 학교에서 사용하는 내부 네트워크 보안 규칙 설정 뿐만아니라. 외부 접속을 통한 데이터의 안전상태를 검열 혹은 수정하는 장치이다.</p>
<p><img src="https://images.velog.io/images/tak_4242/post/3b662f84-b391-4203-add8-c639ed7a5ff5/image.png" alt=""></p>
<h4 id="3-list-the-active-rules-in-ufw-a-rule-must-exist-for-port-4242">3. List the active rules in UFW. A rule must exist for port 4242.</h4>
<p><code>sudo ufw status numbered</code> : verify the rule numbered</p>
<h4 id="4-add-a-new-rule-to-open-port-8080-check-that-this-one-has-been-added-by-listing-the-active-rules-after-delete-this-new-rule">4. Add a new rule to open port 8080. Check that this one has been added by listing the active rules. After, delete this new rule.</h4>
<p><code>sudo ufw allow 8080</code> : add 8080 port</p>
<p><code>sudo ufw delete &lt;Number of the rules to be deleted&gt;</code> : delete the rule</p>
<h3 id="ssh">SSH</h3>
<ol>
<li><p>Check that the SSH service is properly installed on the virtual machine and check that is working properly. 
<code>systemctl status ssh</code> : check the status of ssh</p>
</li>
<li><p>You must be able to explain basically what SSH (Secure Shell) is and the value of using it.</p>
</li>
</ol>
<h3 id="ssh란">SSH란?</h3>
<p>SSH란 Secure Shell의 줄임말로, 두 컴퓨터 간 통신을 보안적으로 안전하게 할 수 있게 해주는 하나의 protocol이다.
인터넷 연결만 되어있어도 내 컴퓨터의 terminal을 통해 다른 지역에 있는 컴퓨터 혹은 서버를 관리할 수 있게 해주고, 파일도 공유 할 수 있다. 
대표적인 사용의 예) </p>
<ul>
<li>데이터 전송</li>
<li>원격 제어</li>
</ul>
<blockquote>
<ul>
<li>protocol이란, 서로 다른 통신 장비 간 주고 받는 데이터의 양식과 규칙이다.
예시) HTTP, HTTPS, FTP </li>
</ul>
</blockquote>
<p>SSH란 Secure Shell Protocol, 즉 네트워크 프로토콜 중 하나로 컴퓨터와 컴퓨터가 같은 public network를 통해 서로 통신을 할때 보안적으로 안전하게 통신을 하기 위해 사용하는 프로토콜이다. 
대표적인 사용의 예는 하기와 같다. </p>
<p>-** SSH (Secure Shell) is a network protocol that gives users, particularly system administrators, a secure way to access a computer over an unsercured network**. In addition to providing secure network services, SSH refers to the suite of utilities that implement the SSH protocol. Secure Shell provides strong password authentication and public key authentication, as well as encrypted data communications between two computers connecting over an open network, such as the internet. </p>
<h4 id="3-verify-that-the-ssh-service-only-uses-port-4242">3. Verify that the SSH service only uses port 4242</h4>
<p>=&gt; 보너스를 했기 때문에, port4242 와 port80 (wordpress 연결)이 떠야함. </p>
<h4 id="4-you-should-use-ssh-in-order-to-log-in-with-the-newly-created-user-to-do-this-you-can-use-a-key-or-a-simple-password-it-will-depend-on-the-student-being-evaluated-of-course-you-have-to-make-sure-that-you-cant-use-ssh-with-the-root-user-as-stated-in-the-subject">4. You should use SSH in order to log in with the newly created user. To do this, you can use a key or a simple password. It will depend on the student being evaluated. Of course, you have to make sure that you can&#39;t use SSH with the &quot;root&quot; user as stated in the subject.</h4>
<h3 id="script-monitoring">Script monitoring</h3>
<h4 id="1-the-operation-of-its-script-by-displaying-its-code">1. The operation of its script by displaying its code</h4>
<pre><code class="language-c">
#!/bin/bash

printf &quot;#Architecture: &quot;
 uname -a

printf &quot;#CPU physical : &quot;
 nproc --all

printf &quot;#vCPU : &quot;
 cat /proc/cpuinfo | grep processor | wc -l

printf &quot;#Memory Usage: &quot;
 free -m | grep Mem |awk &#39;{printf&quot;%d/%dMB (%.2f%%)\n&quot;, $3, $2, $3/$2 * 100}&#39;

printf &quot;#Disk Usage: &quot;
 df -BM -a | grep /dev/mapper/ | awk &#39;{sum+=$3}END{print sum}&#39; | tr -d &#39;\n&#39;
printf &quot;/&quot;
 df -H  -a | grep /dev/mapper/LVMGroup-root | awk &#39;{sum+=$2}END{printf sum}&#39; | tr -d &#39;\n&#39;
printf &quot;Gb (&quot;
 df -BM -a | grep /dev/mapper/ | awk &#39;{sum1+=$3 ; sum2+=$4} END {printf &quot;%d&quot;, sum1 / sum2 * 100}&#39; | tr -d &#39;\n&#39;
printf &quot;%%)\n&quot;

printf &quot;#CPU load: &quot;
 mpstat | grep all | awk &#39;{printf &quot;%.2f%%\n&quot;, 100-$13}&#39;

printf &quot;#Last boot: &quot;
 who -b | sed &#39;s/^ *system boot //g&#39;

printf &quot;#LVM use: &quot;
if [ &quot;$(lsblk | grep lvm | wc -l)&quot; -gt 0 ] ; then printf &quot;yes\n&quot; ; else printf &quot;no\n&quot; ; fi

printf &quot;#Connexions TCP : &quot;
 ss | grep -i  tcp | wc -l | tr -d  &#39;\n&#39;
printf &quot; ESTABLISHED\n&quot;

printf &quot;#User log: &quot;
who | wc -l

printf &quot;#Network: IP &quot;
 /sbin/ifconfig | grep broadcast | sed &#39;s/inet//g&#39; | sed &#39;s/netmask.*//g&#39; | sed &#39;s/ //g&#39; | tr -d &#39;\n&#39;
printf &quot; (&quot;
 /sbin/ifconfig | grep ether | sed &#39;s/.*ether //g&#39; | sed &#39;s/ .*//g&#39; | tr -d &#39;\n&#39;

printf &quot;)\n&quot;

printf &quot;#Sudo : &quot;
 cat /var/log/auth.log | grep -a sudo | grep -a &#39;COMMAND=&#39; | wc -l | tr -d &#39;\n&#39;
printf &quot; cmd\n&quot;

exit 0</code></pre>
<h3 id="cron">Cron</h3>
<h4 id="2-what-is-cron">2. What is &quot;cron&quot;?</h4>
<ul>
<li><p>A time-based job scheduler in Unix-like computer operating systes. </p>
</li>
<li><p>The cron daemon is a long-running process that executes commands at specific dates and times (to run schedule tasks).Cron wakes up every minutes and checks schedule tasks in cron table. </p>
</li>
<li><p>crontab : crontab is a table where we can schedule such kind of repeated tasks. </p>
</li>
</ul>
<h4 id="3-how-the-evaluated-student-set-up-her-script-so-that-it-runs-every-10-minutes-when-the-server-starts-up">3. How the evaluated student set up her script so that it runs every 10 minutes when the server starts up.</h4>
<p><code>crontab -e</code></p>
<p><code>*/10 * * * */home/ytak/monitoring.sh | wall</code>
=&gt; set up the script at every 10 min</p>
<h4 id="4-the-evaluated-student-should-ensure-that-this-script-runs-every-30s-you-can-run-whatever-you-want-to-make-sure-the-script-runs-with-dynamic-values-correctly-and-the-student-evaluated-should-make-the-script-stop-running-when-the-server-starts-up-but-without-modifying-the-script-to-check-this-point-you-will-have-to-restart-the-server-one-last-time-at-startup-it-will-be-necessary-to-check-that-the-script-still-exists-in-the-same-place-that-its-rights-have-remained-unchanged-and-that-it-has-not-been-modified">4. The evaluated student should ensure that this script runs every 30s. You can run whatever you want to make sure the script runs with dynamic values correctly, and the student evaluated should make the script stop running when the server starts up, but without modifying the script. To check this point, you will have to restart the server one last time, At startup, it will be necessary to check that the script still exists in the same place, that its rights have remained unchanged, and that it has not been modified.</h4>
<p><code>crontab -e</code></p>
<p><code>*/1 * * * */home/ytak/monitoring.sh | wall</code>
<code>*/1 * * * * sleep 30; /home/ytak/monitoring.sh | wall</code>
=&gt; Using sleep30s, the monitoring.sh should run every 30 seconds. </p>
<h3 id="bonus">Bonus</h3>
<ol>
<li>Setting up partitions is worth 2 points (need to corresponded to the paritions with the subejct)</li>
</ol>
<p><img src="https://images.velog.io/images/tak_4242/post/79567292-30ed-46b8-9c9f-09fb8ab205b3/image.png" alt=""></p>
<ol start="2">
<li>Setting up WordPress, only with the services required by the subject, is worth 2 points.</li>
</ol>
<p><code>http://127.0.0.1:9000/</code> : php 연결 확인 
<code>http://127.0.0.1:9000/h2s</code> : 연결된 wp 사이트 확인. Lighttpd를 설치할때 syntax를 h2s로 설정함. 
(Host Port:9000 , Guest port :80)</p>
<p><img src="https://images.velog.io/images/tak_4242/post/d99b9ca3-9499-4ace-82ce-5f8273badcf7/image.png" alt=""></p>
<h3 id="포트-포워딩-port-forwarding">포트 포워딩 (port forwarding)</h3>
<h3 id="port란">port란?</h3>
<ul>
<li>인터넷을 사용하는 프로그램은 서버와 통신을 하게 된다. 컴퓨터의 lan선은 하나인데 통신을 필요로 하는 프로그램이 다수일때 이 다수의 프로그램을 구별할 수 있는 번호가 port이다. </li>
</ul>
<p><img src="https://images.velog.io/images/tak_4242/post/70da272d-3fc9-486b-83e8-78ad81b0a58c/image.png" alt=""></p>
<h3 id="포트포워딩port-forwarding이란">포트포워딩(port forwarding)이란?</h3>
<ul>
<li>포트 포워딩이란, 컴퓨터 네트워크에서 패킷이 라우터나 방화벽 같은 네트워크 게이트웨이를 통과하는 동안 네트워크 주소를 변환해주는것을 의미한다. 특정 호스트의 IP와 서비스포트로 전달해 주기 위해 필요한 기능이 포트 포워딩. </li>
<li>쉽게 말해, 외부에서 접속이 가능하도록 하는것. </li>
</ul>
<p><img src="https://images.velog.io/images/tak_4242/post/db40d94e-bb42-4aed-af60-6f2b774b0e53/Screenshot%202021-07-12%20at%2015.19.55.png" alt=""></p>
<ol start="3">
<li>The free choice service is worth 1 point. For the free choice service, the evaluated student has to give you a simple explanation about how it works and why they think it is useful(Please note that NGINX and Apache2 are prohibited).</li>
</ol>
<h3 id="php-란-hypertext-preprocessor-서버측-스크립트">PHP 란 (Hypertext preprocessor 서버측 스크립트)</h3>
<ul>
<li>PHP는 서버 측에서 실행되는 프로그래밍 언어로 HTML을 프로그래밍적으로 생성해주고, 데이터베이스와 상호작용 하면서 데이터를 저장하고 표현한다. 동적으로 웹페이지를 만들어주는 역할을 한다. </li>
<li>동적 웹 페이지를 위해 사용되는 PHP는 스크립트 형식으로 되어있어 작성된 HTML코드 안에 추가해주면 서버에서 PHP 코드를 해석해서 웹 페이지를 생성한다. </li>
<li>PHP는 웹을 위해서 만들어졌고, 웹프로그래밍을 위한 높은 생산성을 제공하는 언어이다. </li>
<li>특히 서버에 직접 설치해서 운영할 수 있는 설치형 웹애플리케이션(워드프레스..) 과반이 PHP로 만들어졌다.</li>
<li>데이터베이스 연동을 편리하게 할 수 있다. 처리속도가 빠르다. </li>
<li>거의 모든 운영체제에 구현이 가능. 코드 작성이 쉽고 문법이 간단하다. 스크립트 언어 이기 때문에  HTML 문서 내부에 입력하여 실행 할 수 있는 편리한 언어이다. </li>
<li>PHP는 서버에 배포하는게 간편하며, 초보자에게 쉽다. </li>
<li>프로그램 코드가 보여지지 않기에 자바스크립트에 비해 보안성이 뛰어나다. </li>
<li>웹 브라우저의 버전과 종류에 영향을 받지 않는다. </li>
</ul>
<p><img src="https://images.velog.io/images/tak_4242/post/6915e56b-0067-432d-b0df-908bd518f74b/image.png" alt=""></p>
<h3 id="web-server-웹-서버">Web server (웹 서버)?</h3>
<ul>
<li>웹 서버는 우리가 인터넷에서 흔히 사용하는 웹 페이지가 들어있는 파일을 사용자에게 제공해주는 서버 프로그램 (시스템 소프트웨어라고 불린다).</li>
<li>웹 서버의 주된 역할은 사용자가 요청한 페이지를 전달하는것.</li>
</ul>
<p>&lt; 웹 서버의 사용 &gt;</p>
<ol>
<li>사용자 -&gt; 웹 브라우저 -&gt; HTTP 프로토콜 -&gt; 웹서버</li>
<li>웹서버 (HTML문서) -&gt; 웹 브라우저 -&gt; 사용자.</li>
</ol>
<h3 id="apache-웹-서버-vs-ngnix-웹서버">Apache 웹 서버 vs Ngnix 웹서버</h3>
<h3 id="apache아파치-웹서버란-">Apache(아파치) 웹서버란 ?</h3>
<ul>
<li>오픈 소스로 공개되며 자유 소프트 웨어로 무료로 사용 가능함. </li>
<li>리눅스나 윈도우 등 거의 모든 운영체제에서 사용 할 수 있으며 구축이 쉽다. </li>
<li>다양한 모듈을 제공하며, 보안 수준이 높다. </li>
<li>강력한 커뮤니티로 인한 방대한 자료가 있다. </li>
</ul>
<h3 id="nginx-웹서버란-">Nginx 웹서버란 ?</h3>
<ul>
<li>최소한의 리소스로 많은 수의 동시 사용자를 처리해야 하는 대 규모 웹 트래픽 처리 상황이 발생할때 고효율을 발휘한다. </li>
<li>오픈소스로 무료이며, Apache에 비해 가볍다. </li>
</ul>
<p>출처 : </p>
<p>0) 가상머신이란
<a href="https://joyfuls.tistory.com/48">https://joyfuls.tistory.com/48</a></p>
<p>1) 리눅스 종류
<a href="https://coding-factory.tistory.com/318">https://coding-factory.tistory.com/318</a></p>
<p>2) Apparmor 정의
<a href="https://wiki.debian.org/AppArmor">https://wiki.debian.org/AppArmor</a></p>
<p>3) 전반적인 info
<a href="https://tbonelee.tistory.com/m/16">https://tbonelee.tistory.com/m/16</a></p>
<p>4) Wall linux command
<a href="https://www.geeksforgeeks.org/wall-command-in-linux-with-examples/">https://www.geeksforgeeks.org/wall-command-in-linux-with-examples/</a></p>
<p>5) UID and GID in Linux
<a href="https://medium.com/@gggauravgandhi/uid-user-identifier-and-gid-group-identifier-in-linux121ea68bf510#:~:text=Identifier%20in%20Linux-,Gaurav%20Gandhi,user%20or%20group%20can%20access">https://medium.com/@gggauravgandhi/uid-user-identifier-and-gid-group-identifier-in-linux121ea68bf510#:~:text=Identifier%20in%20Linux-,Gaurav%20Gandhi,user%20or%20group%20can%20access</a></p>
<p>6) How to add and delete users on Debian 10
<a href="https://devconnected.com/how-to-add-and-delete-users-on-debian-10-buster/">https://devconnected.com/how-to-add-and-delete-users-on-debian-10-buster/</a></p>
<p>7) How to delete Group in Linux
<a href="https://linuxize.com/post/how-to-delete-group-in-linux/">https://linuxize.com/post/how-to-delete-group-in-linux/</a></p>
<p>8) 파티션 정보
<a href="https://www.lifewire.com/do-you-need-home-partition-2202048">https://www.lifewire.com/do-you-need-home-partition-2202048</a>
<a href="https://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-rg-en-4/s1-filesystem-fhs.html">https://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-rg-en-4/s1-filesystem-fhs.html</a>
<a href="https://letitkang.tistory.com/88">https://letitkang.tistory.com/88</a>
<a href="https://new-ngmon.tistory.com/23">https://new-ngmon.tistory.com/23</a></p>
<p>9) LVM 정보
<a href="https://mamu2830.blogspot.com/2019/12/lvmpv-vg-lv-pe-lvm.html">https://mamu2830.blogspot.com/2019/12/lvmpv-vg-lv-pe-lvm.html</a>
<a href="https://velog.io/@welloff_jj/Born2beRoot-%EB%AD%90%EA%B0%80-%EB%AD%94%EC%A7%80-%EB%AA%A8%EB%A5%B4%EA%B2%A0%EC%A7%80%EB%A7%8C-%EC%95%84%EB%AC%B4%ED%8A%BC-%EC%A0%95%EB%A6%AC%ED%95%98%EB%8A%94-%EA%B8%80">https://velog.io/@welloff_jj/Born2beRoot-%EB%AD%90%EA%B0%80-%EB%AD%94%EC%A7%80-%EB%AA%A8%EB%A5%B4%EA%B2%A0%EC%A7%80%EB%A7%8C-%EC%95%84%EB%AC%B4%ED%8A%BC-%EC%A0%95%EB%A6%AC%ED%95%98%EB%8A%94-%EA%B8%80</a>
<a href="https://itguava.tistory.com/100">https://itguava.tistory.com/100</a>
<a href="https://velog.io/@dogfootbirdfoot/Born2beRoot2">https://velog.io/@dogfootbirdfoot/Born2beRoot2</a></p>
<p>10) Firewall 정보
<a href="https://ko.wikipedia.org/wiki/%EB%B0%A9%ED%99%94%EB%B2%BD_(%EB%84%A4%ED%8A%B8%EC%9B%8C%ED%82%B9)#/media/%ED%8C%8C%EC%9D%BC:Firewall.png">https://ko.wikipedia.org/wiki/%EB%B0%A9%ED%99%94%EB%B2%BD_(%EB%84%A4%ED%8A%B8%EC%9B%8C%ED%82%B9)#/media/%ED%8C%8C%EC%9D%BC:Firewall.png</a></p>
<p>11) SSH 정보
<a href="https://searchsecurity.techtarget.com/definition/Secure-Shell">https://searchsecurity.techtarget.com/definition/Secure-Shell</a></p>
<p>12) How to use cron
<a href="https://opensource.com/article/17/11/how-use-cron-linux">https://opensource.com/article/17/11/how-use-cron-linux</a></p>
<p>13) Port forwarding 정보
<a href="https://storytown.tistory.com/14#:~:text=21%EB%B2%88%20%ED%8F%AC%ED%8A%B8%EB%A1%9C%20%EC%9A%94%EC%B2%AD,Port%2DForwarding%EC%9D%B4%EB%9D%BC%EA%B3%A0%20%ED%95%A9%EB%8B%88%EB%8B%A4">https://storytown.tistory.com/14#:~:text=21%EB%B2%88%20%ED%8F%AC%ED%8A%B8%EB%A1%9C%20%EC%9A%94%EC%B2%AD,Port%2DForwarding%EC%9D%B4%EB%9D%BC%EA%B3%A0%20%ED%95%A9%EB%8B%88%EB%8B%A4</a>.</p>
<p>14)Install Wordpress on Lighttpd 
<a href="https://www.how2shout.com/linux/install-wordpress-on-lighttpd-web-server-ubuntu/">https://www.how2shout.com/linux/install-wordpress-on-lighttpd-web-server-ubuntu/</a></p>
<p>15) PHP 정보 
<a href="https://server-talk.tistory.com/25">https://server-talk.tistory.com/25</a>
<a href="https://choseongho93.tistory.com/61">https://choseongho93.tistory.com/61</a></p>
<p>16) 웹서버 정보 
<a href="https://doorbw.tistory.com/29">https://doorbw.tistory.com/29</a>
<a href="https://wiseworld.tistory.com/75">https://wiseworld.tistory.com/75</a></p>
<p>17) sudo 정보
<a href="https://deois.tistory.com/entry/sudo%EC%82%AC%EC%9A%A9%EC%9D%98-%ED%95%84%EC%9A%94%EC%84%B1#:~:text=sudo%EB%A5%BC%20%EC%93%B0%EA%B2%8C%20%EB%90%98%EB%A9%B4%20command,%EA%B0%80%EB%8A%94%20%EB%A7%A4%EC%9A%B0%20%EB%B6%88%EB%B6%84%EB%AA%85%ED%95%B4%EC%A7%91%EB%8B%88%EB%8B%A4">https://deois.tistory.com/entry/sudo%EC%82%AC%EC%9A%A9%EC%9D%98-%ED%95%84%EC%9A%94%EC%84%B1#:~:text=sudo%EB%A5%BC%20%EC%93%B0%EA%B2%8C%20%EB%90%98%EB%A9%B4%20command,%EA%B0%80%EB%8A%94%20%EB%A7%A4%EC%9A%B0%20%EB%B6%88%EB%B6%84%EB%AA%85%ED%95%B4%EC%A7%91%EB%8B%88%EB%8B%A4</a>.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Born2beroot] Linux ]]></title>
            <link>https://velog.io/@tak_4242/born2beroot-Linux</link>
            <guid>https://velog.io/@tak_4242/born2beroot-Linux</guid>
            <pubDate>Wed, 07 Jul 2021 15:29:25 GMT</pubDate>
            <description><![CDATA[<h3 id="linux">Linux</h3>
<h4 id="linux란-무엇인가">Linux란 무엇인가</h4>
<p>쉽게 말하자면, 윈도우와 같은 하나의 독자적인 컴퓨터 운영체제(OS)이다.
(OS란, 컴퓨터의 하드웨어와 소프트웨어를 제어하여, 사용자가 컴퓨터를 쓸 수 있게 만들어주는 프로그램을 말한다.)</p>
<p>리눅스는 공개 소프트웨어라서 그룹이나 회사등에서 커널소스 (kernel: 하드웨어 자원을 효율적으로 관리하기 위한 요소)를 받아 OS를 직접제작하여 사용된다. </p>
<h4 id="리눅스의-특징-및-기능">리눅스의 특징 및 기능</h4>
<ol>
<li>뛰어난 신뢰성, 등급 최고의 성능</li>
<li>다양한 업무 환경을 만족시키는 다양한 배포판의 존재</li>
<li>다중 사용자, 다중 처리 시스템</li>
<li>풍부한 응용프로그램의 제공</li>
<li>누구나 자유롭게 사용할 수 있는 운영체제 (오픈소스 기반)</li>
<li>강력하면서 안정적인 네트워크 지원</li>
<li>GUI방식의 x 윈도우 지원</li>
<li>뛰어난 안정성과 보안성 </li>
</ol>
<h4 id="배포된-리눅스의-종류">배포된 리눅스의 종류</h4>
<ol>
<li><p>데비안 (Debian) 
패키지설치 및 업그레이드가 단순하여 간편한 장점이 있음.
안정성과 보안에 중점을 두고 있음</p>
</li>
<li><p>우분투 (ubuntu) 
Debian을 기반으로 하여 만들어짐.
windows에 익숙해진 유저들이 리눅스를 쉽게 접할 수 있도록 만들어진 운영체제.</p>
</li>
<li><p>레드 햇 (red hat)
클라우드 인프라구축이 쉽고 간편함.</p>
</li>
<li><p>안드로이드 (android)
구글에서 리눅스를 기반으로 개발한 운영체제로, c, c++, python, java등의 프로그래밍 언어를 지원함. </p>
</li>
</ol>
<p>출처 : <a href="https://kma1079.tistory.com/entry/01-%EB%A6%AC%EB%88%85%EC%8A%A4%EB%9E%80-%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80">https://kma1079.tistory.com/entry/01-%EB%A6%AC%EB%88%85%EC%8A%A4%EB%9E%80-%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[born2beroot] Bonus part_ Wordpress]]></title>
            <link>https://velog.io/@tak_4242/born2beroot-Bonus-part-Wordpress</link>
            <guid>https://velog.io/@tak_4242/born2beroot-Bonus-part-Wordpress</guid>
            <pubDate>Wed, 07 Jul 2021 15:19:32 GMT</pubDate>
            <description><![CDATA[<h3 id="born2beroot-bonus-part">Born2beroot bonus part</h3>
<blockquote>
<p>#Bonuspart subject : </p>
</blockquote>
<ul>
<li>Set up a functional Wordpress website with the following services : lighttpd, MariaDB and PHP.</li>
<li>Set up a service of your choice that you think is useful (NGINX /Apache2 excluded!). During the defense, you will have to justify your choice.</li>
<li>To complete the bonus part, you have the possibility to set up extra
services.  In this case, you may open more ports to suit your needs.
Of course, the UFW rules has to be adapted accordingly.</li>
</ul>
<p>Wp를 설치 하려면 php를 사용할수 있는 웹서버와(lighttpd) 데이터베이스 서버가(MariaDB) 필요함. </p>
<h4 id="1-php">1. PHP</h4>
<p>서버측에서 실행되는 프로그램 언어 (사용언어: HTML).
웹개발에 특화된 언어로, 개인이 홈페이지를 쉽게 만들기 위해 개발된 실용적 가벼운 도구. </p>
<h4 id="2-lighttpd-웹서버">2. Lighttpd (웹서버)</h4>
<p>적은 자원을 사용하여 높은 성능을 내는 오픈소스 웹 서버 애플리케이션.
빠른 처리 속도와 가벼운 용량이 장점.</p>
<h4 id="3-mariadb-데이터베이스-서버">3. MariaDB (데이터베이스 서버)</h4>
<p>RDBMS Software, Opensource 
Unix socket방식으로 인증/접속 (sudo) 하는 방식을 채택하고 있다. 
=&gt; mysql의 사용자와 시스템 사용자를 일치시킨다. 이로인해, 항상 sudo를 통해 접속해야 한다. </p>
<h4 id="4-ip-address-127001--loopback--localhost">4. IP Address 127.0.0.1  (loopback / localhost)</h4>
<p>IP주소 127.0.0.1은 localhost 또는 루프백 주소라고 하는 특수 목적의 IPv4 주소이다. 
모든 컴퓨터는 이 주소를 자체 주소로 사용하지만 실제 ip주소처럼 다른 장치와 통신 할 수는 없다.
=&gt; 즉, 네트워크를 구축하지 않고도 네트워크처럼 응답을 보내고 받는것이 가능하다. </p>
<p><strong>루프백은 내 컴퓨터가 내 컴퓨터에 응답을 보내고 받는 기능이기 때문에, DNS(Domain Name Server)를 통해 ip 주소로 변환 할 수 있는 기능이 없다.</strong> </p>
<p>예시)</p>
<blockquote>
<p>&lt; localhost와 127.0.0.1의 차이점 &gt; 
localhost:3000 은 <a href="http://www.naver.com">www.naver.com</a>
127.0.0.1:3000은 125.209.222.141 (네이버 ip 주소) </p>
</blockquote>
<h4 id="5-httphyper-transfer-protocol">5. HTTP(Hyper Transfer Protocol)</h4>
<ul>
<li><p>Web applications are applications that run over HTTP from web servers(known as APIs) to web browsers(also known as clients)</p>
</li>
<li><p>HTTP is the set of rules for transferring files(text, graphic images, sound, video, and other multimedia files) on the World Wide Web</p>
</li>
</ul>
<p><img src="https://images.velog.io/images/tak_4242/post/c1f84a57-f61e-4703-a55d-e87c49024740/image.png" alt=""></p>
<blockquote>
<ul>
<li>web browsers (clients) : this is what users see</li>
</ul>
</blockquote>
<ul>
<li>web servers : this is where the logic of the app is defined </li>
</ul>
<p><img src="https://images.velog.io/images/tak_4242/post/a03127df-f77d-4cbb-91f3-59439457f24b/image.png" alt=""></p>
<p>출처 :</p>
<ol>
<li>debian10 버전을 위한 lighttpd,php, mariadb 설치 사용법
<a href="https://www.howtoforge.com/how-to-install-lighttpd-with-php-and-mariadb-on-debian-10/">https://www.howtoforge.com/how-to-install-lighttpd-with-php-and-mariadb-on-debian-10/</a></li>
<li>lighttpd웹서버에 wordpress설치 하는법
<a href="https://www.how2shout.com/linux/install-wordpress-on-lighttpd-web-server-ubuntu/">https://www.how2shout.com/linux/install-wordpress-on-lighttpd-web-server-ubuntu/</a></li>
<li>루프백 ip주소 설명<br><a href="https://ko.eyewated.com/127-0-0-1-ip-%EC%A3%BC%EC%86%8C-%EC%84%A4%EB%AA%85/">https://ko.eyewated.com/127-0-0-1-ip-%EC%A3%BC%EC%86%8C-%EC%84%A4%EB%AA%85/</a>
<a href="https://velog.io/@lky9303/127.0.0.1-%EA%B3%BC-localhost%EC%9D%98-%EC%B0%A8%EC%9D%B4">https://velog.io/@lky9303/127.0.0.1-%EA%B3%BC-localhost%EC%9D%98-%EC%B0%A8%EC%9D%B4</a></li>
</ol>
]]></description>
        </item>
    </channel>
</rss>