forked from swcarpentry/shell-novice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discussion.html
87 lines (85 loc) · 6.28 KB
/
discussion.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title>Software Carpentry: The Unix Shell</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-theme.css" />
<link rel="stylesheet" type="text/css" href="css/swc.css" />
<link rel="alternate" type="application/rss+xml" title="Software Carpentry Blog" href="http://software-carpentry.org/feed.xml"/>
<meta charset="UTF-8" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body class="lesson">
<div class="container card">
<div class="banner">
<a href="http://software-carpentry.org" title="Software Carpentry">
<img alt="Software Carpentry banner" src="img/software-carpentry-banner.png" />
</a>
</div>
<article>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<a href="index.html"><h1 class="title">The Unix Shell</h1></a>
<h2 class="subtitle">Discussion</h2>
<h2 id="alphabet-soup" class="callout">Alphabet Soup</h2>
<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>
<h2 id="job-control-codes">Job Control Codes</h2>
<p>The shell accepts a few special commands that allow users to interact with running processes or programs. You can enter each of these “control codes” by holding down the Ctrl key and then pressing one of the control characters. In other tutorials, you may see the term “Control” or the <code>^</code> used to represent the Ctrl key (e.g. the following are all equivalent Ctrl-C, Ctrl+C, Control-C, Control+C, <code>^C</code>).</p>
<table>
<thead>
<tr class="header">
<th align="left">Control Code</th>
<th align="left">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">Ctrl-C</td>
<td align="left">Interrupts and cancels a running program. This is useful if you want to cancel a command that is taking too long to execute.</td>
</tr>
<tr class="even">
<td align="left">Ctrl-D</td>
<td align="left">Indicates the end of a file or stream of characters that you are entering on the command line. For example, we saw earlier that the <code>wc</code> command counts lines, words, and characters in a file. If we just type <code>wc</code> and hit the Enter key without providing a file name, then <code>wc</code> will assume we want it to analyze all the stuff we type next. After typing our magnum opus directly into the shell prompt, we can then type Ctrl-D to tell <code>wc</code> that we’re done and we’d like to see the results of the word count.</td>
</tr>
<tr class="odd">
<td align="left">Ctrl-Z</td>
<td align="left">Suspends a process but does not terminate it. You can then use the command <code>fg</code> to restart the job in the foreground.</td>
</tr>
</tbody>
</table>
<p>For new shell users, these control codes can all appear to have the same effect: they make things “go away.” But it is helpful to understand the differences. In general, if something went wrong and you just want to get your shell prompt back, it is better to use Ctrl-C.</p>
<h2 id="other-shells">Other Shells</h2>
<p>Before Bash became popular in the end of nineties, scientists widely used (and some still use) another shell, C-shell, or Csh. Bash and Csh have similar feature sets, but their syntax rules are different and this makes them incompatible with each other. A few other shells have appeared since, including ksh, zsh, and a number of others; they are mostly compatible with Bash, and Bash is the default shell on most modern implementations of Unix (including most packages that provide Unix-like tools for Windows) but if you get strange errors in shell scripts written by colleagues, check to see which shell they were written for.</p>
<h2 id="bash-configurations">Bash Configurations</h2>
<p>Want to customize paths, environment variables, aliases, and other behaviors of your bash? Learn tips, tricks, and how to avoid dangers with this excellent blog on <a href="http://dghubble.com/blog/posts/.bashprofile-.profile-and-.bashrc-conventions/">Bash Configurations Demystified</a> from Dalton Hubble.</p>
</div>
</div>
</article>
<div class="footer">
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/shell-novice">Source</a>
<a class="label swc-blue-bg" href="mailto:[email protected]">Contact</a>
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
</div>
</div>
<!-- Javascript placed at the end of the document so the pages load faster -->
<script src="http://software-carpentry.org/v5/js/jquery-1.9.1.min.js"></script>
<script src="css/bootstrap/bootstrap-js/bootstrap.js"></script>
<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-37305346-2', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>