Tips, Wisdom, and Advocacy...
on this page i try to transcribe many of the more useful things i have learned
computing. small easy things that make a big difference. most of the tips apply
to Unix with a strong emphasis on free utilities and the GNU tools. in fact that
is my first tip. never underestimate free software. if you find something is
more difficult than you know it should be then chances are someone else did too,
solved the problem and gave away the solution. (after all, wouldn't you?)
your shell is what
you interact with whenever you want to get something done, knowing your
shell can save you alot of time and heartache. backquotes.
a backquoted expession will be run and the output will be palced on the
command line
like so
ls -al `which sh` would
be the same as ls -al /bin/sh
aliases: the syntax may vary for different
shells but aliases may be used to make one thing expand into something
else. some useful aliases are:
- alias ll="ls -al" pretty standard for long listing
- alias new="ll -rt" show most recently changed
files at the bottom
- alias nemesis="lpr -Pnemesis" for quicker printing
(i.e. cat file.txt | nemesis for a printer named nemesis.)
- alias more=less in case you forget.
- alias sc="ls *.[ch] | xargs egrep"
search all .c and .h files in current dir for a given expression.
The shell I normally
use is zsh and i HIGHLY recommend it, it is free and very powerful.. these
next few things only work in zsh. there are a whole slew of options in
zsh perhaps the most useful one I find is AUTO_CD you turn it on with
setopt autocd (this can be placed in your .zshrc)
with that turned on you can switch directories
just by typing the dir name as if it were a program. ie you can type ..
or /home and go there instantly.
I know it only saves 3 keystrokes but they add up.. see the zsh man
pages for more autocommands. Another zshism dealing with directories
is
cd -
which will switch to the directory
you were just in, this is just one of the most useful features. unlike
pushd/popd it is always on. useful whenever you need to switch to another
dir for just a sec to make a change.
=executable (ie. =ls, =perl or =texi2html)
expands to `which executable`
(those are backquotes) this is perhaps the most common use of backquotes
and a great shortcut for it. useful for
ls -al =perl (see
the permissions on perl without checking if it is /usr/bin or /bin or wherever
first) or something like
less =texi2html to view the texi2html script
The last useful zshism i will mention
is the **/* notation which
expands recursivly to all files and directorys that can be reached under
the current dir. as in ls **/*.c will
find every c file in the current dir and all its subdirectories and all
the subdirectories and so forth. grep whereami **/*
will search for whereami in all files from the current dir onward.
I like color. especially
when it conveys useful information or serves some purpose.
GNU ls can colorize your directory listings
depending on what type of file is being displayed, its permissons or various
other criteria. to enable this feature
use the --color=tty
option to ls. if you wish to always have it enabled, add this to your shells
startup script
alias ls="ls --color=tty" or
alias ls="ls -F --color=tty"
if you want a special character appended to the file to also let you know what
type of file it is.
another place that color can be used effectivly
is in your email. Are you using pine or elm or mh? i strongly suggest trying
out mutt. mutt can do most anything and will colorize your mail deal with
MIME properly and thread your mailbox which means it will groug messages
and their replys together. see the
mutt homepage for more.
many text editors will also be able to
color code what you are editing. vim the editor i use (see my
editor section) can color syntax hightlight just
about anything you could concievably want to hightlight.
just add :syntax on to
your .vimrc (you need at least vim 5.0 for this)
an editor is a very personal
choice. the editor i choose to use is vim. although the learning curve
is a bit steep for vi-ish editors i strongly recommend you try out vim
and take the time to learn it. it WILL pay off. some quickies.
-
.(period) repeats your last change ie, use cw to change a word
to something else, . will repeat whereever you are
-
<C-a> control-A will add 1 to the nearest number.
it even understands hex. very useful in coding
-
:%s/foo/bar/g replace all foo's with bar's.
-
:syntax on turn on syntax highlighting in vim >= 5.0
-
shift-v and control-v visual mode a vimism
that lets you grab big chunks of text at once. use standard commands on
the blck like y to yank c to chang etc. control-v will do an actual rectangular
block useful at times
-
=% = will auto indent your code % will match {([ with their mates..
so to autoindent main place the cursor on { and press =%.
there are many neat things about vim.. I will
definatly update this section when i have time.
The undisputed king of
practical unix knowledge in books is by far
O'Reilly and Assosiates. basically, if
you need a book on something and
they have one on what you want you cannot go wrong. their books typically
have an animal on the cover but recently they have been straying from the
formula.
For hard therory Springer-Verlag
is always a good bet. they also produce the "Yellow books" of mathematical
fame, their CS books will often be grey but sometimes not if they are very
theoretical and classifed more in the math section.
some other Excelent books i have and would
very highly recommend if you are at all interested in the field are:
-
Unix Network Programming Volume 1 Second
edition: networking APIs, Stevens
this is the most excelent book on network programming and sockets. be sure
to get the second edition though as the first is quite dated. Stevens pretty
much rocks at any book he writes.
-
Advaced Programming in the UNIX envirornment,
Stevens also by stevens and excellent,
full of how to program everything UNIX/Posix.
-
The Design and Implementation of the
4.4BSD Operating System, McKuSick Bostic Karels and Quarterman
red with a devil on it. much better than the previous edition, really a
great book an a specific case of OS design.
-
Distributed Operating Systems, Tanunbaum
Tanunbaum is classic the author of Minix with his new distributed OS. top
notch.
-
What Computing is all about, van de
Snepscheut more theoretical but all
sorts of very cool stuff describes reversible computing and a theoretiacl
maching composed of billiard balls, also the author (Jan van de Snepscheut)
taught here at Caltech until he went insane and attemted to kill his family
with an Axe and then burnt down his house with him inside. thats gotta
say something for the book.
-
UNIX Internals: the new frontiers, Vahalia
this book is the bomb. it has all sorts
of cutting edge awesome technologies such as logging filesystems, microkernel
based systems and a good comparasin of how UNIXs are different on a fundamental
level, a must if your interested in whats inside a modern UNIX
The tao of programing has all the guideance
one could ask for.
back to my homepage.
back to my computer page.
email me: john@foo.net