LevSelector.com New York
home > Unix Hints and Hacks
Unix Hints & Hacks
On this page:
intro, manpages, tutorials
• 
home - top of the page -

- http://www.ugu.com - Unix Guru Universe
- http://www.MagniComp.com/sysinfo/ - SysInfo home page

Collecting system information:
Hostname:
      % hostname
Hostname aliases:
      % grep `hostname` /etc/hosts | awk '{ print $3 }'
Host network addresses:
      % grep `hostname` /etc/hosts | awk '{ print $1 }'
Host ID:
      % hostid
CPU type, application architecture, kernel architecture and version, operatin system name and version:
      % uname -a
Amount of main memory - can be found at boot time:
      % dmesg
Disk configuration (available space, etc.):
      % df
Other pieces:
  A copy of all NFS mounted filesystems
  NIS/YP configuration
  A listing of all OS packages installed
  A listing of all paches installed
  Complete disk drive settings and configuration
  All relevant software license keys and codes
  Any custom soft links that were created
  A copy of the setting and configuration for all defined printers

Backup some important files:
Kernel:
  /kernel  or  /unix  or  /vmunix
Passwd File:
  /etc/passwd
Group file:
  /etc/group
Host Table:
  /etc/hosts
Filesystem Table:
  /etc/fstab  or etc/vfstab
Sendmail Config Files:
  /usr/lib/sendmail.cf, /usr/lib/sendmail.fc,  /usr/lib/sendmail.mc
Inetd Configs:
  /etc/inetd.conf
TTY settings:
  /etc/ttys
Start Up Scripts:
  files residing in /etc/init.d  or /etc/rc#.d directories

Executing script on the last day of the month (backups, filtering of log files, system utilization, etc.):
#!/bin/sh
FILE = `runme`
if test `TZ=EST -24 date +%d` = 1; then
  $FILE
fi

 
#!/usr/bin/perl
use POSIX;
@mydate = localtime(time);
++$mydate[3];  # add one day to the date
$new_day_of _the_month = (localtime (POSIX::mktime (@mydate)))[3];
if ($new_day_of _the_month == 1) { 
  do_end_fo_the _month_stuff(); 
}

Using named pipes:
You can create named pipes using mknod or mkfifo commands, for example:

#!/bin/sh
mkfifo /tmp/testpipe
echo "This is a test" > /tmp/testpipe &
cat /tmp/testpipe
rm /tmp/testpipe

Here is a more elaborate example using 2 pipes to dump information
from Oracle into a series of 10MB compressed files.

$ mknod pipe1 p
$ mknod pipe2 p
$ nohup sqlplus user passwd @some_script_writing_into_pipe1 &
$ nohup compress < pipe1 > pipe2 &
$ nohup split -b 10245k < pipe2 &