Collection of Cheat Sheets

overapi-logoI recently came across a site which holds a collection of cheat sheets, everything from Python, Ruby, MySQL, Linux and the list goes on! Check out OverAPI.com. They are a great reference point for almost everything.

Check it!

 

 


Start Apache without manually entering the SSL Passphrase

openssl-logoToday I started testing a SSL issuer 'STARTSSL' a free SSL certificate issuer that is authorized! Not self signed from my original thought. Visit the site here!

Well this is not on SSL issuer but more on how to remove a password from a private key Post. Since most SSL certificate on webserver reboot will ask for a password, I thought I would remove this. Simply run the following:

1
openssl rsa -in current_privatekey.key -out nopass_privatekey.key

Once this is created, update your config to look at the new key file. Restart Apache, the SSL cert should continue to work but without prompting for a password.

Enjoy


Using Top to show %CPU usage

Just thought I would share how to view and focus on %CPU usage, using the TOP command.

command - 'top'
change colors to while in top, click the 'Z' key
Focus on %CPU line click the 'X' key
to highlight the %CPU linux while focusing on %CPU click the 'B' key

Recorded a quick video on this as well if needed to show you what the output will look like, ENJOY:

 


Changing Timezones on Server

I get this question a lot. 'How do I change the timezone on my server?' Simple and quick, this can apply to both Ubuntu and CentOS Servers.

Run the following from the server:

1
2
3
~: date
Wed Apr 24 11:46:20 UTC 2013
~:

This will show you the current time, which on my server was set to UTC.

You can view all the timezones for Americas by doing the following:

1
~: ls /usr/share/zoneinfo/America/

Then you will want to do the following:

1
mv /etc/localtime /etc/localtime.bak04-24-2013

then

1
ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime

Once this is complete type date and you should see the new time

1
2
~: date
Wed Apr 24 06:59:55 CDT 2013

Now it is set to CDT. Hope this helps for anyone looking to update there Timezone on their server.


IP issues with WP-Comments and Varnish

varnish-cacheSo I started running into issues after installing Varnish and noticed comments to any of my posts are coming from 127.0.0.1. If you are unsure of what varnish is, here is a brief explanation of what it can do for you.

What is Varnish?

 Varnish Cache is a web accelerator, sometimes referred to as a HTTP accelerator or a reverse HTTP proxy, that will significantly enhance your web performance.

Varnish speeds up a website by storing a copy of the page served by the web server the first time a user visits that page. The next time a user requests the same page, Varnish will serve the copy instead of requesting the page from the web server.

This means that your web server needs to handle less traffic and your website’s performance and scalability go through the roof. In fact Varnish Cache is often the single most critical piece of software in a web based business. - Varnish-Cache

Here is a great video to explain more, found here!

Back to my issue. Comments would come in and I was not able to determine the origin of the comment as varnish was causing issue. Here is a great work around that would solve this issue.

You will want to edit 2 files in your WordPress config.

wp-includes/pluggable.php

and

wp-includes/comment.php 

Add the following code to the pluggable.php file

