{"id":6,"date":"2017-01-16T07:40:21","date_gmt":"2017-01-16T07:40:21","guid":{"rendered":"http:\/\/courses.haigarmen.com\/intd320\/?p=6"},"modified":"2017-01-16T07:40:21","modified_gmt":"2017-01-16T07:40:21","slug":"raspberrypi-02-exploring-command-line-basics","status":"publish","type":"post","link":"https:\/\/courses.haigarmen.com\/intd320\/raspberrypi-02-exploring-command-line-basics\/","title":{"rendered":"RaspberryPi 02: Exploring Command Line Basics"},"content":{"rendered":"<h2>The command prompt<\/h2>\n<p>Now that you\u2019ve logged in you\u2019ll see a command prompt with:<\/p>\n<p><code>pi@raspberrypi ~ $<\/code><\/p>\n<p>What does it mean?<\/p>\n<ol>\n<li>The <code>pi<\/code> section is your username followed by <code>@<\/code>.<\/li>\n<li>The <code>raspberrypi<\/code> (the default hostname), the <code>~<\/code> is your current working directory.<\/li>\n<li>The <code>~<\/code> symbol is short hand for your home directory. When you log into your Raspberry Pi, you first land in your home directory.<\/li>\n<li>The tailing <code>$<\/code> is your shell prompt, anything you type to the right of it gets executed as commands.<\/li>\n<\/ol>\n<h2>Poking around the home directory<\/h2>\n<p>When you first login, you\u2019re in the home directory. The home directory is represented as <code>~<\/code> on the command prompt. The <code>~<\/code> character can be used as a shortcut to jump into your home directory.<\/p>\n<p>To see what\u2019s inside your home directory use the <em>ls<\/em> command.<\/p>\n<h2>Other Directories<\/h2>\n<p>Your home directory has the following path <code>\/home\/pi<\/code>. There are other folders\/directories above your home directory.<\/p>\n<p>Don\u2019t believe me? We can ask Linux to tell us what our current directory is by running:<\/p>\n<p><code>pwd<\/code><\/p>\n<p>you should see the following output:<\/p>\n<p><code>\/home\/pi<\/code><\/p>\n<p><em>pwd<\/em> stands for <em>print working directory<\/em>.<\/p>\n<h2>Changing directory<\/h2>\n<p>To change directory use the <em>cd<\/em> command. What did you think <em>cd<\/em> stands for?<\/p>\n<p><strong>Moving up a directory<\/strong><\/p>\n<p>To move up a directory from <em>pi\u2019s<\/em> home directory to the <code>\/home<\/code> directory use the following command:<\/p>\n<p><code>cd ..<\/code><\/p>\n<p>Now when you print the current working directory, you should see.<\/p>\n<p><code>\/home<\/code><\/p>\n<p>To go back to your home directory you would use the command:<\/p>\n<p><code>cd pi<\/code> however the following commands could also do the trick:<\/p>\n<ul>\n<li><code>cd \/home\/pi<\/code> (specifying the full path)<\/li>\n<li><code>cd ~<\/code> (using the <code>~<\/code> shorthand)<\/li>\n<li><code>cd<\/code> (even typing just <code>cd<\/code> takes you back to your home directory, the maker of <code>cd<\/code> sure hates to type extra characters)<\/li>\n<li><code>cd -<\/code> (the <code>-<\/code> argument takes us to the directory we were immediately previously in, so this command would also work)<\/li>\n<\/ul>\n<h2>Other directories<\/h2>\n<p>Of course there\u2019s more to your Pi than the <code>\/home<\/code> directory. Let\u2019s have an explore.<\/p>\n<p>The folder structure on your Raspberry Pi looks something like this (with your home directory highlighted).&#8217;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-61\" src=\"http:\/\/courses.haigarmen.com\/intd300\/files\/2016\/11\/folder-structure.png\" alt=\"folder-structure\" width=\"644\" height=\"682\" \/><\/p>\n<table>\n<thead>\n<tr>\n<th>Directory<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>\/<\/code><\/td>\n<td>The upper most of your hard disk (or SD Card)<\/td>\n<\/tr>\n<tr>\n<td><code>\/bin<\/code><\/td>\n<td>Programs and commands that all users can run<\/td>\n<\/tr>\n<tr>\n<td><code>\/boot<\/code><\/td>\n<td>All the files needed for booting your Raspberry Pi<\/td>\n<\/tr>\n<tr>\n<td><code>\/dev<\/code><\/td>\n<td>Files that represent devices on your Raspberry Pi<\/td>\n<\/tr>\n<tr>\n<td><code>\/etc<\/code><\/td>\n<td>Configuration files<\/td>\n<\/tr>\n<tr>\n<td><code>\/etc\/init.d<\/code><\/td>\n<td>Scripts to start, stop and otherwise command services<\/td>\n<\/tr>\n<tr>\n<td><code>\/etc\/X11<\/code><\/td>\n<td>X11 Configuration Files<\/td>\n<\/tr>\n<tr>\n<td><code>\/home<\/code><\/td>\n<td>All the user home directories (except for root\u2019s)<\/td>\n<\/tr>\n<tr>\n<td><code>\/home\/pi<\/code><\/td>\n<td>The Pi user\u2019s home directory<\/td>\n<\/tr>\n<tr>\n<td><code>\/lib<\/code><\/td>\n<td>This is where the Kernel modules \/ drivers live.<\/td>\n<\/tr>\n<tr>\n<td><code>\/media<\/code><\/td>\n<td>There is where hard disks, SD Cards and other removable media are mounted<\/td>\n<\/tr>\n<tr>\n<td><code>\/proc<\/code><\/td>\n<td>Virtual directory that provides details of running processes<\/td>\n<\/tr>\n<tr>\n<td><code>\/sbin<\/code><\/td>\n<td>Programs primarily used for systems maintenance<\/td>\n<\/tr>\n<tr>\n<td><code>\/sys<\/code><\/td>\n<td>Another special folder that represents hardware devices<\/td>\n<\/tr>\n<tr>\n<td><code>\/tmp<\/code><\/td>\n<td>A space for temporary files<\/td>\n<\/tr>\n<tr>\n<td><code>\/usr<\/code><\/td>\n<td>Programs and data usable by every user<\/td>\n<\/tr>\n<tr>\n<td><code>\/usr\/bin<\/code><\/td>\n<td>Most programs you\u2019ll run live in here<\/td>\n<\/tr>\n<tr>\n<td><code>\/usr\/lib<\/code><\/td>\n<td>Libraries to support programs and programming languages<\/td>\n<\/tr>\n<tr>\n<td><code>\/usr\/local<\/code><\/td>\n<td>By convention software specific to a machine goes here.<\/td>\n<\/tr>\n<tr>\n<td><code>\/usr\/sbin<\/code><\/td>\n<td>More system software<\/td>\n<\/tr>\n<tr>\n<td><code>\/usr\/share<\/code><\/td>\n<td>Supporting files that aren\u2019t specific to chip architecture<\/td>\n<\/tr>\n<tr>\n<td><code>\/usr\/src<\/code><\/td>\n<td>Source code!<\/td>\n<\/tr>\n<tr>\n<td><code>\/var<\/code><\/td>\n<td>System logs<\/td>\n<\/tr>\n<tr>\n<td><code>\/var\/backups<\/code><\/td>\n<td>Typically compressed copies of system logs<\/td>\n<\/tr>\n<tr>\n<td><code>\/var\/cache<\/code><\/td>\n<td>apt-get and other programs keep their data here<\/td>\n<\/tr>\n<tr>\n<td><code>\/var\/log\/<\/code><\/td>\n<td>All the system and service logs<\/td>\n<\/tr>\n<tr>\n<td><code>\/var\/mail<\/code><\/td>\n<td>This is where your mail goes (if you\u2019ve set it up)<\/td>\n<\/tr>\n<tr>\n<td><code>\/var\/spool<\/code><\/td>\n<td>Data that is waiting to be processed or dealt with lives here (e.g. mail or print jobs)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Ok, enough exploring let\u2019s see <a href=\"http:\/\/workshop.raspberrypiaustralia.com\/usb\/ttl\/connecting\/2014\/08\/31\/03_command-line-cheatsheet\/\">what other commands we can do on the Pi<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The command prompt Now that you\u2019ve logged in you\u2019ll see a command prompt with: pi@raspberrypi ~ $ What does it mean? The pi section is your username followed by @. The raspberrypi (the default hostname), the ~ is your current working directory. The ~ symbol is short hand for your home directory. When you log [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-6","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":1,"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":7,"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/posts\/6\/revisions\/7"}],"wp:attachment":[{"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/intd320\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}