{"id":1454,"date":"2018-10-30T05:28:33","date_gmt":"2018-10-30T05:28:33","guid":{"rendered":"https:\/\/www.courses.tegabrain.com\/cc18\/?page_id=1454"},"modified":"2018-11-01T18:17:46","modified_gmt":"2018-11-01T18:17:46","slug":"github-and-command-line-basics","status":"publish","type":"page","link":"https:\/\/www.courses.tegabrain.com\/cc18\/github-and-command-line-basics\/","title":{"rendered":"Command Line Basics"},"content":{"rendered":"<p>The command line is a text-based interface for interacting with your computer. From the command line you can launch programs, view files, and manipulate your file system by making, moving, and copying files and directories. You can think of it as the Finder in Mac, without the graphic interface, but much more powerful.<\/p>\n<h4>Setup<\/h4>\n<ul>\n<li>On a Mac you can access the command line by opening up the <code>Terminal<\/code> application, located in <code>\/Applications\/Utilities\/Terminal<\/code><\/li>\n<li>On Windows follow the instructions to install git below and then <a href=\"https:\/\/gitforwindows.org\/\">use the gitbash to access the terminal.<\/a><\/li>\n<\/ul>\n<h4>The Prompt<\/h4>\n<p>When you open up your terminal application you&#8217;ll see something like this:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre>SamsComputer:<span class=\"pl-k\">~<\/span> sam$<\/pre>\n<\/div>\n<p>This is called the &#8220;prompt&#8221;. By default (on a Mac) it shows the name of the computer, the directory that you are currently in, your username, and then a $ sign.<\/p>\n<p>The basic use of the command line is: 1) you type a command, 2) you hit return, and 3) some output of the command is printed to the screen.<\/p>\n<h4>Basic Navigation &amp; File Operations<\/h4>\n<p><em>Please note I use the word &#8220;directory&#8221; and &#8220;folder&#8221; interchangeably.<\/em><\/p>\n<p>When you open a new terminal window, you are placed inside your home folder. On a Mac this is <code>\/Users\/myusername<\/code> and on Linux, <code>\/home\/myusername<\/code>.<\/p>\n<p>To see the folder you are currently in, type: <code>pwd<\/code> and hit return. <code>pwd<\/code> stands for &#8220;print working directory&#8221;, or in other words, &#8220;show me the directory I am currently working from&#8221;.<\/p>\n<h4>Here are some basic commands for getting around, making, deleting and copying files and folders.<\/h4>\n<p><strong><code>pwd<\/code><\/strong> stands for &#8220;print working directory&#8221;. It prints out where you are:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre><span class=\"pl-c1\">pwd<\/span><\/pre>\n<\/div>\n<p><strong><code>ls<\/code><\/strong> stands for &#8220;list&#8221;. It lists the contents of current directory.<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre>ls<\/pre>\n<\/div>\n<p><strong><code>cd<\/code><\/strong> stands for &#8220;change directory&#8221;. Type <code>cd<\/code> and then the directory you want to go to. For example, change to the Desktop from your home folder:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre><span class=\"pl-c1\">cd<\/span> Desktop<\/pre>\n<\/div>\n<p>To go into the parent folder, up one level in the file structure, type <code>..<\/code> or <code>..\/<\/code> instead of a folder name, like so:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre><span class=\"pl-c1\">cd<\/span> ..<\/pre>\n<\/div>\n<p>If you type <code>cd<\/code> without a folder name after, it takes you back to your home folder.<\/p>\n<p><strong><code>mkdir<\/code><\/strong> stands for &#8220;make directory&#8221;. Type <code>mkdir<\/code> and then a name to make a folder. For example, make a folder called &#8220;cool_project&#8221;:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre>mkdir cool_project<\/pre>\n<\/div>\n<p><strong><code>mv<\/code><\/strong> stands for &#8220;move&#8221;. It lets you move files and folders and also rename them. To rename a file:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre>mv oldname.txt newname.txt<\/pre>\n<\/div>\n<p><strong><code>cp<\/code><\/strong> stands for &#8220;copy&#8221;. It lets duplicate files:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre>cp draft.txt draft_copy.txt<\/pre>\n<\/div>\n<p><strong><code>rm<\/code><\/strong> stands for &#8220;remove&#8221;. It lets you delete files:<\/p>\n<div class=\"highlight highlight-source-shell\">\n<pre>rm bad_selfie.jpg<\/pre>\n<\/div>\n<p>Please note, <code>rm<\/code> will <strong>not<\/strong> ask for confirmation, and it will not move files to the trash. It&#8217;ll just delete them immediately, so be careful.<\/p>\n<h4>Running a local server:<\/h4>\n<p>cd into the folder where you want to run the server. This should be where your p5 files are stored.<\/p>\n<p>Check what version of python you are running by typing python -v into the terminal.<\/p>\n<p>If python 2.7:<\/p>\n<pre><code>$\u00a0<\/code><span class=\"n\">python<\/span> <span class=\"o\">-<\/span><span class=\"n\">m<\/span> <span class=\"n\">SimpleHTTPServer<\/span> <span class=\"mi\">8000<\/span><\/pre>\n<p>If python 3:<\/p>\n<pre class=\"brush: bash\">python3 -m http.server 8000<\/pre>\n<p>You should then see<\/p>\n<pre><code>Serving HTTP on 0.0.0.0 port 8000 ...\r\n<\/code><\/pre>\n<p>This means the server is up and running at\u00a0<a href=\"http:\/\/en.wikipedia.org\/wiki\/Localhost\">localhost<\/a>\u00a0on port 8000. And this means you can type\u00a0<code>http:\/\/localhost:8000\/<\/code>\u00a0into the address of a web browser and I\u2019ll see:<\/p>\n<h4>Running a local server on Windows<\/h4>\n<p>Windows will require you to install Python to get a server set up. Follow the download and installation instructions <a href=\"https:\/\/www.python.org\/downloads\/\">here for Python 2.7.X.\u00a0<\/a><\/p>\n<ul>\n<li>You will also need to make sure that Git Bash recognizes python. You can do this temporarily with this command in Git Bash:\u00a0<code>PATH=$PATH:\/c\/Python36\/<\/code>\u00a0(or whatever version of python you are running). However if you want this to be permanent you\u2019ll need to add\u00a0<code>c:\\python36<\/code>\u00a0to your system environment variable\u00a0<code>path<\/code>.\u00a0<a href=\"http:\/\/www.computerhope.com\/issues\/ch000549.htm\">Here is how you access that.<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The command line is a text-based interface for interacting with your computer. From the command line you can launch programs, view files, and manipulate your file system by making, moving, and copying files and directories. You can think of it as the Finder in Mac, without the graphic interface, but much more powerful. Setup On<a class=\"more-link button\" href=\"https:\/\/www.courses.tegabrain.com\/cc18\/github-and-command-line-basics\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-1454","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/Paeb9f-ns","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/pages\/1454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/comments?post=1454"}],"version-history":[{"count":6,"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/pages\/1454\/revisions"}],"predecessor-version":[{"id":1587,"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/pages\/1454\/revisions\/1587"}],"wp:attachment":[{"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/media?parent=1454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}