Skip to content

Commit

Permalink
updating html for 5.3 release, May 13
Browse files Browse the repository at this point in the history
  • Loading branch information
gdevenyi committed May 14, 2015
1 parent 0119051 commit aea20f1
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 75 deletions.
2 changes: 1 addition & 1 deletion 00-intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1 class="title">The Unix Shell</h1>
<h2 class="subtitle">Introducing the Shell</h2>
<section class="objectives panel panel-warning">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
<h2 id="learning-objectives"><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
</div>
<div class="panel-body">
<ul>
Expand Down
34 changes: 19 additions & 15 deletions 01-filedir.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1 class="title">The Unix Shell</h1>
<h2 class="subtitle">Files and Directories</h2>
<section class="objectives panel panel-warning">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
<h2 id="learning-objectives"><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
</div>
<div class="panel-body">
<ul>
Expand Down Expand Up @@ -62,15 +62,15 @@ <h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2
<pre class="output"><code>/Users/nelle</code></pre>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>Home directory</h2>
<h2 id="home-directory"><span class="glyphicon glyphicon-pushpin"></span>Home directory</h2>
</div>
<div class="panel-body">
<p>The home directory path will look different on different operating systems. On Linux it will look like <code>/home/nelle</code>, and on Windows it will be similar to <code>C:\Documents and Settings\nelle</code>. Note that it may look slightly different for different versions of Windows.</p>
</div>
</aside>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
<h2 id="alphabet-soup"><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
</div>
<div class="panel-body">
<p>If the command to find out who we are is <code>whoami</code>, the command to find out where we are ought to be called <code>whereami</code>, so why is it <code>pwd</code> instead? The usual answer is that in the early 1970s, when Unix was first being developed, every keystroke counted: the devices of the day were slow, and backspacing on a teletype was so painful that cutting the number of keystrokes in order to cut the number of typing mistakes was actually a win for usability. The reality is that commands were added to Unix one by one, without any master plan, by people who were immersed in its jargon. The result is as inconsistent as the roolz uv Inglish speling, but we’re stuck with it now.</p>
Expand All @@ -79,12 +79,14 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
<p>To understand what a “home directory” is, let’s have a look at how the file system as a whole is organized. At the top is the <strong>root directory</strong> that holds everything else. We refer to it using a slash character <code>/</code> on its own; this is the leading slash in <code>/Users/nelle</code>.</p>
<p>Inside that directory are several other directories: <code>bin</code> (which is where some built-in programs are stored), <code>data</code> (for miscellaneous data files), <code>users</code> (where users’ personal directories are located), <code>tmp</code> (for temporary files that don’t need to be stored long-term), and so on:</p>
<div class="figure">
<img src="fig/filesystem.svg" alt="The File System" /><p class="caption">The File System</p>
<img src="fig/filesystem.svg" alt="The File System" />
<p class="caption">The File System</p>
</div>
<p>We know that our current working directory <code>/Users/nelle</code> is stored inside <code>/Users</code> because <code>/Users</code> is the first part of its name. Similarly, we know that <code>/Users</code> is stored inside the root directory <code>/</code> because its name begins with <code>/</code>.</p>
<p>Underneath <code>/Users</code>, we find one directory for each user with an account on this machine. The Mummy’s files are stored in <code>/Users/imhotep</code>, Wolfman’s in <code>/Users/larry</code>, and ours in <code>/Users/nelle</code>, which is why <code>nelle</code> is the last part of the directory’s name.</p>
<div class="figure">
<img src="fig/home-directories.svg" alt="Home Directories" /><p class="caption">Home Directories</p>
<img src="fig/home-directories.svg" alt="Home Directories" />
<p class="caption">Home Directories</p>
</div>
<blockquote>
<p>Notice that there are two meanings for the <code>/</code> character. When it appears at the front of a file or directory name, it refers to the root directory. When it appears <em>inside</em> a name, it’s just a separator.</p>
Expand All @@ -95,7 +97,8 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
data north-pacific-gyre solar.pdf
Desktop notes.txt writing</code></pre>
<div class="figure">
<img src="fig/homedir.svg" alt="Nelle’s Home Directory" /><p class="caption">Nelle’s Home Directory</p>
<img src="fig/homedir.svg" alt="Nelle’s Home Directory" />
<p class="caption">Nelle’s Home Directory</p>
</div>
<p><code>ls</code> prints the names of the files and directories in the current directory in alphabetical order, arranged neatly into columns. We can make its output more comprehensible by using the <strong>flag</strong> <code>-F</code>, which tells <code>ls</code> to add a trailing <code>/</code> to the names of directories:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">ls</span> -F</code></pre>
Expand All @@ -105,7 +108,7 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
<p>Here, we can see that <code>/Users/nelle</code> contains six <strong>sub-directories</strong>. The names that don’t have trailing slashes, like <code>notes.txt</code>, <code>pizza.cfg</code>, and <code>solar.pdf</code>, are plain old files. And note that there is a space between <code>ls</code> and <code>-F</code>: without it, the shell thinks we’re trying to run a command called <code>ls-F</code>, which doesn’t exist.</p>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>What’s In A Name?</h2>
<h2 id="whats-in-a-name"><span class="glyphicon glyphicon-pushpin"></span>What’s In A Name?</h2>
</div>
<div class="panel-body">
<p>You may have noticed that all of Nelle’s files’ names are “something dot something”. This is just a convention: we can call a file <code>mythesis</code> or almost anything else we want. However, most people use two-part names most of the time to help them (and their programs) tell different kinds of files apart. The second part of such a name is called the <strong>filename extension</strong>, and indicates what type of data the file holds: <code>.txt</code> signals a plain text file, <code>.pdf</code> indicates a PDF document, <code>.cfg</code> is a configuration file full of parameters for some program or other, and so on.</p>
Expand All @@ -121,7 +124,7 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>What’s In A Name?</h2>
<p>Notice, by the way that we spelled the directory name <code>data</code>. It doesn’t have a trailing slash: that’s added to directory names by <code>ls</code> when we use the <code>-F</code> flag to help us tell things apart. And it doesn’t begin with a slash because it’s a <strong>relative path</strong>, i.e., it tells <code>ls</code> how to find something from where we are, rather than from the root of the file system.</p>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>Parameters vs. Arguments</h2>
<h2 id="parameters-vs.arguments"><span class="glyphicon glyphicon-pushpin"></span>Parameters vs. Arguments</h2>
</div>
<div class="panel-body">
<p>According to <a href="https://en.wikipedia.org/wiki/Parameter_(computer_programming)#Parameters_and_arguments">Wikipedia</a>, the terms argument and <strong>parameter</strong> mean slightly different things. In practice, however, most people use them interchangeably or inconsistently, so we will too.</p>
Expand Down Expand Up @@ -165,13 +168,13 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>Parameters vs. Arguments</
<p><code>-a</code> stands for “show all”; it forces <code>ls</code> to show us file and directory names that begin with <code>.</code>, such as <code>..</code> (which, if we’re in <code>/Users/nelle</code>, refers to the <code>/Users</code> directory). As you can see, it also displays another special directory that’s just called <code>.</code>, which means “the current working directory”. It may seem redundant to have a name for it, but we’ll see some uses for it soon. Finally, we also see a file called <code>.bash_profile</code>. This file usually contains settings to customize the shell (terminal). For this lesson material it does not contain any settings. There may also be similar files called <code>.bashrc</code> or <code>.bash_login</code>. The <code>.</code> prefix is used to prevent these configuration files from cluttering the terminal when a standard <code>ls</code> command is used.</p>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>Orthogonality</h2>
<h2 id="orthogonality"><span class="glyphicon glyphicon-pushpin"></span>Orthogonality</h2>
</div>
<div class="panel-body">
<p>The special names <code>.</code> and <code>..</code> don’t belong to <code>ls</code>; they are interpreted the same way by every program. For example, if we are in <code>/Users/nelle/data</code>, the command <code>ls ..</code> will give us a listing of <code>/Users/nelle</code>. When the meanings of the parts are the same no matter how they’re combined, programmers say they are <strong>orthogonal</strong>: Orthogonal systems tend to be easier for people to learn because there are fewer special cases and exceptions to keep track of.</p>
</div>
</aside>
<h3 id="nelles-pipeline-organizing-files">Nelle’s Pipeline: Organizing Files</h3>
<h2 id="nelles-pipeline-organizing-files">Nelle’s Pipeline: Organizing Files</h2>
<p>Knowing just this much about files and directories, Nelle is ready to organize the files that the protein assay machine will create. First, she creates a directory called <code>north-pacific-gyre</code> (to remind herself where the data came from). Inside that, she creates a directory called <code>2012-07-03</code>, which is the date she started processing the samples. She used to use names like <code>conference-paper</code> and <code>revised-results</code>, but she found them hard to understand after a couple of years. (The final straw was when she found herself creating a directory called <code>revised-revised-results-3</code>.)</p>
<blockquote>
<p>Nelle names her directories “year-month-day”, with leading zeroes for months and days, because the shell displays file and directory names in alphabetical order. If she used month names, December would come before July; if she didn’t use leading zeroes, November (‘11’) would come before July (‘7’).</p>
Expand All @@ -185,11 +188,12 @@ <h3 id="nelles-pipeline-organizing-files">Nelle’s Pipeline: Organizing Files</
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">ls</span> north-pacific-gyre/</code></pre>
<p>If she presses tab again, Bash will add <code>2012-07-03/</code> to the command, since it’s the only possible completion. Pressing tab again does nothing, since there are 1520 possibilities; pressing tab twice brings up a list of all the files, and so on. This is called <strong>tab completion</strong>, and we will see it in many other tools as we go on.</p>
<div class="figure">
<img src="fig/filesystem-challenge.svg" alt="File System for Challange Questions" /><p class="caption">File System for Challange Questions</p>
<img src="fig/filesystem-challenge.svg" alt="File System for Challange Questions" />
<p class="caption">File System for Challange Questions</p>
</div>
<section class="challenge panel panel-success">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pencil"></span>Relative path resolution</h2>
<h2 id="relative-path-resolution"><span class="glyphicon glyphicon-pencil"></span>Relative path resolution</h2>
</div>
<div class="panel-body">
<p>If <code>pwd</code> displays <code>/Users/thing</code>, what will <code>ls ../backup</code> display?</p>
Expand All @@ -203,7 +207,7 @@ <h2><span class="glyphicon glyphicon-pencil"></span>Relative path resolution</h2
</section>
<section class="challenge panel panel-success">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pencil"></span><code>ls</code> reading comprehension</h2>
<h2 id="ls-reading-comprehension"><span class="glyphicon glyphicon-pencil"></span><code>ls</code> reading comprehension</h2>
</div>
<div class="panel-body">
<p>If <code>pwd</code> displays <code>/Users/backup</code>, and <code>-r</code> tells <code>ls</code> to display things in reverse order, what command will display:</p>
Expand All @@ -218,7 +222,7 @@ <h2><span class="glyphicon glyphicon-pencil"></span><code>ls</code> reading comp
</section>
<section class="challenge panel panel-success">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pencil"></span>Default <code>cd</code> action</h2>
<h2 id="default-cd-action"><span class="glyphicon glyphicon-pencil"></span>Default <code>cd</code> action</h2>
</div>
<div class="panel-body">
<p>What does the command <code>cd</code> without a directory name do?</p>
Expand All @@ -232,7 +236,7 @@ <h2><span class="glyphicon glyphicon-pencil"></span>Default <code>cd</code> acti
</section>
<section class="challenge panel panel-success">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pencil"></span>Exploring more <code>ls</code> arguments</h2>
<h2 id="exploring-more-ls-arguments"><span class="glyphicon glyphicon-pencil"></span>Exploring more <code>ls</code> arguments</h2>
</div>
<div class="panel-body">
<p>What does the command <code>ls</code> do when used with the <code>-s</code> and <code>-h</code> arguments?</p>
Expand Down
Loading

0 comments on commit aea20f1

Please sign in to comment.