//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
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, 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
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'