//ip.of.server/Home\040Folders/ejh /home/ejh/Documents cifs username=ejh,password=*****,uid=500,gid=500 0 0
Programing, Shell scripting, Windows, Linux. I'm using this as a repository for all those niggling little tasks that get done just often enough to be annoying, but maybe not often enough to commit to memory, and other things I feel like writing about.
Tuesday, September 23, 2008
Mounting Shares with Spaces
Monday, September 22, 2008
Removing SVN folders from a directory
rm -rf `find . -type d -name .svn`
Incorrect DNS Settings Reappearing
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
RewriteEngine onThis same format could be used to hide any directory on a web server.
RewriteRule \.svn/ - [F]
Thursday, February 21, 2008
Finding Disk space Hogs
du -k -s * |sort -nthis 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`That backs up all the current .sql files in a directory into a file with todays date as the name
tar czvf SQL-$backup.tar.gz *.sql
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).
Friday, February 1, 2008
Enable or Disable the CTRL+ALT+DELETE Sequence
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 want to sync your hardware clock run the following.
mv /etc/localtime ~/localtime.old
ln -s /usr/share/zoneinfo/America/Denver /etc/localtime
/sbin/hwclock --systohc
UnBlocking Attachments in Outlook
You can unblock them though. (Full directions)
The meet of it comes down to:
- 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) - Under that key, add a new string value named Level1Remove.
- 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.
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
#!/bin/bash
cat ~/.ssh/id_rsa.pub | ssh $1 'mkdir -p .ssh; cat >> .ssh/authorized_keys'