Archive for the ‘Linux’ Category

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 www.cyberciti.biz, 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 “support@mydomain.com” -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($_)’ < test.in | less

SSH Tunnelling

Useful if access to a server is limited to selective IP addresses: ssh -i /home/me/.ssh/id_rsa -N -f -L3389:85.233.133.233:3389 me@myadminserver.net

Convert SSL from pem to pfx

Convert an SSL certificate from Apache pem to IIS pfx format. Copy the private key and certificate parts, from the PEM to their own files. Then: openssl pkcs12 -export -out ssl.pfx -in ssl.crt -inkey ssl.key This gave me a .pfx file i could import into IIS. If it’s an EV SSL, you can add the […]

SSH Tunnelling to local ports on Linux

1. firewall – ensure port 22 is open 2. ensure users have ssh access (in plesk by commenting lines in /usr/local/psa/var/root.controls.lock and granting a shell) 3. Ensure the sshd config allows it in /etc/ssh/sshd_config: AllowTcpForwarding yes comment out: PermitTunnel no service sshd restart

Mounting Windows shares on Linux

mount -t cifs -o username=user,password=pass,rw //192.168.0.100/mydir /mnt/mydir/ You could make this persistent on boot by putting it in /etc/rc.local for example.

screen on Linux

After installing screen you can have multiple sessions per ssh connection and they can be resumed if the connection is lost. type screen to start Now open a new window with “Ctrl-A” “c” You can create several windows and toggle through them with “Ctrl-A” “n” for the next window or “Ctrl-A” “p” for the previous […]