Solaris Tips and Tricks

PS Long Listing

You want to see the whole command, but - how annoying - ps truncates to 80 characters.

/usr/ucb/ps augxww
gives full command listings.

If you're only interested in one process, an excellent alternative is pargs which lists the command line arguments for a given command.

For example:
pargs 12345
Will give all the command line arguments for process ID 12345

Compressing a Tar file upon creation

The standard Solaris version of tar misses the compression options found on fruitier versions of *nix. Never mind - we can use pipes to compress and uncompress archives.

Creating and compressing a tar file:
tar cvf - /home/doug/stuff_to_backup | gzip > my_tar_file.tar.gz

Uncompressing and extracting a tar file:
gunzip -c tar_file_to_uncompress.tar.gz | tar xvf -

Netstat counts

A quick view of the state of your TCP connections can be very useful - here'’s a quick and dirty (nice and simple) way of getting that information.
bash-3.00$ echo "Total: " `netstat | wc -l`

Total:  1756
bash-3.00$ netstat | perl -pe 'split;$_="$_[6]\n"' | sort | uniq -c | sort -n -k 1,1

   1 -----------
   1 Remote
   1 Rwind
   7
  20 LAST_ACK
  26 FIN_WAIT_2
 130 ESTABLISHED
 642 CLOSE_WAIT
 946 TIME_WAIT