How to tell the number of seconds since EPOCH ?

    % perl -le 'print time'
    
    If you have gnu 'date' installed, you can do
    
    % date +%s
    
    % date +%s; perl -le 'print time'
    1098825471
    1098825471
    

How to get past cygwin automake errors ?

    rm configure.in
    rm -r autom4te.cache/
    ./configure
    

How to get cygwin sshd to write to sshd.log ?

Install as follows:

cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd -a '-D -e'
    

How to run debug version of sshd ?

    <p>Run another instance of sshd on a different port, with full debugging
    enabled to standard error:
    
    $ sshd -Dddde -p 22222
    
    You may well have to fiddle with permissions of the host keys and config
    files to get this running.
    
    Now, try a pubkey login to this alternate sshd. Somewhere in the
    (copious) debug output, there is usually a clue to why the
    authentication is failing.
    
    NB: In debug mode, sshd will terminate after 1 connection attempt. You
    will have to restart the alternate sshd each time you want to run
    another test.
    

How to save SSH client data specific to your PC

For any machine that is being re-imaged, could we add the following step for any valid user of the machine, assuming it's not a disk failure and that the machine can be accessed :

    Winzip c:\documents and settings\validuser\Application data\SSH
    

This directory contains the profile settings and ssh user keys for this specific user from this specific PC. That's why it cannot be on the network. The problem is that if the user has created a public/private key pair and uploaded the public part to one or more unix hosts, the unix host will no longer recognise the user if they have to regenerate a new public/private key pair after re-imaging, because the keys will be different.

If the user does not use the SSH client, or if there is no data in the UserKeys subfolder of the directory above, then this is not a required step i.e.

    for each user
       if (dir c:\docs&settings\user\AppData\SSH\Userkeys\*.pub != "") then
             winzip the ssh folder and save to a network location
       end
    next user
    

What are the three types of quotes and what is the difference between them ?

Thanks to Byron on the networker group for the simple explanation.

    mminfo -s server -a -r "volume,%used,pool,location" -q '!full'
    
  • Double quotes: the shell evaluates the text within the quotes, performs things like variable expansion and history expansion (the ! in your example) and passes the result into the program as a single item.
  • Single quotes: the shell does not interpret the text within the quotes and passes it verbatim into the program as a single item.
  • Back quotes: the shell interprets the text within the back quotes as a command, runs the command, and returns the result to the command line and continues processing.

How to build mutt (using slang) on solaris ?

