
Miguel de Icaza: Learning Unix - alexkay
http://tirania.org/blog/archive/2011/Sep-06.html
======
foob
I would like to add the Advanced Bash-Scripting Guide
(<http://tldp.org/LDP/abs/html/>) as an incredible resource. It's obviously
geared towards scripting but most of what it teaches is extremely useful for
working in an interactive shell as well. I had been using linux and bash for
years before I read it and I still picked up quite a bit when I finally got
around to working through it.

~~~
gecko
The only thing I don't quite grok is that, as the complexity of a given bash
script increases, it moves ever-closer to looking exactly like the well-
written-by-90s-standards Perl I remember from when I was just learning Unix.

Given that Perl's about as ubiquitous as bash (and arguably more so, since I
literally don't know any mainstream *nix that ships without Perl in the core,
and I know several that ship without bash), why not just use Perl in the first
place? This is exactly what it was designed to do well, back in the beginning.

~~~
Scaevolus
Learning the different things you can do with bash scripts, especially the
string operations, made me a lot faster at doing batch tasks from the command-
line.

For longer-term scripts over a few lines, it's easier to use a powerful
language you're comfortable with (maybe one of Perl, Python, Ruby) than to
waste time (re)learning shell scripting whenever you need to extend the
script.

~~~
peterwwillis
Since OP's subject is becoming a better Unix hacker, I recommend staying away
from Bash's more advanced (or just useful) features. The more Unix you touch,
the more you realize you can't rely on Bash to work how you expect it across
all different systems (if they have Bash installed). You will end up relying
more on sed, awk, grep and your shell scripting will become more generic - but
more portable.

On the other hand, Perl rarely changes. If you find yourself forced into a
Perl 4 system you can still use the basics of Perl 5. IMO, if you have a
relatively complex job to perform, Perl is going to be more reliable than
Bash.

~~~
spudlyo
Most shell scripts are a collection of undeclared external dependencies. You
can't really rely on sed, awk, and grep to behave the same way on Linux as
they do on Solaris or AIX.

It seems like if you're concerned with portability, you shouldn't be writing a
shell script in the first place.

~~~
peterwwillis
Au contraire, shell script in a (real) POSIX environment is one of the most
portable things... It's interpreted and there's always some kind of shell on
any Unix system, unlike other interpreted languages. That's why lots of 3rd
party vendors use shell scripts to package their setup tools.

