2011-11-14

Solaris 11 default route

Q: How to add a default gateway on a Solaris 11 system?

A:
      route -p add default 192.168.1.1



Explanation: If you happened to be a Solaris administrator since version 2.3, like me, you were used to create a file
 
      /etc/defaultrouter 

But not any more! The "route -p" certainly is a good thing, I'll remember that.

2011-11-08

flatten a gnu tar archive

Problem:

I have a tar file with a deep directory hierarchy but only some files in it. I want to extract the files into my current directory and not care for subdirectories. Filenames do not conflict. The gnu tar option --remove-components does not handle this well.

Solution:

Fortunately, there is a very general gnu tar option --transform:
    tar --extract --transform='s/.*\///' --show-transformed-names --file=foo.tar
This deletes pathname up to the first slash character, resulting in the desired effect.

Example:

$ mkdir -p a/b/c/d/e/f/g/h/i
$ echo "hi there" >  a/b/c/d/e/f/g/h/i/foobar
$ tar cvf foo.tar a
a/
a/b/
a/b/c/
a/b/c/d/
a/b/c/d/e/
a/b/c/d/e/f/
a/b/c/d/e/f/g/
a/b/c/d/e/f/g/h/
a/b/c/d/e/f/g/h/i/
a/b/c/d/e/f/g/h/i/foobar
$ tar --extract --transform='s/.*\///' --show-transformed-names --verbose --file=foo.tar
a
b
c
d
e
f
g
h
i
foobar
$ cat foobar
hi there