Archive for December, 2009

Adding date/time to BASH history

Useful if you have several admins on a server, so you can figure out who did what when. Edit /etc/bashrc  and add: export HISTTIMEFORMAT=”%h/%d – %H:%M:%S “

crontab format

1 2 3 4 5 /path/to/command arg1 arg2 Where: * 1: Minute (0-59) * 2: Hours (0-23) * 3: Day (0-31) * 4: Month (0-12 [12 == December]) * 5: Day of the week(0-7 [7 or 0 == sunday]) * /path/to/command – Script or command name to schedule crontab -e = edit crontab -l = […]

chown a symlink

Not sure why I always forget this, but to chown or chmod a symbolic link rather than its target use the -h (no-dereference) flag: chown -h new_user symbolic_link_name

Fedora disable beeps!

Out of the box, Fedora seems to send every system event to the PC speaker, which is annoying!  To disable: /sbin/rmmod -v pcspkr To make this a persistent change edit /etc/modprobe.d/blacklist.conf adding: blacklist pcspkr or edit: /etc/rc.local (loads on boot) adding: /sbin/rmmod -v pcspkr

PHP 5.3 big changes!

Lots and lots of things are deprecated!  Probably a good idea to change the error reporting to something like: error_reporting = E_ALL & ~E_NOTICE ~ E_DEPRECATED magic_quotes_gpc,register_globals,safe mode seem to be deprecated Short PHP tags are disabled by default: short_open_tag = On more to come I’m sure…….

MySQL reset lost root password

/etc/init.d/mysql.server stop /usr/local/mysql/bin/safe_mysqld –user=mysql –skip-grant-tables –skip-networking & /usr/local/mysql/bin/mysql mysql> UPDATE mysql.user SET Password=PASSWORD(‘MyNewPass’) WHERE User=’root'; mysql> FLUSH PRIVILEGES; mysql> exit /etc/init.d/mysql.server restart Probably a good idea to clear the MySQL history afterwards or pull in the update from a txt file and delete!

Appcmd IIS7 command line tool

Appcmd list sites Appcmd list site “sitename” /config Appcmd start/stop sites “Default Web Site” (or whatever site you want to start) Appcmd add sites /name:”Site 5” /id:12 /bindings: /physicalPath:C:\inetpub\site5 Backup IIS config: appcmd add backup appcmd list backup appcmd restore backup It has much much more functionality – appcmd /h

Save password for mapped network drive

When you map a network drive in Windows, with a non-domain user for example, Windows will save the username but not the password.  To persistently store the password, use the following from cmd: net use x: \\server’\share /savecred /persistent:yes

Auto restart IIS when service unavailable

A bit crude but it works.  Make a schedule task for this batch file: del testsql1.asp C:\wget\wget.exe –timeout=30 –tries=1 find /C “SQLServer Test Code 1″ testscript.asp IF ERRORLEVEL 1 IISRESET /RESTART /TIMEOUT:120 /REBOOTONERROR

Force group policy update

To manually force Group Policy to refresh under Windows 2000, you use the command secedit /refreshpolicy Microsoft has replaced this command in Windows 2003 and XP with this command: gpupdate