January 21, 2009
I have missed the second birthday of this blog; starting with Hello World on 17th January 2007, this blog has seen a small growth, but the comments posted show that people have found it to be useful, which is good.
I hope that you continue to find it useful; I really will try to post a bit more often in 2009!
December 24, 2008
echo unccl puevfgznf | tr A-Za-z N-ZA-Mn-za-m
This is a very simplistic thing called “rot13”, whereby “a” becomes “n”, “b” becomes “o”, “c” becomes “p”, and so on. The
tr utility is ideal for simple string manipulation like this.
Happy Christmas to all!
December 10, 2008
You can forward ports with ssh like this:
$ ssh -L 8080:localhost:80 user@remotehost
This will log you in to
user, and port
8080 on your local machine will be tunnelled to port
remotehost. If remotehost can see a machine that you can’t (for example, if it’s on an internal network), you can even do this:
$ ssh -L 8080:internalhost:80 user@borderhost
This will log you in to
localhost:8080 will be directed to
internalhost:80, even though you may not be able to see
internalhost directly yourself.
What I didn’t know until I read Nico Golde’s blog today, is that you can do this interactively, with an existing session. Tilde (~) is the default escape character, and ~C (note that’s an uppercase C) gets you a shell session within ssh itself:
$ ssh user@remotehost
ssh> -L 8080:localhost:80
November 8, 2008
Mike Hommey has a nice article on clearing down deleted (but still-open) files:
http://glandium.org/blog/?p=211. He explains the problem clearly, and goes on to provide the solution, too. Well worth bookmarking, for that 2am emergency!
someone had to free some space on a 1GB filesystem, and thought a good idea would be to delete that 860MB log file that nobody cares about. Except that it didn’t really remove it, but he didn’t really check.
Later, the “filesystem full” problem came back at someone else, who came to ask me what files from a small list he could remove. But the files were pretty small, and that wouldn’t have freed enough space. That gave me the feeling that we probably were in this typical case I introduced this post with, which du -sk confirmed: 970MB used on the filesystem according to df, but only 110MB worth of data…
Mike has solutions to this for Solaris and Linux;
lsof is also useful for this kind of thing, on systems which have it.
October 17, 2008
When using the
more tool (this works with
less, also, and
less is generally more useful; you can scroll backwards and forwards with
less), you can press “
v” to start editing the file, in
vi, at the line you are currently viewing.
This works on Linux and Solaris; please confirm on other OSes as appropriate, though I would assume that what works on
more on Solaris, will work on
less on just about any OS.
This makes using
less far more powerful than before, and a new way into
September 9, 2008
Ben Hutchings has noted a quirk in the chmod syntax: If you use the “
chmod o-x” syntax, but omit the “
o” (Others) (or the “
u” (User) or “
g” (Group)), it will default to “
chmod -x foo” becomes “
chmod a-x foo“; similarly, “
chmod +x foo” becomes “
chmod a+x foo“
September 1, 2008
Interesting list of 15 examples of bash history syntax.
Most people probably know #5:
ps aux | grep yp
I didn’t know #13, that looks really useful for arcane purposes:
# cp ~/longname.txt /really/a/very/long/path/long-filename.txt
# ls -l !cp:2
ls -l /really/a/very/long/path/long-filename.txt