Better Putty Color Scheme for existing Sessions on Windows

December 18, 2015 Leave a comment

Putty is a versatile tool for remote SSH access – however the color schemes are not too impressive. The blue especially is really bad. You can change the blue color in the settings but what if you already have a ton of putty Saved Sessions. You will have to painfully modify each. There is a better way by directly modifying the registry entry for all sessions at once.

I am doing this on Windows 7.
A word of caution, we will be modifying registry entries. I have done this many times without problems, however I will still say, do it at your own risk.

Right, lets get to it then.

Press Windows Key + R to get the Run prompt
Enter regedit and press Ok. This will open the registry editor
Navigate to HKEY_CURRENT_USER -> Software -> Simontatham -> PuTTY
Expand Sessions and you should see all your Saved Sessions listed there
Right Click on Sessions and select Export
Save the file as putty-original.reg somewhere where you can locate it
Dont modify this file, this is your backup file
If something goes wrong or you dont like the changes, you re-import this file and you are back where you started
Make a copy of the file call it putty-new.reg
Open putty-new.reg in your text editor ( i am using notepad++ or sublime )
This will have color value blocks for all your Saved Sessions.
You have to replace the entire color block with the new color block

Replace the color blocks with this new color block – do this for all color blocks


Once you have replaced blocks for all sessions in the file, save putty-new.reg
Double click on putty-new.reg to import the new settings.
Windows will ask for permissions and display warnings, go ahead click ok

Exit out of your current putty sessions and re connect.
You should see the new colors and color scheme.

If something went wrong, or you did not like the color scheme, double click putty-original.reg to get back to your old settings.
Keep putty-original.reg safely.

There are many links on the web which will let you build your own color schemes – try them

This color scheme I found here

Categories: Tips and Tricks Tags: ,

PHP 5.6 and Self Signed Certificates for Soap, file_get_contents

November 18, 2015 Leave a comment

Operating System: CentOS 7
PHP: 5.6

This is only for local machine and local development – use at your own risk

I a using a self signed SSL certificate on my local development machine and many functions in PHP refuse to work with self signed certificates.
Some of the functions are

  • file_get_contents()
  • fopen()
  • SoapClient()

my domain name for local machine: localhost
my Self Signed SSL certificate in PEM format: localhost.crt

