Skip to content

Commit aea20f1

Browse files
committed
updating html for 5.3 release, May 13
1 parent 0119051 commit aea20f1

File tree

10 files changed

+82
-75
lines changed

10 files changed

+82
-75
lines changed

00-intro.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h1 class="title">The Unix Shell</h1>
3030
<h2 class="subtitle">Introducing the Shell</h2>
3131
<section class="objectives panel panel-warning">
3232
<div class="panel-heading">
33-
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
33+
<h2 id="learning-objectives"><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
3434
</div>
3535
<div class="panel-body">
3636
<ul>

01-filedir.html

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h1 class="title">The Unix Shell</h1>
3030
<h2 class="subtitle">Files and Directories</h2>
3131
<section class="objectives panel panel-warning">
3232
<div class="panel-heading">
33-
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
33+
<h2 id="learning-objectives"><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
3434
</div>
3535
<div class="panel-body">
3636
<ul>
@@ -62,15 +62,15 @@ <h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2
6262
<pre class="output"><code>/Users/nelle</code></pre>
6363
<aside class="callout panel panel-info">
6464
<div class="panel-heading">
65-
<h2><span class="glyphicon glyphicon-pushpin"></span>Home directory</h2>
65+
<h2 id="home-directory"><span class="glyphicon glyphicon-pushpin"></span>Home directory</h2>
6666
</div>
6767
<div class="panel-body">
6868
<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>
6969
</div>
7070
</aside>
7171
<aside class="callout panel panel-info">
7272
<div class="panel-heading">
73-
<h2><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
73+
<h2 id="alphabet-soup"><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
7474
</div>
7575
<div class="panel-body">
7676
<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>
@@ -79,12 +79,14 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
7979
<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>
8080
<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>
8181
<div class="figure">
82-
<img src="fig/filesystem.svg" alt="The File System" /><p class="caption">The File System</p>
82+
<img src="fig/filesystem.svg" alt="The File System" />
83+
<p class="caption">The File System</p>
8384
</div>
8485
<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>
8586
<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>
8687
<div class="figure">
87-
<img src="fig/home-directories.svg" alt="Home Directories" /><p class="caption">Home Directories</p>
88+
<img src="fig/home-directories.svg" alt="Home Directories" />
89+
<p class="caption">Home Directories</p>
8890
</div>
8991
<blockquote>
9092
<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>
@@ -95,7 +97,8 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
9597
data north-pacific-gyre solar.pdf
9698
Desktop notes.txt writing</code></pre>
9799
<div class="figure">
98-
<img src="fig/homedir.svg" alt="Nelle’s Home Directory" /><p class="caption">Nelle’s Home Directory</p>
100+
<img src="fig/homedir.svg" alt="Nelle’s Home Directory" />
101+
<p class="caption">Nelle’s Home Directory</p>
99102
</div>
100103
<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>
101104
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">ls</span> -F</code></pre>
@@ -105,7 +108,7 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>Alphabet Soup</h2>
105108
<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>
106109
<aside class="callout panel panel-info">
107110
<div class="panel-heading">
108-
<h2><span class="glyphicon glyphicon-pushpin"></span>What’s In A Name?</h2>
111+
<h2 id="whats-in-a-name"><span class="glyphicon glyphicon-pushpin"></span>What’s In A Name?</h2>
109112
</div>
110113
<div class="panel-body">
111114
<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>
@@ -121,7 +124,7 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>What’s In A Name?</h2>
121124
<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>
122125
<aside class="callout panel panel-info">
123126
<div class="panel-heading">
124-
<h2><span class="glyphicon glyphicon-pushpin"></span>Parameters vs. Arguments</h2>
127+
<h2 id="parameters-vs.arguments"><span class="glyphicon glyphicon-pushpin"></span>Parameters vs. Arguments</h2>
125128
</div>
126129
<div class="panel-body">
127130
<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>
@@ -165,13 +168,13 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>Parameters vs. Arguments</
165168
<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>
166169
<aside class="callout panel panel-info">
167170
<div class="panel-heading">
168-
<h2><span class="glyphicon glyphicon-pushpin"></span>Orthogonality</h2>
171+
<h2 id="orthogonality"><span class="glyphicon glyphicon-pushpin"></span>Orthogonality</h2>
169172
</div>
170173
<div class="panel-body">
171174
<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>
172175
</div>
173176
</aside>
174-
<h3 id="nelles-pipeline-organizing-files">Nelle’s Pipeline: Organizing Files</h3>
177+
<h2 id="nelles-pipeline-organizing-files">Nelle’s Pipeline: Organizing Files</h2>
175178
<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>
176179
<blockquote>
177180
<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>
@@ -185,11 +188,12 @@ <h3 id="nelles-pipeline-organizing-files">Nelle’s Pipeline: Organizing Files</
185188
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">ls</span> north-pacific-gyre/</code></pre>
186189
<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>
187190
<div class="figure">
188-
<img src="fig/filesystem-challenge.svg" alt="File System for Challange Questions" /><p class="caption">File System for Challange Questions</p>
191+
<img src="fig/filesystem-challenge.svg" alt="File System for Challange Questions" />
192+
<p class="caption">File System for Challange Questions</p>
189193
</div>
190194
<section class="challenge panel panel-success">
191195
<div class="panel-heading">
192-
<h2><span class="glyphicon glyphicon-pencil"></span>Relative path resolution</h2>
196+
<h2 id="relative-path-resolution"><span class="glyphicon glyphicon-pencil"></span>Relative path resolution</h2>
193197
</div>
194198
<div class="panel-body">
195199
<p>If <code>pwd</code> displays <code>/Users/thing</code>, what will <code>ls ../backup</code> display?</p>
@@ -203,7 +207,7 @@ <h2><span class="glyphicon glyphicon-pencil"></span>Relative path resolution</h2
203207
</section>
204208
<section class="challenge panel panel-success">
205209
<div class="panel-heading">
206-
<h2><span class="glyphicon glyphicon-pencil"></span><code>ls</code> reading comprehension</h2>
210+
<h2 id="ls-reading-comprehension"><span class="glyphicon glyphicon-pencil"></span><code>ls</code> reading comprehension</h2>
207211
</div>
208212
<div class="panel-body">
209213
<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>
@@ -218,7 +222,7 @@ <h2><span class="glyphicon glyphicon-pencil"></span><code>ls</code> reading comp
218222
</section>
219223
<section class="challenge panel panel-success">
220224
<div class="panel-heading">
221-
<h2><span class="glyphicon glyphicon-pencil"></span>Default <code>cd</code> action</h2>
225+
<h2 id="default-cd-action"><span class="glyphicon glyphicon-pencil"></span>Default <code>cd</code> action</h2>
222226
</div>
223227
<div class="panel-body">
224228
<p>What does the command <code>cd</code> without a directory name do?</p>
@@ -232,7 +236,7 @@ <h2><span class="glyphicon glyphicon-pencil"></span>Default <code>cd</code> acti
232236
</section>
233237
<section class="challenge panel panel-success">
234238
<div class="panel-heading">
235-
<h2><span class="glyphicon glyphicon-pencil"></span>Exploring more <code>ls</code> arguments</h2>
239+
<h2 id="exploring-more-ls-arguments"><span class="glyphicon glyphicon-pencil"></span>Exploring more <code>ls</code> arguments</h2>
236240
</div>
237241
<div class="panel-body">
238242
<p>What does the command <code>ls</code> do when used with the <code>-s</code> and <code>-h</code> arguments?</p>

0 commit comments

Comments
 (0)