Category: Linux

Force WordPress SSL HTTPS on Only One Page

RewriteEngine On Options -Indexes Options +FollowSymLinks RewriteBase / # force https for all URLs matching “subscribe.* # otherwise normal http request are unmolested # other methods that force ssl cause 301 redirects on # all pages RewriteCond %{HTTPS} =off RewriteRule ^subscribe https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ## standard rule but causes redirect loops #RewriteRule . /index.php [L]...

USB Linux Wipe Format Ext2 Filesystem

Find the correct device fdisk -l Unmount the device unmount /dev/sdc Wipe the device (handles bad blocks too) dd if=/dev/zero of=/dev/sdc bs=4k Format device mke2fs /dev/sdc1 Make a mount point mkdir /mnt/memstick Mount the device mount /dev/sdc1 /mnt/memstick

WordPress Draft Crawl by Baiduspider

An interesting log in Apache hosts log (below) surprised me. I saw this URL crawl attempt by what is supposed to be Baidu – I checked – it was. What is so surprising is that the URL is a sentence of a DRAFT I was working on at the moment (screenshot below – notice the draft status bottom right). This...

Find and Kill All Processes One Liner

Brilliant – where you need it – like when you accidentally try to open 8000 html files at once with your browser. sudo kill $(ps aux | grep ‘iceweasel’ | awk ‘{print $2}’) credit for Find and Kill All Processes One Liner – bash using grep and awk

How To Fix a missing eth0 adapter after moving HDD from one machine to another

Debian/Ubuntu Linux : How To Fix a missing eth0 adapter after moving HDD from one machine to another. Explanation : Debian and Ubuntu write the MAC address of the ethernet adapter to a file that prevents the eth card in the new machine from being recognized. Delete the lines in this persistent-net.rules file and upon reboot, linux will see the...

How To Block Traffic by Country using IPtables

http://www.linuxstall.com/block-country-iptables/ http://www.ipdeny.com/ipblocks/ http://www.ipdeny.com/ipblocks/data/countries/ #!/bin/bash # country codes ISO="cn it kr br ru tw af sa iq sy tr ua in jp id at ro pl bg vn hk ve th mx co ar ir cz ph eg pk" # set path IPT=/sbin/iptables WGET=/usr/bin/wget EGREP=/bin/egrep $IPT-save -c > /home/iptables/iptables_bak_$(/bin/date +\%Y\%m\%d\%H\%M\%S).txt SPAMLIST="countrydrop" ZONEROOT="/root/iptables" DLROOT="http://www.ipdeny.com/ipblocks/data/countries" cleanOldRules(){ $IPT -F $IPT -X $IPT -t nat...

unable to resolve host – not found or unable to stat

Debian 7 Apache 2.2.22 Virtualhost with only one website using ssl – ssl certificate is for www.example.com (not example.com) The following setup resolves the “unable to resolve host” error /etc/hosts 127.0.0.1 localhost {server ip address} www.example.com www /etc/hostname www.example.com However, if you have a new apache error [error] [client 127.0.0.1] script ‘/var/www/wp-cron.php’ not found or unable to stat Change hosts...

Checklist when rc.local does not run on boot on Debian 7 Wheezy

Checklist when rc.local does not run on boot on Debian 7 Wheezy Make sure file is located /etc/rc.local Permissions root:root 755 The shebang is in place in the first line #!/bin/sh -e You bash script has a . and full path ./home/me/myscript.sh The last line must be exit 0

script /var/www/wp-cron.php not found or unable to stat

[error] [client 127.0.0.1] script /var/www/wp-cron.php not found or unable to stat http://serverfault.com/questions/185954/hosts-file-entries-for-multiple-domains-on-vps 127.0.0.1 localhost localhost.localdomainxxx.xxx.xxx.xxx yourdomain1.com yourdomain1 yourdomain2.com yourdomain2 And those lines must have a few blank lines above the in the hosts file, or they will get overwritten each reboot.

Format USB and Unzip img to memory stick

Insert the USB stick Type [sudo fdisk -l] [enter] (-l is lower case L) You should see a line: Disk /dev/sdb: xxxxMB, xxxxxxxxxxxxxxbytes LOOK FOR > sdb < NOT sda the xxx should roughly match the size of the USB memory stick >> This confirms the device we want is sdb there should be NO * under Boot [a] –...

Mark Bad Blocks Check Hard Drive Linux

Which disk? sudo fdisk -l Non-destructive read-write test If you want to preserve your data try this first sudo badblocks -svn /dev/sdb smartmon Check to see if your fix worked sudo apt-get install smartmontools sudo smartctl –all /dev/sdb sudo smartctl -A /dev/sdb sudo smartctl -a /dev/sdb | grep -i reallocated Use DD to automatically mark bad blocks – destructive if...

How To Use DD to Wipe Hard Drive

Helpful to know which device is which fdisk -l Will write zeros to sda dd if=/dev/zero of=/dev/sda bs=1M Write random numbers to sda dd if=/dev/urandom of=/dev/sda bs=1M Wipe the MBR dd if=/dev/zero of=/dev/sda bs=446 count=1 or just add the partition number to sda to wipe certain partitions Creates an ISO disk image from a CD-ROM; in some cases the created...