If i use any of these functions to access a HTTPS resource, the calls fail with invalid certificate
eg file_get_contentc(“https://localhost/test.csv”); will fail

the easiest method is to force add your self signed certificate to the trusted ca-authority in the operating system and openssl

# this should already be installed if you have openssl installed
yum -y install ca-certificates

# copy your self signed cert to the /etc/pki/ca-trust/source/anchors - change certificate path as necessary
cp /etc/pki/tls/certs/localhost.crt /etc/pki/ca-trust/source/anchors

# update
sudo update-ca-trust

now SoapClient, file_get_contents and fopen should work without problems

Other way to do it is to manually send in the stream_context to each of the calls like here

GIT merge or squash 2 or more commits into 1

October 1, 2015 Leave a comment

git lets you squash 2 or more commits into 1 commit before pushing to upstream


you have a git repo
you make some changes and do a commit with message: commit 1
you make some more changes and do another commit with message: commit 2
you can then merge these 2 commits into 1 single commit before pushing your changes upstream
here is the concept on how to do it

My Work Environment

  • Windows 7 – 64 bit
  • git version 1.9.5.msysgit.0
  • git bash installed
  • notepad++ editor installed ( i will be using this as my default editor )

open gitbash

change your default editor to notepad++
this is for Windows 7 64 bit – make sure you have the correct path of the editor for your machine

git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

for testing – create a folder in your file system
open gitk and cd into the folder
initialize the test git repo

git init

create a file 1.txt
do the first commit on master

git add .
git commit -m "commit 1"

create a branch from master and checkout development

git branch development
git checkout development

create a file 2.txt and commit to development

git add .
git commit -m "commit 2"

create a file 3.txt and commit to development

git add .
git commit -m "commit 3"

at this point gitk should show you 3 commits on development branch
we will squash commit 2 and commit 3 into 1 commit with a final commit message

the HEAD~2 is for last 2 commits, for last 3 commits HEAD~3

git rebase -i HEAD~2

this will open up notepad++
you will see 2 commits at the top
pick ebbea73 commit 2
pick fd2055f commit 3

the first word is important: pick
you will keep the first commit the same ( pick ) and change all commits after that to an s ( for squash )
so the file will look like ( the commit hash will be different – this is just an example )

pick ebbea73 commit 2
s fd2055f commit 3

lets say you had 4 commits, then your file would look like ( s = squash at the beginning )

pick ebbea73 commit 2
s fd2055f commit 3
s eccea73 commit 4
s ftt055f commit 5

save and close the file
git should say rebasing and open another window for the commit message
this will be used as the commit message for the squashed commit
you can comment out ( with a hash # ) the first 2 commit messages and add your new commit message at the bottom
the file will look like this ( note that commit 2 and commit 3 messages have been commented out with a # )

# This is a combination of 2 commits.
# The first commit's message is:
#commit 2
# This is the 2nd commit message:
#commit 3
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# rebase in progress; onto 7500cac
# You are currently editing a commit while rebasing branch 'development' on '7500cac'.
# Changes to be committed:
# new file: 2.txt
# new file: 3.txt

save and close
git should say successfully rebased and updated refs/heads/development
gitk should show the new commit message and only 2 commits

Categories: GIT Tags: , ,

Increasing File Descriptors and Open Files Limit CentOS 7

September 17, 2015 4 comments

PS: See Andy Dyrcz answer in the comments for a better way to do this

Some programs like Apache and MySQL require a higher number of file descriptors.
This is how you can increase that limit for all users in CentOS 7
Commands require root access

# Find the default limit – check the open files line – it will be 1024

sudo ulimit -a

To increase edit nano /etc/sysctl.conf add the below line, save and exit

fs.file-max = 100000

We also need to increase hard and soft limits
Edit /etc/security/limits.conf add the below lines before the #End, save and exit

* soft nproc 65535
 * hard nproc 65535
 * soft nofile 65535
 * hard nofile 65535

Next run the command

sudo sysctl -p

for MySQL, edit /usr/lib/systemd/system/mysqld.service  and add the below 2 lines at the end, save and exit


then increase the table_open_cache and open_files_limit in my.cnf

# reload systemctl
 sudo systemctl daemon-reload

# if you modified mysql config, restart mysql and check values for table_open_cache and open_files_limit

systemctl restart mysqld.service

run the below command to check the open files limit – change user based on requirement
output should say: open files (-n) 65535

# for mysql
 su - mysql -c 'ulimit -aHS' -s '/bin/bash'

# for apache
 su - apache -c 'ulimit -aHS' -s '/bin/bash'

Changing SSH Ports CentOS 7

September 17, 2015 Leave a comment

Here is how to change the SSH port in CentOS 7

All commands require root privileges

SSH into the server with the default SSH port 22

edit /etc/ssh/sshd_config 

un-comment #Port and put your new SSH port number there

for example, if you choose 9898 as your new port, the file should look like

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
Port 9898

Make sure that the port you choose is not being used for any other purposes. For this you can use these commands

# list all services with their associated ports
semanage port -l

# check the current ssh port - you will see a couple of matches including the ssh_port_t
semanage port -l | grep '22'
ssh_port_t tcp 22

# check your new port - there should not be any matches with the exact port 
semanage port -l | grep '9898'

Now you need to tell SELinux about the new port – execute the command

semanage port -a -t ssh_port_t -p tcp #YOUR-NEW-PORT-NUMBER 


# -a: add, -t: service type, -p: protocol 
semanage port -a -t ssh_port_t -p tcp 9898

Restart the sshd service

systemctl restart sshd.service


this is just a precaution because if something goes wrong, you still have an active session that you can use to make modifications

if you close this session and you SSH with the new port does not work, then your system might become inaccessible

Now open a SEPARATE SSH session and try to log in with the new port

If you can log in then everything worked fine

you can also check the port assignments with

semanage port -l | grep ssh_port_t
Categories: Linux

Linux Cron not running ?

April 13, 2015 Leave a comment

There are 2 ways to set up periodic cron jobs in linux

  1. Put them directly in the crontab
  2. Put them in one of the cron directories – below are available

So you can create a script and put it in one of the directories and they will run according to schedule

For example, if i put a script in cron.hourly, it will be executed hourly etc

Before you do that, you have to take care of the below things

  • Make sure your script does not have an extension, else cron might ignore it. If you have a script named, just rename it to myScript
  • Make the script executable, use sudo chmod +x myScript
  • If using bash script remember to declare the #!/bin/bash at the top

Once you copy your script to the required directory, use this utility to test and see if cron will execute your script ( change cron directory as required )

sudo run-parts --test /etc/cron.hourly

Your script should show up here – else it wont be run

Categories: Linux, Tips and Tricks

Windows 7 – record WAV files

February 24, 2015 4 comments

The default audio recorder in Win 7 save the file as WMA. However, you can use this simple command to record audio and save to WAV instead

Go to Start Menu search bar and type the below command and hit enter

soundrecorder /file output.wav

The recorder will open up – record your audio and it will ask you to save the file as a WAV file instead of WMA

Categories: Tips and Tricks