There are 2 parts - building slang, then building mutt.

  • Get the latest version of slang.
  • gunzip, tar xvf etc.
  • ./configure --prefix=/u/kscully
  • make
  • make install
  • Get the latest version of mutt. Go to the devel folder and get the version that has the "i" suffix (e.g. mutt-1.5.6i.tar.gz)
  • gunzip, tar xvf etc.
  • ./configure --enable-compressed --with-slang=/u/kscully --with-docdir=/u/kscully/public_html/mutt --prefix=/u/kscully --with-included-gettext
  • applied this patch to enable compressed folders.
  • applied this patch to menu.c because it failed at link time.
               if (*s < M_TREE_MAX)
    	   {
           #ifndef USE_SLANG_CURSES
                 if (do_color)
                 {
                 pair_content(PAIR_NUMBER(ColorDefs[MT_COLOR_TREE]), &f1, &b1);
                 pair_content(PAIR_NUMBER(attr), &f2, &b2);
                 if (b1 == b2)
                    SETCOLOR (MT_COLOR_TREE);
                 }
           #endif
               while (*s && *s < M_TREE_MAX)
           
  • make; make install

How to build apache on solaris ?

probably not what the official apache maintainer would do, but ...

    ./configure --enable-layout=Apache --enable-info --enable-cgi
    --enable-ssl --with-ssl=/software/openssl --enable-modules=all
    make clean
    make
    

How to use the ldapsearch command

Some useful ldapsearch commands

http://support.microsoft.com/default.aspx?scid=kb;en-us;321051
https://www.cs.uwaterloo.ca/twiki/view/CF/ADLdapS
certutil -store my
mmc, add snap in for certificate
ldapsearch -L -Hldaps://syslab25.adst.uwaterloo.ca/ -x -W \
-D "cn=Kevin Scully (kscully),OU=Users,OU=Info Systems & Technology,OU=Academic \ 
   Support,dc=adst,dc=uwaterloo,dc=ca" \
-b "dc=syslab25,dc=adst,dc=uwaterloo,dc=ca" "cn=Kevin*" cn

ldapsearch -L -Hldaps://syslab25.adst.uwaterloo.ca/ -x -W -D "cn=Kevin Scully \
(kscully),OU=Users,OU=Info Systems & Technology,OU=Academic Support,dc=adst, \
dc=uwaterloo,dc=ca" -b "dc=adst,dc=uwaterloo,dc=ca" "cn=Reginald*" cn

[kscully@dominic ~]$ cat .ldaprc
BASE dc=adst,dc=uwaterloo,dc=ca
BINDDN cn=Kevin Scully (kscully),OU=Users,OU=Info Systems & Technology,
   OU=Academic Support,dc=adst,dc=uwaterloo,dc=caURI 
   ldap://syslab25.adst.uwaterloo.ca
HOST syslab25.adst.uwaterloo.ca
TLS_CACERT /home/kscully/certs/cacert.pem

ldapsearch -L -x -W  "cn=Reginald*" cn
    

How to open a link in a new window with a specific size

In the < head> section of the page with the href link, add this javascript function

    < script>
    function wopen(url, name, w, h)
    {
    // Fudge factors for window decoration space.
    // In my tests these work well on all platforms & browsers.
      w += 32;
      h += 96;
      var win = window.open(url,
                name,
	        'width=' + w + ', height=' + h + ', ' +
	        'location=no, menubar=no, ' +
	        'status=no, toolbar=no, scrollbars=no, resizable=no');
      win.resizeTo(w, h);
      win.focus();
    }
   </script>
   

Then, in the calling page, the href tag calls the wopen function like this: Click here to open example.html in a 640x480 window.

How to backup all mysql databases on a server

    mysqldump -uroot -pYOURPASSWORD --all-databases > filename
    

How to debug a cygwin program ?

    To debug cygwin:

    1) Put the latest version of the dll which works for you
       in a directory "foo" along with a copy of gdb.exe.
   
    2) Set the environment variable CYGWIN_TESTING=1 at the windows
       prompt.
      
    3) Debug a cygwin application by typing:
      
       c:\foo\gdb /bin/pwd
	 
       (do not cd to the foo directory here)
	    
    4) Type "run".
	    
    5) If you get a SEGV, it is possible that it is just a natural occurrence
       of calling BadWritePtr.  Type 'continue' a few times to make sure that
       the SEGV address does not change.
   
    6) Type "backtrace" and report the results here.
   
       cgf
    

How to create a qtree on the netapp filer.

Steps to do on the filer (e.g. to create a qtree named mergetest)

  1. telnet admfile
  2. qtree create /vol/vol0/mergetest
  3. qtree security /vol/vol0/mergetest ntfs ( ntfs / mixed / unix)

From the admin host (hoover) as user root

  1. /sbin/mount admfile:/etc /mnt
  2. cd /mnt and update quotas and exports using RCS

In the NT domain from an NT server

  1. sign on as ntmaint
  2. Run srvmgr \\admfile (might need 129.97.128.36)
  3. Choose Computer, Shared directories from the menu
  4. Click 'New Share'
  5. At "Share Name" enter the Windows folder name
  6. At "Path" enter the pathe to the share e.g. c:\vol\vol0\mergetest
  7. At "Comment" enter something useful...
  8. Update permissions as required.

In a Windows 2000 domain from an W2k server

  1. sign on as a domain administrator
  2. Right click "My computer" and choose manage.
  3. Choose Action, Connect to another computer from the menu
  4. From the browse list, choose uwfile
  5. At "Path" enter the pathe to the share e.g. c:\vol\vol0\mergetest
  6. At "Comment" enter something useful...
  7. Update permissions as required.

