Posts Tagged ‘Linux’

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

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!

BASH create random password

apg -MSNCL  -m8 -x11 -n10 -E\%\\\/\|\`\<\>\+\{\}\”\’ or < /dev/urandom tr -dc A-Za-z0-9_$*?! | head -c10 Another useful implementation thanks to, a sample random password generator (put in your ~/.bashrc): genpasswd() { local l=$1 [ “$l” == “” ] && l=20 tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs } Run it: […]

BASH email test script

#!/bin/bash # script to send simple email # Email To ? echo “Enter Mail To” read EMAIL # Email text/message EMAILMESSAGE=”/tmp/emailmessage.txt” echo “This is an email message test”>>$EMAILMESSAGE echo | date >> $EMAILMESSAGE echo “Test”>>$EMAILMESSAGE echo “Test”>>$EMAILMESSAGE nail -v -r “” -s “Test Email” -S smtp=mysmtpserver $EMAIL < $EMAILMESSAGE #Clean up rm /tmp/emailmessage.txt

Base64 Decode using shell

perl -MMIME::Base64 -ne ‘print decode_base64($_)’ < | less

Purge MySQL Binary Logs

If you have binary logging enabled in MySQL, for example if you are using replication, there is a good chance that these binary logs will grown pretty big and fill the disk.  It’s a good idea to set some limits in my.cnf expire-logs-days    = 20 max_binlog_size         = 104857600 If you find the need to purge […]

Crazy Zend Errors!

Like so: Zend� 2002062301�1�29734�169503�xù Ÿ2 ì½MlgÇu/x›¤ßÉ0 Y|RlÙn·r«n}>=%ÔJ^Ú‹‘”<Ä“1Ãnþ[Í›ìlK­Á´`A›Ù%›L?H XhÀ… kñyÐBh-ò.öh1„EÀ+ƒ0§îg}ž**’¢¸õÿœ[¿:çÔ©SU§ŒSøüﯽ0Û¼9 xÇ´D‘ ÑJUíÜ¿uûæÍ;mnmí÷SxeÜ3ó?Z½ô@÷åŽ,Ëjkvm{w¶ÕOJ÷²)sãOž¼ü7þðÙN½H§ÀzÞ×¾¤¾„¹Žë;þ,úæâ‡Nm „‰êâöþìêáÚ“W¯ÎÀmØ[3C¿¶³wuóp{o×Ì~»{‡k›;;{/϶[û_§ ùúáá­ÿüÛ¿mìÊ•;{‡³«×aùí›WwníÜ>xøw.=ùôåuø¯µõý½µ§ÁöìíÎv×®íí¯]ÚÛ»¹³ùŸÖÈcõc¤Y{¾ðvnÿß7M¾ Ioncube and Zend Optimizer don’t get on.  Ioncube needs to be loaded by PHP first to avoid problems.  Rather than loading them in php.ini, it’s wiser to add their own ini files in /etc/php.d which is then read alphabetically.