{"componentChunkName":"component---src-templates-blog-post-js","path":"/linux/생활코딩-리눅스-강좌(shell)/","result":{"data":{"site":{"siteMetadata":{"title":"Study Log","author":"[HongDongUk]","siteUrl":"https://donguk.netlify.com","comment":{"disqusShortName":"","utterances":"doonguk/doonguk.github.io"},"sponsor":{"buyMeACoffeeId":"doonguk"}}},"markdownRemark":{"id":"c220f0b5-aeeb-5faa-94ba-8f497787cdad","excerpt":"Shell harware - 컴퓨터의 기계적인 부분들 ( 메모리, 하드디스크 ,SSD, CPU 등등..) Kernel - 하드웨어를 제어하는 프로그램 ( 운영체제에서 코어역할을 한다.) Shell - 우리가 입력한 명령을 Kernel이 이해할수 있게 kernel에게 전달해줌. Kernel은 이를 하드웨어에 이해할 수 있게 전달한다.  echo $0 : 현재 사용중인 쉘 확인 결국 쉘은 사용자의 Standard input…","html":"<h2 id=\"shell\" style=\"position:relative;\"><a href=\"#shell\" aria-label=\"shell permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Shell</h2>\n<img width=\"490\" alt=\"&#xC2A4;&#xD06C;&#xB9B0;&#xC0F7; 2019-11-09 &#xC624;&#xD6C4; 3 11 44\" src=\"https://user-images.githubusercontent.com/39187116/68523950-5390b880-0303-11ea-9a27-045c2c85612e.png\">\n<ul>\n<li>harware - 컴퓨터의 기계적인 부분들 ( 메모리, 하드디스크 ,SSD, CPU 등등..)</li>\n<li>Kernel - 하드웨어를 제어하는 프로그램 ( 운영체제에서 코어역할을 한다.)</li>\n<li>Shell - 우리가 입력한 명령을 Kernel이 이해할수 있게 kernel에게 전달해줌. Kernel은 이를 하드웨어에 이해할 수 있게 전달한다. </li>\n<li><code>echo </code>$0 : 현재 사용중인 쉘 확인</li>\n<li>결국 쉘은 사용자의 Standard input(키보드)을 받아서 커널이 이해할 수 있게 커널에 전달하고, 커널은 이를 하드웨어에 전달하여 처리하고, 이 결과를 쉘이 받아서 Standard output이나 Standard error로 사용자에게 전달하여 상호작용하는 소프트웨어 이다.</li>\n</ul>\n<br/>\n<h2 id=\"shell-script\" style=\"position:relative;\"><a href=\"#shell-script\" aria-label=\"shell script permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Shell Script</h2>\n<ul>\n<li><code>/bin directory</code> : 유닉스 계열의 컴퓨터에 기본적으로 존재하는 프로그램들이 위치한 directory</li>\n</ul>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">$ <span class=\"token function\">nano</span> backup\n<span class=\"token punctuation\">..</span>.backup 파일 start\n<span class=\"token comment\">#!/bin/bash </span>\n<span class=\"token keyword\">if</span> <span class=\"token operator\">!</span> <span class=\"token punctuation\">[</span> -d bak <span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span> <span class=\"token keyword\">then</span> //현재 디렉토리에 bak라는 directory가 존재하지 않는다면?\n\t<span class=\"token function\">mkdir</span> bak\n<span class=\"token keyword\">fi</span> //if를 거꾸로 쓰면 조건문이 끝났다는 것을 컴퓨터에 알림\n<span class=\"token function\">cp</span> *.log bak // 현재 디렉토리의 log로 끝나는 파일들을 bak에 복사</code></pre></div>\n<ul>\n<li><code>#!/bin/bash</code> :  이 줄 밑에 작성된 코드들이 /bin/bash 라는 프로그램을 통해서 해석되어야 한다. 라는 약속 ( /bin/bash 는 example )</li>\n<li><code>./[filename]</code> : 현재 경로의 파일 실행</li>\n</ul>\n<img width=\"473\" alt=\"&#xC2A4;&#xD06C;&#xB9B0;&#xC0F7; 2019-11-09 &#xC624;&#xD6C4; 4 00 37\" src=\"https://user-images.githubusercontent.com/39187116/68524432-1e3b9900-030a-11ea-9ce9-6f909a6b1334.png\">\n<ul>\n<li>실행 권한이 없기 때문에 <code>’./backup’ is not executable by this user (또는 Permisssion denied)</code> 라는 Standard error가 나왔다.(<code>ls -l</code> 로 나온 output을 보면 backup 파일에 x 권한이 없음.)  실행 권한을 주기 위해서는 <code>chmod ( change mode )</code> 명령어에 <code>+x (executable)</code> 권한을 추가 해줬다.</li>\n</ul>","frontmatter":{"title":"생활코딩 리눅스 강좌(Shell)","date":"November 09, 2019"}}},"pageContext":{"slug":"/linux/생활코딩-리눅스-강좌(shell)/","previous":{"fields":{"slug":"/linux/생활코딩-리눅스-강좌(IO-Redirection)/"},"frontmatter":{"title":"생활코딩 리눅스 강좌(IO Redirection)","category":"linux"}},"next":{"fields":{"slug":"/python/파이썬-기초-정리(print,-variable)/"},"frontmatter":{"title":"파이썬 기초 정리(print, variable)","category":"python"}}}},"staticQueryHashes":["3128451518","96099027"]}