More handy hacks (not ready for prime time)
More handy hacks (not ready for prime time)
These are some hacks which are not ready to be distributed via
handy-hacks.html
yet for one reason or another.
If something looks interesting, let me know and I'll try to clean it
up enough for general use.
cache-clean
Finds
netscape
cache files on structure specified, sorts them by date, then starts
removing them (oldest first) until disk space is up to specified
level.
check-aliases-vs-users
Compares the list of aliases to the list of valid users and prints out
a warning for aliases which are also valid users.
An exception mechanism exists for users which *should* have aliases in
/etc/aliases.
(Sometimes some of my users come back after I set up mail bouncing...)
check-tape-usage
Scans RUBS backup log files to give total tape usage from each log
file.
When
"-v"
is specified, lists individual partitions and their estimated tape
usage.
check-exports
Ensures that all hosts to which local filesystems are exported exist
and that the local host is not included.
(It's a security risk to export a filesystem to yourself.)
check-ftp
Ensure that all publicly writable files/directories under ~ftp are
properly hidden.
(You're opening yourself up to abuse by software pirates if they're
not.
See my
anonymous ftp
page.)
clear-mounts-from-host
Attempts to clear bogus rmtab entries on remote hosts by mounting and
unmounting the partition that host thinks this host is mounting.
(Useful when receiving unneeded shutdown warnings.)
cshbigfiles
A simple csh template shell script showing how to process a file
having so many lines that a simple
foreach FILE ( `cat filename` )
produces an error like "Arguments too long" or "Too many words from".
dig-for-host
Uses
dig
command to begin at the root of the DNS and follow downward to
determine who answers authoritatively for a hostname or IP address and
what the results are.
easter
Determines the date of Easter for year supplied (or the current year).
find-gateways-on
Finds gateways (hostnames of the form *-gw) on one (or a
common gateway on two) subnet.
find-processes-holding-open-nonexistent-files-on
Uses
lsof,
find,
and
ps
to determine what process(es) are holding open files on ( and possibly
filling) a specified partition.
h2h
Executes
host
command to translate hostname to IP address, then to
result to convert back to hostname again (or vice versa).
hps
Reorganizes output of
ps
so child PIDs appear indented under parents.
install-patches
Installs (or backs out of) a given list of Solaris patches.
Takes care of uncompressing and untaring patch files.
Can do a crude job of backing out of previously installed versions of
patches if you're tight on space.
kill-processes-of-user
Fast way to kill off all processes owned by a user on the machine.
Can take an optional process name to kill off only processes
containing that word by that user.
reserve-machine
Waits until specified user is on machine, then sets
nologin
until user logs off or optionally specified time has expired.
sd-decode
Translates the old 4.1.x "sd" notation to the Solaris "cwtxdy" notation.
(There's some confusion with iostat whether sd0 and sd3 are switched
or not.)
For Solaris 2.6 or later, use
"iostat -xn".
share-cd-with
automates starting nfsd, mountd, sharing and unsharing of a CD when
using a remote CD drive on a machine which normally does not export
filesytems.
share-directory-with-group
makes it easier to correct protections on a directory which is
supposed to be shared with a group by changing the group and adding
read or read/write access for all files/directories owned by user
within specified directory.
watch-net
For a (currently hardcoded) list of hosts, this script resolves the IP
address,
pings
the host, and optionally saves the output of a
traceroute
(so you can tell recent successful routes as well as where the route
is currently breaking down) and checks packet lossage.
watch-structure
Does a repeating
df
of the filesytem(s) specified.
Alternate sleep time can be specified.
Also, in "delta" mode, prints the amount and percentage of
increase/decrease of usage of the structure.
whatson
Lists all hosts on a particular subnet.
(Currently assumes netmask 255.255.255.0.)
whois
Simple script to recurse on
whois
requests when referred to another server.
This page last updated March 14, 2004.