Tuesday, September 23, 2008

Mounting Shares with Spaces

In linux sometimes you want to mount a windows share that has spaces in the name. This is actualy quite easy, just use \040 in place of the space

//ip.of.server/Home\040Folders/ejh /home/ejh/Documents cifs username=ejh,password=*****,uid=500,gid=500 0 0

Monday, September 22, 2008

Removing SVN folders from a directory

If you need to removing a folder from subversion run the following command

rm -rf `find . -type d -name .svn`

Incorrect DNS Settings Reappearing

I recently moved a virtualized server to a new host machine. In the process its virtual hardware changed, and so its MAC address changed. It got a new address from DHCP correctly and reported it to DNS, but DNS would only hold that information for about 15 minutes before switching back and reporting the old DNS.

After many frustrating hours I decided to check DHCP, and sure enough, DHCP had the old and new leases both with the same host name and was reporting them both to Active Direcotry.

Solution: Simply remove the old lease from DHCP, I'm sure eventualy it would have expired and fixed itself as well.

Monday, March 3, 2008

Hiding SVN Directories using .htaccess

You can use the .htaccess file to hide specific directories pretty easily using a simple rewrite rule
RewriteEngine on
RewriteRule \.svn/ - [F]
This same format could be used to hide any directory on a web server.

Thursday, February 21, 2008

Finding Disk space Hogs

I occasionaly have a system go off the deep end eating up all of its space. This can be very difficult to track down. In order to find the offending files/directories goto the root and do
du -k -s * |sort -n
this will list the directories and files in the current directory in asc order so that the last one you see is the largest. Using this it is easy to move down the directory tree and quickly identify the offending files.

Using date in file name (and compressing files)

Yea this is stupid an easy, and also very annoying if you forget how!

    backup=`date +%Y%m%d`
tar czvf SQL-$backup.tar.gz *.sql
That backs up all the current .sql files in a directory into a file with todays date as the name

Deleting Files over Certain Age

The command to delete files over a certain age is deceptivly easy in linux.

   find * -mtime +5 -exec rm {} \;

That finds all files over 5 minutes old in the current directory. This is quite usefull in a backup script run from cron.

Tuesday, February 5, 2008

VMWare Server (Guests very slow)

If you are having trouble with guest machines being slow it could be because they don't have any shared memory setup. Make sure you have /dev/shm setup with tmpfs and at least half your physical memory mounted. Then add tmpDirectory="/dev/shm" to your /etc/vmware/config file and restart vmware. (Full directions at above link).

I've also found that staying close to the recommend memory settings in guests is better than adding more memory.

Friday, February 1, 2008

Enable or Disable the CTRL+ALT+DELETE Sequence

To Enable or Disable the CTRL+ALT+DELETE Sequence

1.Click Start, click Control Panel, and then click User Accounts.
2.Click the Advanced tab.
3.In the Secure logon section, select or clear the Require users to press Ctrl+Alt+Delete check box.

Thursday, January 31, 2008

Oracle MV Update

I love materialized views, but sometimes you need to be able to force their update. Just use the following Pl/SQL (I like using it from APEX where users need the ability to force the refresh

BEGIN
DBMS_MVIEW.REFRESH('NEWPORT.TRANSACTIONS_MV','C');
END;

Tuesday, January 29, 2008

Setting TimeZone in linux

If you look in the /usr/share/zoneinfo directory you'll see all the available time zone settings. To change it just create a symlink from /etc/localtime to the correct zone file. (Reference)

mv /etc/localtime ~/localtime.old
ln -s /usr/share/zoneinfo/America/Denver /etc/localtime
If you want to sync your hardware clock run the following.
/sbin/hwclock  --systohc

UnBlocking Attachments in Outlook

Outlook blocks a lot of usefull extensions by default, like mdb files.

You can unblock them though. (Full directions)

The meet of it comes down to:
  1. Run Regedit, and go to this key:

    HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security (change 10.0 to 9.0 for Outlook 2000 SP3 or to 11.0 for Outlook 2003)
  2. Under that key, add a new string value named Level1Remove.
  3. For the value for Level1Remove, enter a semicolon-delimited list of file extensions. For example, entering this:

    .mdb;.url

    would unblock Microsoft Access files and Internet shortcuts. Note that the use of a leading dot was not previously required, however, new security patches may require it. If you are using "mdb;url" format and extensions are blocked, add a dot to each extension. Note also that there is not a space between extensions.
After that, restart outlook and enjoy. Personaly i've only unblocked .mdb so far.

Monday, January 28, 2008

Embedded vi Syntax Highlighting


This is a vi syntax highlighting trick gmax
emailed to me. It changes the syntax highlighting for here documents and the
qq() and q() operators as long as braces {} are used to delimit them (that is the trick, you see). This example
'embeds' the MySQL highlighting scheme inside Perl code. Example.


Find the perl.vim file that is being used by your version of vi, usually somewhere
in /usr/share/vim/


Add this syntax to it:


syn include @Sql <sfile>:p:h/mysql.vim
syn region perlSQL start="qq{" end="}" contains=@Sql keepend
syn region perlSQL start="q{" end="}" contains=@Sql keepend
syn region perlSQL start="<<MYSQL" end="^MYSQL" contains=@Sql keepend

just before this line at the end of the file:
let b:current_syntax = "perl"

and save this file [mysql.vim] to the same directory
as the file you just edited (perl.vim).


Configure Apt-get to use Web

I was having trouble with apt-get wanting a CD-ROM. This was inside a Nagios VMware appliance so I didn't have the CD. apt-get appears to default to using the cd, all you need to do is edit /etc/apt/sources.list and comment out the first line. Then uncomment one of the web address lines, in my file they where nicely commented so my final file looked like:


#deb cdrom:[Debian GNU/Linux 3.1 r1 _Sarge_ - Official i386 Binary-1 (20051218)]/ unstable contrib main
deb file:/root debs/
#deb http://security.debian.org/ stable/updates main contrib
deb http://debian.oregonstate.edu/debian/ stable main
#deb http://debian.oregonstate.edu/debian/ unstable main

A quick 'apt-get update' and I was in business.

Setting up Remote SSH with shared keys

This little bit of code is quite nice. I put it in a file called setup_ssh in my ~/bin directory and life was much easier. Now when I want to setup shared key authentication i just type 'setup_ssh user@host' and put in my password. Thats it!

#!/bin/bash
cat ~/.ssh/id_rsa.pub | ssh $1 'mkdir -p .ssh; cat >> .ssh/authorized_keys'