How to rename a qtree on the netapp filer

  1. Rename the qtree, as if it were a directory, by using the UNIX "mv" command, the DOS "ren" or "rename" commands, Windows Explorer, etc.
  2. Update the qtree name in the filer's /etc/quotas file using rcs.
  3. Turn quotas off by
    1. typing "quota off" at the filer console.
    2. typing "rsh filername quota off" as root from the admin host hoover.
  4. Turn quotas on again by
    1. typing "quota on" at the filer console.
    2. typing "rsh filername quota on" as root from the admin host hoover.

How to update share permissions on the netapp filer

Windows NT server instructions

  1. Connect to a server in the ADMIN domain.
  2. Run Server Manager on the filer e.g. Start -> run -> srvmgr \\admfile
  3. Choose Computer -> Shared directories.
  4. Select the share name you want to update.
  5. Choose "Properties".
  6. Choose "Permissions".
  7. If adding a new group, select "Add" and select the group. If necessary, use the drop down list to find the group in another domain.
  8. If updating a group's permissions, select the group and modify the share permissions as necessary
  9. Click "OK" twice and "Close" to exit

Windows 2000 instructions

  1. As a "domain administrator", right click 'My computer', select 'Manage'
  2. Select 'Action' -> 'Connect to another computer' and in the dialogue box, type the name of the filer you want to manage.
  3. Expand 'Shared Folders'. Click on 'Shares'.
  4. Right click the share that needs to be updated and modify as necessary.
  5. Select 'File' -> 'Exit' when finsihed.

How to convert a directory to a qtree.

  1. Write down the existing share permissions.
  2. Rename the directory
    • From Windows: map the root volume of the file, usethe DOS "ren" or "rename" commands, Windows Explorer, etc.
    • From unix: mount the root volume of the filer in write mode, and use the mv oldqtreename newatreename command to rename the qtree.
  3. Update the qtree name in the filer's /etc/quotas file using rcs.
  4. Turn quotas off by
    1. typing "quota off" at the filer console.
    2. typing "rsh filername quota off" as root from the admin host hoover.
  5. Turn quotas on again by
    1. typing "quota on" at the filer console.
    2. typing "rsh filername quota on" as root from the admin host hoover.
  6. If shares have to be recreated to point to the new qtree, use the permissions noted in the first step.

How to join a filer to a domain

  1. If the filer is already in the domain, use Active Directory - Users and Computers to delete the account.
  2. From hoover (the filer administration host), telnet to uwfile and issue the 2 commands shown in the dialogue below. The default answers for the cifs setup command are shown in []. The important step is to answer "yes" to delete the existing filer account information.
  3. An administrative account in the domain to be joined is required. I left the default cn=computers as the OU for the filer at this point and then moved it to ads/Academic Support/Servers later using the AD users and computers tool.
       
    uwfile> cifs terminate
    uwfile> cifs setup
    Enable CIFS access to the filer by a Windows(tm) PC
         Your filer is visible to all systems using WINS.
         The WINS name servers currently configured are:
         129.97.108.193
    Do you want to modify this list? [no]:
         This filer is currently configured as a Multiprotocol filer.
    Do you want to configure this filer as a NTFS-only filer? [no]:
         This filer is currently a member of the domain 'ADS'
         If you want to change the name of the filer, or change
         the filer's domain membership, you must delete its
         existing account information.
    Do you want to delete the existing filer account information? [no]: yes
         The default name of this filer will be 'UWFILE'.
    Do you want to modify this name? [no]:
         CIFS supports three types of user authentication:
         1. Windows Domain authentication.
         2. Windows Workgroup authentication using the filer's user accounts.
         3. /etc/passwd and/or NIS based authentication.
    What type of authentication will this filer use? [1]:
         The filer will use Windows Domain authentication.
    Enter the Windows Domain for the filer []:ads.uwaterloo.ca
         ADS is a Windows 2000(tm) domain.
         In order to create this filer's domain account, you must supply the
         name and password of an administrator account with sufficient privilege
         to add the filer to the ADS domain.
         Please enter the Windows 2000 user [ADS\Administrator]:ads\!!kscully
    Password for ADS\!!kscully:
    CIFS - Logged in as ADS\!!kscully.
         By default, setup creates the filer account in the Active
         Directory container named 'Computers'. Alternatively, you can
         install the filer in an organizational unit (OU) by specifying
         the domain relative distinguished name of the OU, as in
         'ou=innerOU,ou=outerOU'.
    Active Directory container for filer account? [cn=computers]:
    CIFS - Connecting to domain controller.
    Welcome to the ADS Windows 2000(tm) domain.
    

