How to find files in Linux modified on specific date

The below code will find all *.php files in every directory under the /path/to/dir/ directory modified on 14th June 2015 (ie between 00:00 on 2015-06-14 and 00:00 on 2015-06-15, hence why you need both dates).

find /path/to/dir/ -type f -name "*.php" -newermt 2015-06-14 ! -newermt 2015-06-15

Just modify each part of the command to suit your needs!

Install and Setup OpenVPN on CentOS Linux

As it says on the tin, this is how to install OpenVPN on your Redhat based Linux server.

Repo

First ensure you have the Enterprise Packages for Enterprise Linux (EPEL) repository installed / enabled on your system.

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh epel-release-7-5.noarch.rpm

Install OpenVPN

First, install the package using Yum:

yum install openvpn

Copy the sample configuration file to where it can be edited and used as the main configuration.

cp /usr/share/doc/openvpn-*/sample/sample-config-files/server.conf /etc/openvpn/

Open the new configuration file using your favourite editor.

nano /etc/openvpn/server.conf

Look for this line and uncomment (i.e. remove the “;” to configure all clients to redirect their default network gateway through the VPN.

push "redirect-gateway def1 bypass-dhcp"

Look for these lines and uncomment. These IP addresses are those of the DNS server your VPN will use. You can change the IP addresses to, say, Google’s public DNS servers if you wish:

push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.8.4"

To improve security, remove the comments on the following lines to reduce the permissions of the OpenVPN daemon:

user nobody
group nobody

RSA Security Keys

OpenVPN versions prior to 2.3 were bundled with EasyRSA, however it is now a separate project and must be downloaded separately.

Navigate to the OpenVPN folder:

cd /etc/openvpn

Download EasyRSA from the OpenVPN website and uncompress: (Alternatively go to the releases folder of the below link to retrieve the latest version)

wget https://github.com/OpenVPN/easy-rsa/releases/download/2.2.2/EasyRSA-2.2.2.tgz
tar -zxvf EasyRSA-2.2.2.tgz

Open the new EasyRSA-2.2.2 folder and Edit the vars file in the EasyRSA-2.2.2 folder with your favourite editor:

cd EasyRSA-2.2.2
nano vars

Find the below line:

export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`

Replace with the following:

export KEY_CONFIG=/etc/openvpn/EasyRSA-2.2.2/openssl-1.0.0.cnf

Find the below KEY_ settings and edit to suit your requirements (find list of country codes here):

export KEY_COUNTRY="GB"
export KEY_PROVINCE="London"
export KEY_CITY="London"
export KEY_ORG="TinnedGeek"
export KEY_EMAIL="webmaster@tinnedgeek.com"

Exit and save the configuration file and then prepare to generate the RSA certificate:

chmod 755 *
source ./vars
./vars
./clean-all

Build CA (follow the on-screen prompts):

./build-ca

Build key server (follow the on-screen prompts) and answer ‘yes’ to commit:

./build-key-server server

Build Diffie Hellman key exchange file (may take a while to process to generate the random key)

./build-dh

Generate keys to allow clients to authenticate and connect. Generate as many client keys as you need for each client program or device:

./build-key client1

Move into the keys directory and copy the respective files to the OpenVPN directory:

cd /etc/openvpn/EasyRSA-2.2.2/keys
cp ca.crt dh2048.pem server.crt server.key /etc/openvpn/

Disable SELinux

Disable SELinux by editing the SELinux configuration file:

nano /etc/selinux/config

Replace the below:

SELINUX=enforcing

With:

SELINUX=disabled

Routing and IPTables

Create an iptables rule to allow routing of our VPN subnet:

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
service iptables save

Then, enable IP Forwarding in sysctl:

nano -w /etc/sysctl.conf

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

Finally, apply our new sysctl settings. Start the server and assure that it starts automatically on boot:

sysctl -p
service openvpn start
chkconfig openvpn on

Troubleshooting

If you get the following error:

service openvpn start
Redirecting to /bin/systemctl start  openvpn.service
Failed to issue method call: Unit openvpn.service failed to load: No such file or directory.

Then start the OpenVPN server manually:

openvpn /etc/openvpn/server.conf

And voila!

List of Country Codes for SSL Certificate

AF Afghanistan
AX Åland Islands
AL Albania
DZ Algeria
AS American Samoa
AD Andorra
AO Angola
AI Anguilla
AQ Antarctica
AG Antigua and Barbuda
AR Argentina
AM Armenia
AW Aruba
AU Australia
AT Austria
AZ Azerbaijan
BS Bahamas
BH Bahrain
BD Bangladesh
BB Barbados
BE Belgium
BZ Belize
BJ Benin
BM Bermuda
BT Bhutan
BO Bolivia
BA Bosnia and Herzegovina
BW Botswana
BV Bouvet Island
BR Brazil
IO British Indian Ocean Territory
BN Brunei Darussalam
BG Bulgaria
BF Burkina Faso
BI Burundi
KH Cambodia
CM Cameroon
CA Canada
CA Canada
CV Cape Verde
KY Cayman Islands
CF Central African Republic
TD Chad
CL Chile
CN China
CX Christmas Island
CC Cocos (Keeling) Islands
CO Colombia
KM Comoros
CK Cook Islands
CR Costa Rica
CI Cote D’Ivoire (Ivory Coast)
HR Croatia (Hrvatska)
CY Cyprus
CZ Czech Republic
CS Czechoslovakia (former)
DK Denmark
DJ Djibouti
DM Dominica
DO Dominican Republic
TP East Timor
EC Ecuador
EG Egypt
SV El Salvador
GQ Equatorial Guinea
ER Eritrea
EE Estonia
ET Ethiopia
FK Falkland Islands (Malvinas)
FO Faroe Islands
FJ Fiji
FI Finland
FR France
FX France, Metropolitan
GF French Guiana
PF French Polynesia
TF French Southern Territories
GA Gabon
GM Gambia
GE Georgia
DE Germany
GH Ghana
GI Gibraltar
GB Great Britain (UK)
GR Greece
GL Greenland
GD Grenada
GP Guadeloupe
GU Guam
GT Guatemala
GG Guernsey
GN Guinea
GW Guinea-Bissau
GY Guyana
HT Haiti
HM Heard and McDonald Islands
HN Honduras
HK Hong Kong
HU Hungary
IS Iceland
IN India
ID Indonesia
IE Ireland
IM Isle of Man
IL Israel
IT Italy
JM Jamaica
JP Japan
JE Jersey
JO Jordan
KZ Kazakhstan
KE Kenya
KI Kiribati
KR Korea (South)
KW Kuwait
KG Kyrgyzstan
LA Laos
LV Latvia
LS Lesotho
LY Libya
LI Liechtenstein
LT Lithuania
LU Luxembourg
MO Macau
MK Macedonia
MG Madagascar
MW Malawi
MY Malaysia
MV Maldives
ML Mali
MT Malta
MH Marshall Islands
MQ Martinique
MR Mauritania
MU Mauritius
YT Mayotte
MX Mexico
FM Micronesia
MD Moldova
MC Monaco
MN Mongolia
ME Montenegro
MS Montserrat
MA Morocco
MZ Mozambique
MM Myanmar
NA Namibia
NR Nauru
NP Nepal
NL Netherlands
AN Netherlands Antilles
NT Neutral Zone
NC New Caledonia
NZ New Zealand (Aotearoa)
NI Nicaragua
NE Niger
NG Nigeria
NU Niue
NF Norfolk Island
MP Northern Mariana Islands
NO Norway
OM Oman
PK Pakistan
PW Palau
PS Palestinian Territory
PA Panama
PG Papua New Guinea
PY Paraguay
PE Peru
PH Philippines
PN Pitcairn
PL Poland
PT Portugal
PR Puerto Rico
QA Qatar
RE Reunion
RO Romania
RU Russian Federation
RW Rwanda
GS S. Georgia and S. Sandwich Isls.
KN Saint Kitts and Nevis
LC Saint Lucia
VC Saint Vincent and the Grenadines
WS Samoa
SM San Marino
ST Sao Tome and Principe
SA Saudi Arabia
SN Senegal
RS Serbia
SC Seychelles
SL Sierra Leone
SG Singapore
SK Slovak Republic
SI Slovenia
SB Solomon Islands
ZA South Africa
ES Spain
LK Sri Lanka
SH St. Helena
PM St. Pierre and Miquelon
SR Suriname
SJ Svalbard and Jan Mayen Islands
SZ Swaziland
SE Sweden
CH Switzerland
TW Taiwan
TJ Tajikistan
TZ Tanzania
TH Thailand
TG Togo
TK Tokelau
TO Tonga
TT Trinidad and Tobago
TN Tunisia
TR Turkey
TM Turkmenistan
TC Turks and Caicos Islands
TV Tuvalu
UG Uganda
UA Ukraine
AE United Arab Emirates
US United States
US United States of America
UY Uruguay
UM US Minor Outlying Islands
SU USSR (former)
UZ Uzbekistan
VU Vanuatu
VA Vatican City State (Holy See)
VE Venezuela
VN Viet Nam
VG Virgin Islands (British)
VI Virgin Islands (U.S.)
WF Wallis and Futuna Islands
EH Western Sahara
YE Yemen
ZM Zambia

Check whether your partition table uses GPT or MBR

Easiest way to check whether your linux server uses GPT or MBR for partition tables is to run the GPT fdisk program (gdisk):

# gdisk -l /dev/sda
(Where /dev/sda is the device being queried)

This will output something similar to the following response where the partition table type is clearly listed:

GPT fdisk (gdisk) version 0.8.6

Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format.
***************************************************************

Automatically reduce/scale CPU frequency in Linux

I have recently been converting my old computer into a webserver and leaving it switched on in my lounge. After the constantly whirring cooling fan started to bother me, I looked at reducing the CPU frequency in order to reduce heat production (and power consumption).

A bit of research led me to try and install CPUSPEED. However I when I tried to install via yum, I kept the getting package not available error.

I have since found the CPUPOWER package:

yum install cpupower
# cpupower --help
Usage:	cpupower [-d|--debug] [-c|--cpu cpulist ]  []
Supported commands are:
	frequency-info
	frequency-set
	idle-info
	idle-set
	set
	info
	monitor
	help

Not all commands can make use of the -c cpulist option.

Use 'cpupower help ' for getting help for above commands.

This is clearly very powerful for controlling the CPU. Enjoy the help file to find the answer, or for automatic control:

--cpu all frequency-set --governor ondemand

How to track a Dell/Alienware delivery via WUK and Syncreon

I recently ordered a new laptop via Dell. After it was dispatched, I was given tracking information for WUK which gave me the following error:

“The Order Number entered did not match the Customer Number”

How did I solve it?

I had an 8 digit order number and added a 0 to the beginning to make it 9 digits long. My customer number consisted of GB1 followed by 7 more numbers. Replace the GB1 with 02 and it should work.

Change British Airways Reservation – What Constitutes a ‘Low’, ‘Medium’ or ‘High’ Additional Fare?

Booked a British Airways flight but want to change the date/time? That is easy enough as the guide shows below, however what about the ‘Additional Fare’? The last time I tried to change my flight, I got an error and was required to phone the BA Booking Phone line.

One of the best benefits of booking online is the ability to check the different options very quickly without having to explain what you want to a travel agent. With the array of options available, I didn’t want to go through each one with the BA agent but instead have an idea of what I was getting for myself.

Login to your Executive Club account and select ‘Manage my Booking’. From there, select the flight you’d like to change, select ‘Change/Cancel Booking’ and then select from either from of the upgrade options or to ‘Change Date/Time of my flight’ as per the demonstration below.

BA Change Flight Booking

 After asking you to confirm which flight you’re changing, if other options are available you will be confronted with a screen that looks similar to this:

Change Flight Options

I like the look of this list – there are even options to upgrade on different planes. The problem is that instead of showing a number, all you are shown is a ‘Low’, ‘Medium’ or ‘High’ additional fare. Understandably, it is a ‘High’ additonal fare to change my World Traveller flight to a Club World flight. No dramas.

What does the catch-all fare title mean?

After a bit of back and forth with the agent, I am posting my results to save you time!

‘Low’ means less than £1000 to change.

‘Medium’ means £1000 to £3000 to change.

‘High’ means more than £3000 to change.

To cut a long story short, I think British Airways have a slightly different definition of what ‘Low’, ‘Medium’ and ‘High’ really means to the average consumer.

So I think I’ll stick with my World Traveller fare instead…

How to mount a *.vhd image in Windows 7

1) Right click on ‘Computer’ -> select ‘Manage’

right-click-manage-computer

2) Expand ‘Storage’ -> select ‘Disk Management’ and let HDD information load -> right click on ‘Disk Management’ -> select ‘Attach VHD’

right-click-attach-vhd-disk-management

 

3) Browse and select the VHD image you would like to use. Click OK.

add-vhd-browse

 

4) The VHD image should now mount. If autoplay is enabled, this will appear.