1
if ( !function_exists('get_user_real_ip') ) { function get_user_real_ip() { $userip = ( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; return $userip; } }

Then in the comment.php file, comment out the first line and replace with the second line

1
2
/**     $commentdata['comment_author_IP']    = apply_filters('pre_comment_user_ip', $commentdata['comment_author_IP']); */
        $commentdata['comment_author_IP']    = preg_replace( '/[^0-9a-fA-F:., ]/', '',get_user_real_ip() );

Then save the files, no need to restart Apache but you can if you like. Then you can test by submitting a test comment to yourself. You should see the IP of the client host and not 127.0.0.1. Hope this helps anyone running into this issue.

 


Awesome Linux AD


Banner Message

I've had questions lately on how to add a message to the server when logging in. Usually this is a message like:

'This is a production server, be caution of your actions.'

Things like that, you can also add ASCII art to the message, which is pretty cool for personal servers.

This is a banner. What you will want to do is add a banner to your sshd_config. Simply login to your server, then

1
sudo vim /etc/ssh/banner

In this file you will add your text/ASCII art, etc. Once this is completed, write and quit the file.

You will want to make sure that sshd can read the file. To do this simply:

1
sudo vim /etc/sshd_config

In this file towards the bottom you should see a commented line like the following:

1
#Banner none

If  you do not have this in the file you can simply add it. You will want it to look like the following:

1
Banner /etc/ssh/banner

Once this is uncommented and the banner path added, write and quit.

You will also need to restart sshd, simply run the following:

1
sudo service sshd restart

Logout and log back into the server and you should see your Banner message. Tada! Hope this helps to all of those looking to add a message to their servers before logging in.


Record your Shell session

Found a cool little way to record your terminal sessions. Granted you have 'history' that you can run to see your previously typed commands, but with 'script' it will allow you to record your sessions in a video type reply or by simply cat'ing out your output file.

To install script, simply run the following:

Linux(Redhat/Fedora/CentOS) Operating systems

yum install util-linux-ng

Linux(Ubuntu/Debian) Operating systems

apt-get install bsdutils

Once script is installed you can run 2 different commands, the first:

'script > /tmp/record.txt' - which will record your session, then you will be able to cat out the file record.txt. Once your session is complete, simply run the 'exit' command or Ctrl-D to end the session.

The second command will be:

'script -t -a 2> /tmp/time.txt /tmp/record.txt' - which will record actual playback of your session. Once completed, use the same 'exit' command or Ctrl-D to exit the session. -t for mentioning the time so that separate time stamps are logged in to /tmp/time.txt file and -a for appending those time stamps to /tmp/time.txt file

Then to reply your session run the following - 'scriptreplay /tmp/time.txt /tmp/record.txt'

Here is a video I found showing you this a little more in detail. Check it out video bellow! Hope this can prove to be useful.


Why we use Linux

Explanation at it finest. Enough said!

WP Lightbox 2 - About


Linux Powered Rifle

linuxscopeI recently came across an article on arstechnica about a Precision Rifle powered by Linux. As a all around weapons enthusiast and Linux Sys Admin, I was inclined to check out what this rifle was all about.

The article goes through details behind this manly/geeky firepower.

The Precision Guided Firearm is a "whole widget" type of thing—it's not just a fancy scope on top of a fancy gun, but rather a tightly integrated system coupling a rifle, an ARM-powered scope running a modified version of Angström Linux (with some custom BitBake recipes and kernel modules to support the rifle's proprietary hardware), and a linked trigger mechanism whose weighting is controlled by the scope. - arstechnica

The rifle made by a company here in Texas, TrackingPoint made this weapon available for anyone who wants to drop down 17 to 23k. From the looks of the way this technology is made, enthusiasts from weapon folks to gun geeks might enjoy this. I was able to get a little glimpse from TrackingPoint's Youtube Channel. (I'll post the videos bellow) Behind the optic assembly is an entire ARM-powered embedded system that knows everything there is to know about the characteristics of the rifle and its ammunition. The tracking scope also contains instrumentation to make it aware of ambient conditions, including temperature and humidity and atmospheric pressure, the incline and cant of the weapon, and its compass heading. The only thing you need to manually enter is the wind speed and direction, using a control on the top of the scope. -arstechnica

WP Lightbox 2 - About

As you can see above in the picture provided, this technology shows you everything you would need to get on point. This is where the bulk of the weapons technology is at. As well on the rifle itself. With use of an iPad, you can view down range at your target. The other thing is that this is a precision long range rifle with a fixed magnification of 35x. Long range, not looking to hit a 100 yard target with this weapon. To say the least this is technology at its finest. Innovating weapons and technology to the fullest. Watch out TrackingPoint might be the best weapons maker for our Military.

WP Lightbox 2 - About

You can view the entire in depth article here http://arstechnica.com/gadgets/2013/03/bullseye-from-1000-yards-shooting-the-17000-linux-powered-rifle/

Here is also some of their videos.