How to upload a core file to netapp

If a filer crashes, there will be a core file created in the /etc/crash directory off the root of the filer. The name of the file will be something like core.1.nz. To upload this file to netapp, follow these steps:

  1. Open a case with Netapp. You'll need the case number to upload the file
  2. On the admin host (hoover), cd /nfs/filername/etc/crash, where filername is the name of the filer that crashed.
  3. Locate the latest core file ls -lt. Remember this number (say it's X)
  4. Connect to the NOW ftp site ftp ftp.netapp.com. Use anonymous as the userid, and your email address as the password.
  5. Switch to the upload directory cd to-ntap
  6. Switch to binary mode for the transfer bin
  7. Upload the core file and rename it with the case number put core.X.nz case_number.core.X.nz, where case_number is the case number you got from Netapp in the first step, and X is the number of the core file from step 3.

Dialogue should look something like this:

suw-2.03# cd /mnt/etc/crash
suw-2.03# ftp ftp.netapp.com                                                  
Connected to ftp-lbs.netapp.com.
220 ftp.netapp.com NcFTPd Server (licensed copy) ready.
Name (ftp.netapp.com:kscully): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password:
230-You are user #1 of 100 simultaneous users allowed.
230-
230-
230-    Welcome to Network Appliance Corporation's FTP server.  This
230-server is for the use of Network Appliance customers and employees only.
230-                   All other use is prohibited.
230-
230-
230-To upload ONTAP core files, change directories to to-ntap.
230-To upload Netcache core files, change directories to incoming/cs/netcache.
230-Please use Binary mode to upload files. 
230- 
230-
230-NOTE: You must open a Customer case/call record
230-       before transferring the core file. 
230-
230-To upload ONTAP core files
230-
230-   ftp> cd to-ntap
230-   ftp> bin
230-   ftp> put core..nz
.core..nz
230-
230-To upload NetCache core files
230-
230-   ftp> cd incoming/cs/netcache
230-   ftp> bin
230-   ftp> put core..nz
.core..nz
230- 
230- 
230-   Example:
230-   ftp> put core.3.nz  82329.core.3.nz
230-
230-HTTP/HTTPS are also available for core/trace/stat/log files uploads.
230-See http://upload.netapp.com for details.
230-
230 Logged in anonymously.
ftp> cd to-ntap
250 "/incoming/cs/ontap" is new cwd.
ftp> bin
200 Type okay.
ftp> put core.2.nz 463838.core.2.nz
200 PORT command successful.
150 Opening BINARY mode data connection.
226 Transfer completed.
local: core.2.nz remote: 463838.core.2.nz
57298671 bytes sent in 3.8e+02 seconds (145.44 Kbytes/s)
ftp> quit

Getting the latest release from the NOW site

  • Setup the directory structure on hoover (example below for 6.1.2).
           /software/netapp-6.1.2/data/2_8_a2        (firmware files)
           /software/netapp-6.1.2/data/612
           /software/netapp-6.1.2/doc/
          

Howto upgrade the version of ONTAP for F720s

From the management server

  • mount uwfile:/ /mnt
  • cd /mnt
  • tar xvf /software/netapp-6.2/data/62r2/62R2_sysfiles_a.tar
  • ./install_netapp /mnt
  • cd /; umount /mnt

From the filer console:

  • download
  • disk_fw_update (will do nothing if all disk firmware is up to date)
  • reboot
  • filer should reboot in less than a minute. Check /nfs/filername/etc/messages.

How to use rsync to copy data from one filer to another

Here is the process as described by Terry Stewart. Both filers are mounted from one unix host (in the example below ahsnap is the target and ahsfile is the source)

   cd /ahsnap
   rsync -axv --delete --exclude-from /u/stewart/exclude.me /home/ .
   (don't miss the dot on the end of line above)
   /ahsnap is the new filer mount point
   /home   is the old filer mount point
   The file exclude.me looks like:
       .snapshot/
 You can add other directories (eg, Windows2000/) on separate lines
 in the exclude file.
      

How to disable/enable rsh access to a filer.

to disable

      rsh.enable off
      rsh.access "none"
      

to enable rsh

      rsh.enable on
      rsh.access host=server1.uwaterloo.ca,server2.uwaterloo.ca
      

Help on troubleshooting IIS 6.0 problems

On your IIS 6.0 server, start a browser and past this string into the URL (assuming C:\WINDOWS is the windows directory)

      mk:@MSITStore:C:\WINDOWS\help\iismmc.chm::/HTM/aaconaspnetiisregistrationtoolaspnet_regiisexe.htm
      
    
C:\WINDOWS\system32>cscript iisext.vbs /ListFile
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Connecting to server ...Done.

Status / Extension Path
------------------------
1  C:\php\sapi\php4isapi.dll
0  C:\WINDOWS\system32\inetsrv\httpodbc.dll
0  C:\WINDOWS\system32\inetsrv\ssinc.dll
1  C:\WINDOWS\system32\inetsrv\asp.dll
1  C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll
0  *.exe
0  C:\WINDOWS\system32\inetsrv\httpext.dll
0  *.dll

C:\WINDOWS\system32>cscript iisext.vbs /EnFile *.dll
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Connecting to server ...Done.
Enabling extension file complete.

C:\WINDOWS\system32>cscript iisext.vbs /ListFile
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Connecting to server ...Done.

Status / Extension Path
------------------------
1  C:\php\sapi\php4isapi.dll
0  C:\WINDOWS\system32\inetsrv\httpodbc.dll
0  C:\WINDOWS\system32\inetsrv\ssinc.dll
1  C:\WINDOWS\system32\inetsrv\asp.dll
1  C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll
0  *.exe
0  C:\WINDOWS\system32\inetsrv\httpext.dll
1  *.dll

C:\WINDOWS\system32>

How to configure Thunderbird to do ldap lookups

Open the address book, choose File, New, LDAP directory.

  • for name use uwdir
  • for hostname, use uwldap.uwaterloo.ca
  • for base dn, use dc=uwaterloo,dc=ca
  • for port number, use 389
  • no need for a bind dn, and no changes needed on offline or advanced.

How to tunnel ftp traffic through using the ssh client.

The SSH administrator's guide has a good discussion about setting up ftp tunneling with the ssh client.

How to generate a reort of directory usage

Open a command window and type diruse /?

      C:\>diruse /m /* c:
      
          Size (mb)  Files  Directory
         129.63    798  SUB-TOTAL: C:Documents and Settings
           0.09      4  SUB-TOTAL: C:Inetpub
           0.00      0  SUB-TOTAL: C:Old_Event_Logs
        1602.17   5023  SUB-TOTAL: C:Program Files
           0.02      2  SUB-TOTAL: C:System Volume Information
           7.99     40  SUB-TOTAL: C:Utility
        2802.49  18191  SUB-TOTAL: C:WINDOWS
           0.00      0  SUB-TOTAL: C:wmpub
        4542.41  24058  TOTAL
      

How to use smbclient to evaluate and update windows shares

Example 1. List the shares on a file server. Authentication required.

             smbclient -L \\\\jam -W ADS -U kscully
      

Example 2. List the contents of a specific file share.

          smbclient \\\\jam\\istus$ -W ADS -U kscully
          Password:
          Domain=[ADS] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
          smb: \> ls
          ~snapshot                     DH        0  Mon Jun 26 00:00:48 2006
	  crutter                      DAR        0  Fri Jun 23 14:29:10 2006
	  srrestal                      DA        0  Fri Jun 16 16:58:43 2006
	  bkhrms                        DA        0  Wed Nov 16 15:38:03 2005
	  beu                          DAR        0  Thu Jun  1 17:38:59 2006
	  istchip                       DA        0  Wed Nov 20 10:50:23 2002
      

Example 3. Transfer a file to a windows share. From a unix prompt, place a file on a windows share, using -W to name the domain for authorization, -U for the userid, -D for the directory to move to for processing, and -c for the command to execute.

            smbclient \\\\jam\\hrrd$ -W ADS -U kscully -D hrweb=20
            -c "put smbclient.txt jobdescriptions\smbclient.txt"
      

How to use the IIS migration tool ?

I needed to move an IIS web site from one server running Windows 2000 Server SP 4 and IIS 6.0 to a Windows 2003 SP 1 server also running IIS 6.0. This is the command I ran :

C:\Program Files\IIS Resources\IIS 6.0 Migration Tool>iismt sycamore "Prospects
Visit Us" /path "e:\www sites\Prospects" /verbose

and this is the output :

Internet Information Services 6.0 Migration Tool version 1.0
Copyright (C) 2002 Microsoft Corporation. All rights reserved.


Connecting to the local IIS Server...
Connecting to server SYCAMORE...
Resolving the site by name 'Prospects Visit Us'...
Backing up the current IIS configuration...
Replicating the metabase properties...
Migrating the metabase key "" which contains 450 bytes of data...
Migrating the metabase key "/Root" which contains 448 bytes of data...
Migrating the metabase key "/Root/_vti_pvt" which contains 96 bytes of data...
Migrating the metabase key "/Root/_vti_log" which contains 96 bytes of data...
Migrating the metabase key "/Root/_private" which contains 96 bytes of data...
Migrating the metabase key "/Root/_vti_txt" which contains 96 bytes of data...
Migrating the metabase key "/Root/_vti_script" which contains 96 bytes of data..
.
Migrating the metabase key "/Root/_vti_cnf" which contains 96 bytes of data...
Migrating the metabase key "/Root/aspnet_client" which contains 64 bytes of data
...
Migrating the site content...
Migrating the content for metabase key /Root from \\SYCAMORE\E$\WWW Sites\pvu...

Creating directory e:\www sites\Prospects\ambassador...
Creating directory e:\www sites\Prospects\archived...
Creating directory e:\www sites\Prospects\aspnet_client...
Creating directory e:\www sites\Prospects\cgi-bin...
Creating directory e:\www sites\Prospects\Connections...
Creating directory e:\www sites\Prospects\css_files...
Creating directory e:\www sites\Prospects\Existing_files...
Creating directory e:\www sites\Prospects\fpdb...
Creating directory e:\www sites\Prospects\images...
........
Creating directory e:\www sites\Prospects\request\PicsSys\_mmDBScripts\_vti_cnf...
Creating directory e:\www sites\Prospects\request\PicsSys\_notes\_vti_cnf...
Creating directory e:\www sites\Prospects\request\PicsSys\images_menu\_notes\_vti_cnf...
The directory has been migrated with 112 subdirectorie(s) and 2173 file(s).
Migrating the application isolation settings...
				
The site has migrated successfully.

How to delete content from Sharepoint

I needed to remove content from a Sharepoint virtual server. Using command line tools from this article, I ran this command to update the site.

C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BIN>stsa
dm -o unextendvs -url http://css07/ -deletecontent

Operation completed successfully.

How to delete content from Sharepoint

I needed to convert a PAL DVD movie to NTSC format. I followed instructions from this article. It involved the installation of VideoLAN VLC media player.


Other FAQs