Yes the tools behave differently on different systems, but 99.9% of the time
there's very basic syntax that is respected across all versions of the tools.
Stick to BSD4.4 C Shell syntax
(<http://docs.freebsd.org/44doc/usd/04.csh/paper.html>), don't rely on regular
expressions in grep, and stick to the very basics of sed and awk and you can
go pretty far in Unix.

Any of the following commands which existed on some archaic version of Unix
will still exist and their limited but useful functionality can be extended in
lots of ways, and is pretty darn portable.
[https://secure.wikimedia.org/wikipedia/en/wiki/List_of_Unix_...](https://secure.wikimedia.org/wikipedia/en/wiki/List_of_Unix_utilities)

------
sb
Hm, instead of MC I prefer dired+ within Emacs, I have never used anything
more powerful than this (particularly with TRAMP and the regex features.) So,
if you are already learning Emacs, I think it pays off to at least take a look
at dired(+).

(Minor remark: for smaller tasks [and instead of launching a terminal window]
I prefer to use the DirOpus clone "worker" on UNIX.)

------
gradstudent
Does anyone else find it deliciously ironic that, in such a pro-Unix article,
Miguel recommends Mavis Beacon? According to Amazon, it's available only for
Windows and OSX :p

~~~
skb_
I'm surprised he didn't recommend gtype, it's probably the best and fastest
way to learn how to type in that there are no unnecessary graphics and you
need not ever touch a mouse. Fits the Unix approach much better imo.

~~~
rbanffy
apt-get install gtype didn't work ;-) Googling for it led to a couple false
hints, dead-ends and lots of information about viruses (not the computer kind)

~~~
FraaJad
gtypist -- <http://www.gnu.org/s/gtypist/>

~~~
rbanffy
Thanks!

~~~
skb_
oops, sorry about that :). I guess my inability to remember names extends to
software as well.

------
shaggyfrog
I still have my copy of UNIX for the Impatient I bought in 1997 and I still
find myself referring to it occasionally (less so these days, with Internet
references being more accessible generally). Quite a thing for that book to
stand the test of time so well to still find it recommended -- 1995 edition
and all. The C equivalent would probably be Advanced Programming in the UNIX
Environment.

------
RyanMcGreal
I loved this:

> Save yourself the embarrassment, and avoid posting on the comments section
> jwz's quote on regular expressions. You are not jwz.

~~~
dools
I personally though this was quite hilarious:

 _"But unless you touch-type, you are neither awesome, nor you are in a
position to judge the qualities of the world as an oyster or any James Cameron
movies."_

Thoroughly enjoyable read I must say.

------
juiceandjuice
Are most people not touch typers? I've noticed my boss isn't really a touch
typer, despite programming since before I was born, but I always assumed the
majority of CS people were.

~~~
super_mario
I'm always shocked to see a developer not touch type. I just can't understand
those 10% or so, that spend their life essentially editing text and yet can't
touch type. It's one of those essential skills that you learn once and reap
the benefits for the rest of your life.

~~~
mekoka
Where do you get 10% from? Most programmers are fast on a keyboard, but being
fast != touch-typing. Admittedly, not all touch-typists train their fingers to
properly remember the numbers row or the set of accompanying punctuations and
symbols, they might sometimes need to look at the keyboard to find stuff like
tilde, pipe or the underscore.

However, if you catch yourself needing to even just glance at the keyboard
while typing basic stuff, you're not a touch-typist, no matter how fast you
are.

Many people feel that being fast is good enough. It has been my observation
though, that the lag between typos and their fix is considerably shorter
(almost instantaneous) for touch-typists (they're looking at the screen as
it's happening). Indeed, I'm always a tiny bit annoyed when while sitting next
to someone editing code, they accidentally turn on caps and it takes forever
for them to realize it (like 10 characters later).

------
LeafStorm
I need to remember this one: "And you will offer to buy me a beer, which I
will refuse because I rather have you buy me a freshly squeezed orange juice."

~~~
bitops
That could be considered the "Beer Ware" license for San Francisco in the 21st
century. And it should be certified organic/vegan/etc.

~~~
middus
I created a "license" and put in on GitHub:
[https://github.com/felixmiddendorf/ojware-
license/blob/maste...](https://github.com/felixmiddendorf/ojware-
license/blob/master/en) <http://news.ycombinator.com/item?id=2984233>

------
tingletech
in a computer lab between pepper canyon and warren college at UCSD in 1991 it
was written to type 'man man' and maybe even 'apropos' was written up there on
a chalk board. I taught myself unix from the manual. A few years later, I
learned perl starting with 'perldoc perldoc'.

~~~
flatwhatson
In all my years of using and loving (and abusing) the shell, I've never
encountered apropos. I'm really amazed that something so fundamental has
somehow been left out of the many unix/shell articles (such as this one) that
I've read. Anyhow, you've made my day. Thanks!

------
bostonvaulter2
Does anyone know any good online typing tutors? Especially for people who are
already reasonably proficient (~60 wpm)

~~~
shawndumas
not on-line but... <http://www.gnu.org/s/gtypist/>

------
sciurus
He's right when he says Unix Power tools "is the atomic bomb of Unix
knowledge".

------
dmboyd
Mavis beacon teaches typing.. Seriously?

~~~
andrewhare
He sounded pretty serious to me. Do you have a better suggestion? The Mavis
Beacon software does a perfectly fine job at teaching touch-typing.

~~~
okal
GNU gtypist. Got me from "hunt and peck" to touch typing with a decent wpm
count within 2 weeks. Considering I used fewer than half of the tutorials, I
think that's pretty awesome. It's an old GNU utility so it should be in any
repos. Even had it on Cygwin.

~~~
angus77
That's exactly how I learned---I'd say it took me two weeks, to, to become
comfortable with typing. I've been recommending learning to touch type that
way for a few years now. Not a soul has taken me up on it yet.

------
kasperset
Another good book with historical perspective. Harley Hahn's Guide to Unix and
Linux

------
pointyhat
Without starting a religious war, it's essential to learn the basics of vi for
it is ubiquitous on all UNIX variants. Even if you use emacs, it's essential
knowledge.

~~~
davidw
While this argument might have held weight once, I think these factors
undermine it:

Emacs used to be considered 'expensive' in terms of disk/memory. These days,
it really isn't.

Non-Linux unixes are less and less of a factor these days, and even most of
those have some sort of packaging system where installing emacs is a quick
operation, rather than a laborious download/compile/install.

Emacs itself has remote editing capabilities with Tramp, via ssh that obviates
the need to fire up an editor on the target machine in some cases.

If your job involves sitting down at HPUX/Irix/AIX/whatever machines that
haven't been updated since 1998, and don't allow remote access, yes, vi is
probably a valuable skill. Otherwise, I think this argument is less important
than it once was.

~~~
Goladus
It's still valid. I haven't had to use vi in awhile but there are still a lot
of OSes that don't have emacs installed by default. And every so often you'll
wind up on a system where EDITOR isn't set and you'll get stuck in vi by
accident.

The thing is, though, the subset of vi you have to learn to is relatively
small. You need to know how to enter and leave insert mode, how to delete, and
how to quit with and without saving. (For a non-vi user, the difference
between knowing and not knowing those simple things is significant)

This is generally enough to edit the few configuration files you may need to
touch before you install emacs (network, sources.list, sudoers, etc).

So even though the use case is small and shrinking, the amount of "vi skill"
you need is pretty low as well. There's really no good excuse to avoid it.

~~~
niels_olson
> the subset of vi you have to learn to is relatively small. You need to know
> how to enter and leave insert mode, how to delete, and how to quit with and
> without saving. (For a non-vi user, the difference between knowing and not
> knowing those simple things is significant)

As a self-learner out in the wilderness, I don't know how I could have learned
Linux without learning that basic Vi alongside. And that really is all you
need to know.

------
gcb
learn unix ... use midnight commander.

lolwat?

~~~
jrockway
Keep in mind that the same person wrote both this blog post and Midnight
Commander.

~~~
gcb
and that validates midnight commander as a tool with the unix philosophy how?

downvote all you want. but a clone of norton commander was and always will be
a joke.

...saw several sysadmins using it to delete files named with dash because they
didn't know "--" is posix for stop taking flags. and that's just one bad vice
it foments.

~~~
angrycoder
> but a clone of norton commander was and always will be a joke

why?

P.S. - if you can answer without the elitist bullshit, people will probably
stop down voting you.

~~~
pivo
For me MC has always struck me as something someone uses as a crutch when
they're not interested in learning the "unix way" of doing things, which
usually means using the command line.

The idea of MC never appealed to me so I admit I've never used it. When I see
other people using it it seems awkward and slow, and the people using it never
seem to know much about unix. Of course it could be that they just don't know
the application well and it is in fact really fantastic. So my perception
could be completely wrong.

------
dramaticus3
Miguel, please learn Unix

