tag:blogger.com,1999:blog-67008005762182938562024-03-27T02:11:43.344-07:00IT MeditateLove for learning and troubleshootingUnknownnoreply@blogger.comBlogger27125tag:blogger.com,1999:blog-6700800576218293856.post-13896656927466216062014-04-09T11:20:00.003-07:002014-04-09T11:39:31.103-07:00Why my computer is slow? 7 steps to make your Windows 7 faster.<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
Why my computer is slow?</h2>
Perhaps this is the question that millions of people around the globe are asking every day. This is popular topic within the Windows users and there is usually good reason why your computer is slow.<br />
<br />
Personally now days i can tune almost any windows computer to work fast. Or if not fast, at least a lot faster. There is few tuning tips that i want to give. If you follow these steps, your computer will be faster.<br />
<br />
I don't like when people are recommending reinstalling of whole Windows every time when computer is acting slowly. Its easy solution, like cheating. 90% of the time, its not even necessary.<br />
<br />
Your computer has became slow, since its stuffed with running processes. Every time when you any kind of application running on background, its eating CPU cycles and consuming memory. Your hard drive has started defragmenting. Defragmenting means that bits that reside your physical hard drive surface has been scattered, and system needs to spend extra time looking for them.<br />
<br />
To keep your computer running smoothly, you need to keep things simple. Here is few tips that i recommend doing, if you wish to kick some speed to your can. These examples are for Windows 7. This might be bit aggressive approach, so pay attention. Sometimes desperate time require desperate measures!<br />
<br />
<h2 style="text-align: left;">
Performance tuning Windows 7</h2>
<div>
<br /></div>
<h3 style="text-align: left;">
<b>1. Make sure that your windows is up to date.</b></h3>
<div>
This is natural and good step to start tuning your Windows. If you missed service pack updates, that is going to affect your performance since it includes many performance updates. Check your updates, update everything you can, reboot and repeat this until Windows update doesn't have anything else to offer. Open up start menu and search for '<b>Windows Update</b>'. Then just click '<b>Install updates</b>'.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj12bdbowog0Ol8rVpMYEl0Qhd4tpDFZu3fWWQC92m1UxwkyesGmc83exlAC0NT1R-ZZiH2PvbCDSqzikbfOiDIzlzZW9jc7zPlGwEH4ILE6W3i0dApSYFUAOe5xfrFgwOt4CNxwT9a0AHX/s1600/windows+update+1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj12bdbowog0Ol8rVpMYEl0Qhd4tpDFZu3fWWQC92m1UxwkyesGmc83exlAC0NT1R-ZZiH2PvbCDSqzikbfOiDIzlzZW9jc7zPlGwEH4ILE6W3i0dApSYFUAOe5xfrFgwOt4CNxwT9a0AHX/s1600/windows+update+1.png" height="320" width="249" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Search for 'Windows Update'</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSE7TVTF-KoMCXMB8kCPoC9CQbT6hppjj-7biy0DwIToKOMEBpDLFiXaaPu2CJhgfLTdWbg9Ln4VCQWRch2t-HFwHe8cNRujiWHW3BYo7nILeMQMXUGaYTJXcYt_rBFDThhqhBUkycojQl/s1600/windows+update+2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSE7TVTF-KoMCXMB8kCPoC9CQbT6hppjj-7biy0DwIToKOMEBpDLFiXaaPu2CJhgfLTdWbg9Ln4VCQWRch2t-HFwHe8cNRujiWHW3BYo7nILeMQMXUGaYTJXcYt_rBFDThhqhBUkycojQl/s1600/windows+update+2.png" height="87" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Keep installing updates, until Windows update doesn't have anything else to offer.</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
</div>
<h3 style="text-align: left;">
<b>2. Delete unused applications, that you don't need anymore.</b></h3>
Be careful here, remove only applications that you recognize. There can be bunch of frameworks and drivers need to be there. But don't be scared, your system wont die if you accidentally deleted something that you shouldn't. Open '<b>Add or remove programs</b>' select application from the list, press uninstall and follow the instructions after uninstaller starts.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh23fjcgYyYCH3Q5YXHv83qHBEYcwo4J2AnbRxvOui-xM7aM7IuiPB1Krt3hfS4T6NpIbffDWucxvm8P3S_Jvt5Q0couD4_yIG6Qp4nFv-_gUNxmNrMF9YNe2YD2r1siA4jnuevt-cdq0BL/s1600/addremove1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh23fjcgYyYCH3Q5YXHv83qHBEYcwo4J2AnbRxvOui-xM7aM7IuiPB1Krt3hfS4T6NpIbffDWucxvm8P3S_Jvt5Q0couD4_yIG6Qp4nFv-_gUNxmNrMF9YNe2YD2r1siA4jnuevt-cdq0BL/s1600/addremove1.png" height="44" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Search for 'Add or remove programs'</td></tr>
</tbody></table>
<br />
<h3 style="text-align: left;">
<b>3. Remove ALL start up applications.</b> </h3>
Yes, everything, unless you are certain that you need them. Its easier to come back and enable the applications than just leave them hanging around useless. Anti virus software is a good example which you could leave enabled. Open application called '<b>msconfig</b>', select '<b>Startup</b>' tab and start deselecting applications. After you are done, hit OK.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg6gpj26StaAEusVbqR4vfw5MfEnU20ySsR92q54ZeFPNM-68hHY8ywNrbdxoLzMpN9neAIJoOsPiPnnzYgXSSjALxJZ6_ovbKMoqMcQEndypaEpK5c_AXDAqgpC9ul_sZ60Skx9cfxBvk/s1600/msconfig1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg6gpj26StaAEusVbqR4vfw5MfEnU20ySsR92q54ZeFPNM-68hHY8ywNrbdxoLzMpN9neAIJoOsPiPnnzYgXSSjALxJZ6_ovbKMoqMcQEndypaEpK5c_AXDAqgpC9ul_sZ60Skx9cfxBvk/s1600/msconfig1.png" height="51" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Search for 'msconfig'</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr3CLy1DdGg2EItcAlfn8MogGkGV5dMs2UTodeCpi7PjV0XymXcPjvt-syrc4Gtxmp0KtypCnqKf6f5DeGdrQi8k2Joq2DFECvTEf-AqmxGIXaqiP0Tnpx5WqtTDL02-nfJb3f8EyW5Q3q/s1600/msconfig2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr3CLy1DdGg2EItcAlfn8MogGkGV5dMs2UTodeCpi7PjV0XymXcPjvt-syrc4Gtxmp0KtypCnqKf6f5DeGdrQi8k2Joq2DFECvTEf-AqmxGIXaqiP0Tnpx5WqtTDL02-nfJb3f8EyW5Q3q/s1600/msconfig2.png" height="218" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Remove everything what you don't need.</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<h3 style="text-align: left;">
4. Run CCleaner</h3>
<div>
This handy piece of software will delete all of your temporary files with one click. You can also clean up your registry. Just hit '<b>Analyze</b>' to see what CCleaner is about to do and after that click '<b>Run Cleaner</b>'. You can repeat this step at '<b>Registry'</b> tab.</div>
<div>
<br /></div>
<div>
Download latest version of CCleaner here:</div>
<a href="http://www.piriform.com/ccleaner/download">http://www.piriform.com/ccleaner/download</a><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5rpV8pLD82oMClq3uuIdiiJkoPSnMfNrz9TJrAM98vrho8wxXZ8rC4s3T63rdO7XZMbWx2uXH2kWOpm7mgWDP1LJ8gMvGXcQREClAx8o-6Zu3ZY2jC2X3ggv6_IAe4xry3OAMv3VP3v1I/s1600/ccleaner2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5rpV8pLD82oMClq3uuIdiiJkoPSnMfNrz9TJrAM98vrho8wxXZ8rC4s3T63rdO7XZMbWx2uXH2kWOpm7mgWDP1LJ8gMvGXcQREClAx8o-6Zu3ZY2jC2X3ggv6_IAe4xry3OAMv3VP3v1I/s1600/ccleaner2.png" height="178" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">CCleaner analyze</td></tr>
</tbody></table>
<br />
<h3 style="text-align: left;">
5. Reboot your system</h3>
Now on system startup should already start feeling less painful. Keep an eye out if something is missing, go back to '<b>msconfig</b>' and re-enable applications if needed.<br />
<br />
<h3 style="text-align: left;">
6. Defrag your system</h3>
You really don't have to (or actually shouldn't) do this if you are using SSD drive. SSD or Solid state drives wears out by doing intensive read/write operations (which defrag is doing). And since seek-time of SSD drive is 0ms its really needed anyway. If you are not sure, listen to your harddrive, if you hear it spinning and keeping noise, then its a standard hard drive, and you most probably should defrag it.<br />
<br />
Open '<b>Disk Defragmenter</b>', click Disk you want to defrag and hit '<b>Defragment disk</b>'. This might take a while. Tts better to leave it running and not to do too much stuff with your computer during that time.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNVEPetIb-S1MXEXBwkthOZPpKX5JceK_H0maM4oyBmF4mtZKb7fSdXAWiPaIzc_2n4dSen-jCVD-79mGv1cPKWMByfXcGjWrgWw57Umfj5GzFFp2kyMEut4HED2b4k1pmAdlQNT2WDL62/s1600/defrag1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNVEPetIb-S1MXEXBwkthOZPpKX5JceK_H0maM4oyBmF4mtZKb7fSdXAWiPaIzc_2n4dSen-jCVD-79mGv1cPKWMByfXcGjWrgWw57Umfj5GzFFp2kyMEut4HED2b4k1pmAdlQNT2WDL62/s1600/defrag1.png" height="48" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Search for 'Disk Defragmenter'</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcaX8SMr22tpcFZAVMTSAa_2IeUbsXE8wEKYfRBUvUEI9M9ln2H4FGF_iJea_3ncoQp3mj8ehl_Qa7soNLEXJQmK9ZbGrsIuO08hAqRiZnEJTwdxR_L2AcgNp8v5Xr19CTDZYjSof2W3ZI/s1600/defrag2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcaX8SMr22tpcFZAVMTSAa_2IeUbsXE8wEKYfRBUvUEI9M9ln2H4FGF_iJea_3ncoQp3mj8ehl_Qa7soNLEXJQmK9ZbGrsIuO08hAqRiZnEJTwdxR_L2AcgNp8v5Xr19CTDZYjSof2W3ZI/s1600/defrag2.png" height="256" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Select drive and click 'Defragment disk'</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<h3 style="text-align: left;">
7. Clean your desktop</h3>
This might be an illusion, but seriously try it! Making your desktop clear from all the temporary documents and crap will make your computer appear to be running faster. Also change a shiny new background. If you don't know where to look for one, i recommend <a href="http://interfacelift.com/">http://interfacelift.com/</a>.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQE_PzLBHzRn4dDjkT9Cv8AEFMuYmx4vSQlS8liGtNjQTAZQCVKBSWzoJJL24k9IGLuA1x-g1zKXnZX7SpuO8e4VrA3SrHcGT9TiIis11WvsGlNlvrcfd8LSGwdi7b6mxUyV5y1iQYjvUP/s1600/desktop1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQE_PzLBHzRn4dDjkT9Cv8AEFMuYmx4vSQlS8liGtNjQTAZQCVKBSWzoJJL24k9IGLuA1x-g1zKXnZX7SpuO8e4VrA3SrHcGT9TiIis11WvsGlNlvrcfd8LSGwdi7b6mxUyV5y1iQYjvUP/s1600/desktop1.png" height="240" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Before</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiNsFpJm9qQ22b3pI3D54dAZazMKR3oN2R1ygUc9sujqUFNoaAiZhZUYxdfKM8r_QHG-wLm2toUoiX233DrLgUvjXznvel4vEndsMdSMBIBJ1eCkXhPUuprJb-UUdzrUOTAcaRds10uahE/s1600/desktop2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiNsFpJm9qQ22b3pI3D54dAZazMKR3oN2R1ygUc9sujqUFNoaAiZhZUYxdfKM8r_QHG-wLm2toUoiX233DrLgUvjXznvel4vEndsMdSMBIBJ1eCkXhPUuprJb-UUdzrUOTAcaRds10uahE/s1600/desktop2.png" height="241" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">After</td></tr>
</tbody></table>
Thats it, now your system should be bit faster again. Hopefully this was helpful.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-83561406360494238912014-04-07T11:38:00.001-07:002014-04-07T11:38:34.067-07:00Saving screenshot to clipboard or desktop on Mac OS X<div dir="ltr" style="text-align: left;" trbidi="on">
Here is few very handy shortcuts for taking screenshots in Mac OS X. Especially saving your region directly to clipboard can be a great time saver when working on a presentation or anything alike.<br />
<br />
<b>Cmd - Shift - 3</b><br />
Capture screen and save it on desktop.<br />
<br />
<b>Cmd - Shift - Control - 3</b><br />
Capture screen and save it on clipboard.<br />
<br />
<b>Cmd - Shift - 4</b><br />
Capture region and save it on desktop.<br />
<br />
<b>Cmd - Control - Shift - 4</b><br />
Capture region and save it on clipboard.<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8Q1MIe16o7YO1NO9cbf9MI_df0DOq3b3TEDnR7tGGc4H36E2pm28Ml1I7HuXukDoddMzvohhLEe9i9zfGaQXwR-QopJFPrWchg7icVhh9an5BooDqGs4-uod5jR5Q2B1VsGk-10Mtr41p/s3200/mac2.jpg" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8Q1MIe16o7YO1NO9cbf9MI_df0DOq3b3TEDnR7tGGc4H36E2pm28Ml1I7HuXukDoddMzvohhLEe9i9zfGaQXwR-QopJFPrWchg7icVhh9an5BooDqGs4-uod5jR5Q2B1VsGk-10Mtr41p/s3200/mac2.jpg" height="202" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Saving screenshot (3) or region (4) to clipboard.</td></tr>
</tbody></table>
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-86566301003679739112014-04-07T11:17:00.002-07:002014-04-07T11:17:37.276-07:00Taking screenshot on Samusung Galaxy S4<div dir="ltr" style="text-align: left;" trbidi="on">
It wasn't too obivius so i had to search for it.<br />
<br />
Classical way for taking screenshot in Samsung Galaxy S4 is to press:<br />
<b><br /></b>
<b>power/lock screen button + home button</b> at the same time for 1 second.<br />
<br />
After this screenshot will be taken and saved into your gallery. You could also use Samusing motion sensor and swipe your hand across the screen. This has to be somehow enabled from the menus, but since i find this feature useless anyway, i didn't even bother to try it out.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-59083695089626125402014-03-06T00:35:00.000-08:002014-03-06T00:36:48.356-08:00Enable password authentication for Google Compute Engine instance.<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="p1">
</div>
<div class="p1">
By default Compute Engine instance uses key pairs to authenticate you into your instance. This is very much recommended for security reasons. When you are first time connecting your instance through gcutil ssh, you will be asked to create a pass phrase for your ssh keys. Gcutil will create key pair in your local machine and copy it over to your project.</div>
<div class="p1">
<br /></div>
<div class="p1">
However if you want to authenticate ssh from outside world using password, here is a simple step what to do:</div>
<div class="p1">
<br /></div>
<div class="p1">
Edit file <b>/etc/ssh/sshd_config</b></div>
<div class="p1">
<br /></div>
<div class="p1">
Find this line from your sshd_config and change it to <b>PasswordAuthentication yes:</b></div>
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> # Change to no to disable tunnelled clear text passwords
PasswordAuthentication no </code></pre>
<div class="p1">
Then just reload your OpenBSD Secure Shell server (Debian).<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sudo /etc/init.d/ssh reload </code></pre>
In a CentOS init.d name is bit different, since it uses OpenSSH server.<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sudo /etc/init.d/sshd reload </code></pre>
Of course also remember to add firewall rule for TCP port 22. This can be done through Developers Console.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYpEv0QrNaNaJ3XPd4SvflPAhZoDzmBxIxNc53AfDujiO_FEaxpv0Myb6m72_SWwFFD5gjW3aPUb9ZCLu6bMJoBcJAqV3o6BoOWwusdI-v02ZNnGNkN0KU-mD6_1vDBnMwTrmxqTQLu17h/s1600/Screen+Shot+2014-03-06+at+10.32.50+AM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYpEv0QrNaNaJ3XPd4SvflPAhZoDzmBxIxNc53AfDujiO_FEaxpv0Myb6m72_SWwFFD5gjW3aPUb9ZCLu6bMJoBcJAqV3o6BoOWwusdI-v02ZNnGNkN0KU-mD6_1vDBnMwTrmxqTQLu17h/s1600/Screen+Shot+2014-03-06+at+10.32.50+AM.png" height="157" width="320" /></a></div>
<br />
<br /></div>
</div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-6700800576218293856.post-55529904254815991162014-02-28T08:15:00.003-08:002014-02-28T08:15:54.178-08:00Add quick print button for Google Chrome<div dir="ltr" style="text-align: left;" trbidi="on">
My friend was recently wondering that why doesn't chrome have quick print button. Back in the days i also got used to that quick print icon in Internet Explorer. And i do remember using it many times.<br />
<br />
In chrome, normally you could print by opening Chrome settings tab from right hand side and select "<b>Print..."</b>. Alternatively you can print by using keyboard shortcut <b>Ctrl+P</b> (Windows) or <b>⌘-P </b>(mac).<br />
<br />
Since my IE days are long gone, i would still like to have quick print icon in Google chrome. This is how you can get it.<br />
<br />
Select "Customize and control Google chrome", from the top right corner next to the address bar.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYRi0Db_ZOK8cUm3vq_oMN4ZytCgCqdVG-2oxFnrdyqOhIsy_26gAphsyFD1tpJjfOF5H-tfBwJpoQq9CxGQ6bpoMk_LuEcM2I8zCwvxTemGBNKk_iMrmS83JFGxq58ExFiWIl9fVxKJnD/s1600/printer1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYRi0Db_ZOK8cUm3vq_oMN4ZytCgCqdVG-2oxFnrdyqOhIsy_26gAphsyFD1tpJjfOF5H-tfBwJpoQq9CxGQ6bpoMk_LuEcM2I8zCwvxTemGBNKk_iMrmS83JFGxq58ExFiWIl9fVxKJnD/s1600/printer1.png" height="93" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Note that <b>Show Bookmarks Bar</b> must be enabled. Select <b>Bookmarks</b> -> <b>Bookmark</b> <b>Manager</b>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgF1YokN7hwU9WZtBepDZ0j0TGFMh_-UqmJRIH-kYw4P-TmnFVD5cHxUJSML_yk6R3Dgj6IVih8TsmDnlmbGC9AZT3NB_uHZvTpx-qOufkuqQh1slWC0cwB7LbUsEcAz7Cv2MTeZ21omojf/s1600/printer2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgF1YokN7hwU9WZtBepDZ0j0TGFMh_-UqmJRIH-kYw4P-TmnFVD5cHxUJSML_yk6R3Dgj6IVih8TsmDnlmbGC9AZT3NB_uHZvTpx-qOufkuqQh1slWC0cwB7LbUsEcAz7Cv2MTeZ21omojf/s1600/printer2.png" height="236" width="320" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
While Bookmarks Bar selected, right click anywhere on the window right hand side and select "<b>Add Page</b>".<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_EbaD4SSqgkRGWaNly1v27mARgZIDCGlWoFN4keojjmwpvl82VjvjKFEbWlJmzEMu-PW_bSq_sf_dq9yjYVOBN2h5UzsIYQF-mQmU0ghAsOFGRdYITeMghbxRKbrVr0x6VvpXo_9e-cjh/s1600/Screen+Shot+2014-02-28+at+6.09.27+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_EbaD4SSqgkRGWaNly1v27mARgZIDCGlWoFN4keojjmwpvl82VjvjKFEbWlJmzEMu-PW_bSq_sf_dq9yjYVOBN2h5UzsIYQF-mQmU0ghAsOFGRdYITeMghbxRKbrVr0x6VvpXo_9e-cjh/s1600/Screen+Shot+2014-02-28+at+6.09.27+PM.png" height="19" width="320" /></a></div>
<br />
<br />
Left textbox is the name of the bookmark, i made it "<b>Print</b>". Right side is the bookmark URL, we are going to place small javascript to it: <b>javascript:window.print()</b>. Then hit enter and you are done.<br />
<br />
Now you should have nice small quick print icon on your bookmarks bar. I wonder if you could actually have cool printer icon on it as well. Need to research that later.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwLvXqrIwc0c_H74EBuNKDNUZMixE_1FtYnXpL0861yAqlfnOaxkKGJoV482gTui_c8XwPpU2tdsc1EufjTwewRIrUMIG1_oZxrmnE2k8vD8OJXgvgcInMCybY-bWOyvpWZwamjYd9udnc/s1600/Screen+Shot+2014-02-28+at+6.11.59+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwLvXqrIwc0c_H74EBuNKDNUZMixE_1FtYnXpL0861yAqlfnOaxkKGJoV482gTui_c8XwPpU2tdsc1EufjTwewRIrUMIG1_oZxrmnE2k8vD8OJXgvgcInMCybY-bWOyvpWZwamjYd9udnc/s1600/Screen+Shot+2014-02-28+at+6.11.59+PM.png" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-6700800576218293856.post-32355599474642873242014-02-26T11:42:00.004-08:002014-02-26T11:42:56.934-08:00Linux: Bash single line for loop examples<div dir="ltr" style="text-align: left;" trbidi="on">
Knowing for loop in bash is definitely one of the most powerful tricks. For instance, it makes processing and reading files quick and painless in most cases. Since there can be countless use cases for this, i will write down some basic use scenarios.<br />
<br />
Here is few basic examples that could be useful.<br />
<br />
Creating files:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"><b> for i in 1 2 3 4;do touch file"$i";done
ls -l </b>
-rw-r--r-- 1 m 5000 0 Feb 26 21:31 file1
-rw-r--r-- 1 m 5000 0 Feb 26 21:31 file2
-rw-r--r-- 1 m 5000 0 Feb 26 21:31 file3
-rw-r--r-- 1 m 5000 0 Feb 26 21:31 file4
</code></pre>
<br />
Renaming all files within directory:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"><b> ls -l </b>
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic01.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic02.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic03.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic04.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic05.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic06.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic07.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic08.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic09.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic10.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic11.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic12.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic13.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic14.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic15.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic16.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic17.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic18.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic19.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic20.JPG
</code></pre>
<div class="p1">
<br /></div>
<div class="p1">
I want to change rename these pictures as picture_01, picture_02 and so on. I could do this:</div>
<div class="p1">
<br /></div>
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <b>for i in *;do mv $i $(echo $i | sed "s/pic/picture_/");done
ls -l </b>
total 0
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_01.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_02.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_03.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_04.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_05.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_06.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_07.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_08.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_09.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_10.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_11.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_12.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_13.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_14.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_15.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_16.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_17.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_18.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_19.JPG
-rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_20.JPG
</code></pre>
<div class="p1">
<br /></div>
<div class="p1">
* wildcard in this bash loop (for i in *) refers to all files within current working directory. That's why this for loop will catch all files.</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-18663439447049472592014-02-26T04:42:00.000-08:002014-02-26T11:13:28.868-08:00Jinja2 template engine, simple basics.<div dir="ltr" style="text-align: left;" trbidi="on">
Template engines will allow you to keep your HTML code outside of your code base. Managing and generating HTML in code is a bad practise. Templates will also give nice boost for performance and give you more secure system. this naturally depends how you are using your templates.<br />
<br />
This is what Jinja2 is hyping in their features list:<br />
<br />
<br />
<li style="line-height: 1.4em;">Sandboxed execution</li>
<li style="line-height: 1.4em;">Powerful automatic HTML escaping system for XSS prevention</li>
<li style="line-height: 1.4em;">Template inheritance</li>
<li style="line-height: 1.4em;">Compiles down to the optimal python code just in time</li>
<li style="line-height: 1.4em;">Optional ahead of time template compilation</li>
<li style="line-height: 1.4em;">Easy to debug. Line numbers of exceptions directly point to the correct line in the template.</li>
<li style="line-height: 1.4em;">Configurable syntax</li>
<br />
I was surprised to see how flexible Jinja2 for instance is. Variables can be modifier by filters you can see the full list of built in filters from here: <a href="http://jinja.pocoo.org/docs/templates/#builtin-filters">http://jinja.pocoo.org/docs/templates/#builtin-filters</a><br />
<br />
Here is some basics, which are usually enough to get going.<br />
<br />
I'm passing this test data to Jinja2 (I'm using Python):<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> template_data = {"page_title": "Testing templating",
"page_text": "This is my Jinja2 rendered web page!",
"loop_data": ["item1", "item2", "item3"]}
</code></pre>
<br />
Data is in dict format. It consists title, text and some data for demonstrating looping. Loop data is placed inside a list.<br />
<br />
This is my template file:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <html>
<head>
<title><b>{{ page_title }}</b></title>
</head>
<body>
<h1><b>{{ page_text }}</b></h1>
Loop data:
<b>{% for row in loop_data %}
{% if row == "item2" %}</b>
<font color="red"><b>{{ row }}</b></font>
<b> {% else %}
{{ row }}
{% endif %}}
{% endfor %}
</b> </body>
</html>
</code></pre>
<br />
Variables are referred with {{ var_name }}.<br />
<br />
For loop works like in any other programming language. Just loop list named <b>loop_data</b> and represent its data with variable <b>row</b> in the loop.<br />
<br />
There is also a example how simple IF works. Basically when row value hits "<b>item2</b>" in the loop, font color should be in red. You can also specify <b>{% elif %}</b> blocks.<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-75516855009618826442013-05-11T11:25:00.000-07:002013-05-11T11:44:57.154-07:00Python subprocess Popen Stdout and Stderr<div dir="ltr" style="text-align: left;" trbidi="on">
Python's cool subprocess module allows you to launch new processes and make stuff happen for you. You can easily catch Stdout and Stderr from these processes and do post processing as you like.<br />
<br />
You can redirect stdout and stderr into buffer by specifying stdout=subprocess.PIPE, stderr=subprocess.PIPE arguments into Popen. You can also ignore them be setting values to None. By default you are receiving Stdout and Stderr output normally.<br />
<br />
Python documentation states that you should not use PIPE with Popen since it can fill up OS Buffer, if your Stdout generates enough output. However this can be prevented by communicating with your process regularly by using <b>communicate().</b><br />
<br />
In my script, I'm waiting for suprocess to complete in a while loop, I'm polling the status of the process and then communicating to get stdout and stderr from the OS pipe buffer. Its also wise to sleep during the while loop to save overhead on CPU :-)<br />
<br />
Here is a small script to demonstrate this:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> import subprocess
import time
# Bash command that will be executed
cmd = "sudo apt-get upgrade"
# Launch subprocess
print "Launching command: " + cmd
sp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
sp_data = []
# Wait for process to finish
while sp.returncode is None:
print "Polling.."
sp.poll()
sp_data = sp.communicate()
time.sleep(1)
# Print results
print "Finished, returncode: " + str(sp.returncode)
print "Stdout:"
print "------------------------"
print str(sp_data[0])
print "Stderr:"
print "------------------------"
print str(sp_data[1])
</code></pre>
<br />
Output from this command is following:<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Launching command: sudo apt-get upgrade
Polling..
Finished, returncode: 0
Stdout:
------------------------
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Stderr:
------------------------
</code></pre>
<br />
To test that Stderr is also working, lets try to execute same command without sudo:<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Launching command: apt-get upgrade
Polling..
Finished, returncode: 100
Stdout:
------------------------
Stderr:
------------------------
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
</code></pre>
<br />
You might also want to look at my previous post about Popen, how to spawn parallel processes:<br />
<a href="http://itmeditate.blogspot.com/2012/09/experimenting-with-python-subprocess.html">Experimenting with Python subprocess Popen</a><br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-74209034351630590732013-05-11T10:06:00.000-07:002014-03-22T00:01:03.165-07:00Install webmin on Ubuntu server (12.04 LTS)<div dir="ltr" style="text-align: left;" trbidi="on">
Webmin is powerful web-based application for administering your Unix based or Windows system. With webmin, you can modify basic configuration of your server, manage cron jobs, execute commands etc.<br />
<br />
Webmin is modular, which makes it very flexible. You can see list of standard modules of latest version from this link:<br />
<a href="http://www.webmin.com/standard.html">http://www.webmin.com/standard.html</a><br />
<br />
First up, you should look up most recent version of webmin, you can check latest version from here:<br />
<a href="http://freefr.dl.sourceforge.net/project/webadmin/webmin/">http://freefr.dl.sourceforge.net/project/webadmin/webmin/</a><br />
<br />
Download package with wget:<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <b>wget http://freefr.dl.sourceforge.net/project/webadmin/webmin/1.620/webmin_1.620_all.deb</b>
</code></pre>
<br />
Webmin is going to need some dependencies in order to install, handy way to install all required packages is to use tool called gdebi. Run gdebi as sudo against your deb packet to install all dependencies.<br />
<br />
First you need to install packet gdebi-core:<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <b>sudo apt-get install gdebi-core</b> </code></pre>
<br />
Then you can run it against your .deb pakcage:<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <b>sudo gdebi webmin_1.620_all.deb</b>
Requires the installation of the following packages:
apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl libnet-ssleay-perl
web-based administration interface for Unix systems
Using Webmin you can configure DNS, Samba, NFS, local/remote filesystems
and more using your web browser. After installation, enter the URL
https://localhost:10000/ into your browser and login as root with your root
password.
Do you want to install the software package? [y/N]:<b>y</b>
</code></pre>
<br />
Now everything should be set up and we can proceed with webmin install:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <b>sudo dpkg -i webmin_1.620_all.deb</b>
...
Webmin install complete. You can now login to https://ip-192-168-1-1:10000/
as root with your root password, or as any user who can use sudo
to run commands as root. </code></pre>
<br />
Now everything should be set! You can start configuring your server from https://<your server>:10000/<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-12112614799159411222013-05-09T10:47:00.003-07:002013-05-09T10:47:51.935-07:00Grep running process<div dir="ltr" style="text-align: left;" trbidi="on">
If you need script to see if specified process is running, its easy to grep it from ps aux.<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@box:~$ ps aux | grep mysqld
mysql 1090 0.0 3.1 322660 48892 ? Ssl 19:53 0:00 /usr/sbin/mysqld
m 1903 0.0 0.0 4384 808 pts/0 S+ 20:29 0:00 grep --color=auto mysqld
</code></pre>
<br />
Problem here is that you can see your grep process which has your process as parameter. Script that relays on exit code ends up always being successful since grep process is on the list. You can easily fix this problem by adding additional pipe trough grep with <b>-v grep</b> parameter.<br />
<br />
<b>-v</b> option is also <b>--invert-match</b><br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ps aux | grep mysqld | grep -v grep 1>/dev/null&& echo Process is runing || echo Process is not running
</code></pre>
<br />
Its a lot easier to do this by using <b>pgrep</b>.<br />
<br />
<b>pgrep</b> scans running processes and returns process pid into your stdout.<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@box:~$ pgrep mysqld 1>/dev/null&& echo Process is runing || echo Process is not running
Process is runing </code></pre>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-77351153887067896042013-01-20T00:45:00.000-08:002013-01-20T00:45:00.048-08:00 CIDR and VLSM<div dir="ltr" style="text-align: left;" trbidi="on">
For a while it was very hard for me to understand what exactly is the difference between CIDR and VLSM. And since it took time to figure it out, i decided to post about it in a way how i would understand it myself.<br />
<br />
<b>Classless Inter-Domain Routing </b>is a method to allocate IP addresses into multiple logical networks. You may know CIDR for its notation, for example 192.168.0.0 with mask 255.255.255.0 would be notated as 192.168.0.0/24.<br />
<br />
CIDR has a 33 blocks of subnets, ranging from 0 to 32. Which makes subnetting a lot more efficient than classful subnetting. CIDR doesn't cover all possible subnet masks. Check the CIDR block table from <a href="http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing">wikipedia page</a><br />
<br />
<b>What if i want to use subnet mask of 255.255.255.253, which doesn't have CIDR notation ?</b><br />
<br />
This is still indeed a valid subnet mask, but using it is discouraged. There might be incompatibility with some routing hardware depending how they are parsing their bits. In CIDR bits are expected to be 1's from left to right.<br />
<br />
<b>Where does the /24 come from ?</b><br />
<br />
24 presents the amount of "turned on" bits in <b>subnet mask's</b> binary format. IPv4 address is a 32bit, so every octet in the IP address has 8 bit's. Every bit in octet has a value which you can either turn on or off.<br />
<br />
<table>
<tbody>
<tr><td>128</td><td>64</td><td>32</td><td>16</td><td>8</td><td>4</td><td>2</td><td>1</td>
</tr>
<tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td>
</tr>
</tbody></table>
<br />
If every bit is turned on, result would be 255<br />
<br />
Consider this IPv4 addreess:<br />
<br />
11000000 10100000 00001010 01100101<br />
<br />
First octet: 11000000: 128 + 64 = <b>192</b><br />
Second octet: 10100000: 128 + 32 = <b>168</b><br />
Third octet: 00001010: 8 + 2 = <b>10</b><br />
Fourth octet: 01100101: 64 + 32 + 4 + 1 = <b>100</b><br />
<br />
Subnet mask 255.255.255.0 in binary would look like this:<br />
<br />
<b>11111111 11111111 11111111</b> 00000000<br />
<br />
It has 24 "turned on" bits and 8 "turned off" bits, so thats <b>/24</b><br />
<br />
255.255.255.255.192 in the other hand would look like this:<br />
<br />
<b>11111111 11111111 11111111</b> <b>11</b>00000<br />
<br />
It has 26 one's and 6 zeroes, so this would be notated as <b>/26</b><br />
<b><br /></b>
<b>Then what is VLSM ?</b><br />
<br />
<b>VLSM </b>stand for <b>Variable Lenght Subnetmask</b>. Name kind of gives it away, so for example: instead of splitting your 192.168.0.0/24 network into 4 same size pieces, you can split it into multiple variable sized networks.<br />
<br />
So if i would want to hack <b>192.168.0.0/24</b> into 4 pieces it would look like this:<br />
<br />
Network A: 192.168.0.0/26 (64 hosts)<br />
Network B: 192.168.0.64/26 (64 hosts)<br />
Network C: 192.168.0.128/26 (64 hosts)<br />
Network D: 192.168.0.192/26 (64 hosts)<br />
<br />
So now all networks can have total of 64 hosts (minus network and broadcast).<br />
<br />
But what if my network A would have demand for more hosts, and 192.168.0.0/24 would be the only IP block that we can spare to allocate ?<br />
<br />
Let's pretend that B and C networks would need only half of the currently allocated IP's. So instead of 64 hosts they would have 32 hosts. We could mask these networks with 255.255.255.224 which is equivalent to /27, and has 32 hosts. And now we have 64 IP's unallocated which we can lend to network A!<br />
<br />
Using VLSM, we split the network more logically to serve all network better for their needs, our new networks would look like this:<br />
<br />
Network A: 192.168.0.0/25 (128 hosts)<br />
Network B: 192.168.0.128/27 (32 hosts)<br />
Network C: 192.168.0.160/27 (32 hosts)<br />
Network D: 192.168.0.192/26 (64 hosts)</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6700800576218293856.post-65850298183846420822012-12-31T12:58:00.000-08:002013-01-01T02:12:48.390-08:00RIP version 1 Vs RIP version 2<div dir="ltr" style="text-align: left;" trbidi="on">
<b>RIP = Routing Information Protocol</b><br />
<b><br /></b>
RIP was first introduced in 1988 in <a href="http://tools.ietf.org/rfc/rfc1058.txt">RFC 1058</a> and was developed for exchanging routing information among gateways and other hosts. By the time RIP served it purpose well when networks were small and didn't require complex subnet allocations.<br />
<br />
While RIPv1 is still widle used, in modern networks RIPv1 has been replaced with enchaned RIPv2. RIPv2 was developed 1993 and standardized 1998. It was developed to make RIP more effecient and secure.<br />
<br />
<b>How RIP works</b><br />
<br />
Basic function of RIP is to send periodic updates every 30 seconds. In this update, routers will exchange their routing tables, so they can keep track how to reach different networks. They will update even when there is no changes in the routing tables.<br />
<br />
Originally RIPv1 sent these updates trough broadcast address of 255.255.255.255. RIPv2 protocol uses 224.0.0.9 which is a multicast address, greatly saving bandwidth and increasing performance of updates.<br />
<br />
Fastest path will be decided with Hop Count (Hops between subnets). Hop Count is limited to 15 so everything above 16 hops is considered unreachable. This way infinite loops cannot happens in RIP network.<br />
<br />
<b>RIPv1 Vs RIPv2</b><br />
<b><br /></b>
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnEPLjr5v4UMIjoQmVaM3XSITVXOtTKlwUJMkj9nR_ENZ3JacDDIpmjawuUfiXJTQrD7CmB7LKe9XQtilVfDtQAzT6OPQdRycmsW-OEGS3483Fd-k-blXrLtwqSbh8jK9z2Sv1RoDrbVKP/s1600/ripv1_vs_ripv2.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="143" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnEPLjr5v4UMIjoQmVaM3XSITVXOtTKlwUJMkj9nR_ENZ3JacDDIpmjawuUfiXJTQrD7CmB7LKe9XQtilVfDtQAzT6OPQdRycmsW-OEGS3483Fd-k-blXrLtwqSbh8jK9z2Sv1RoDrbVKP/s400/ripv1_vs_ripv2.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">RIPv1 vs RIPv2</td></tr>
</tbody></table>
<b>Classful vs Classless</b><br />
<i><b><br /></b></i>
RIPv1 used classful routing, it means that RIPv1 couldn't send subnet information in its periodic updates.<br />
<br />
Classful routing protocol will look up the first octet of your IP address and determinate which class it belongs to.<br />
<br />
For instance if your IP address belongs to Class B, it has a default subnet of /16 (255.255.0.0). If your network would be 172.10.10.0/24, Classful routing protocol would see only 172.10.0.0/16 and ignore your /24 network.<br />
<br />
RIPv2 is a Classless routing protocol and now routers can have subnet masks in their routing tables. Enabling you to have any kind of network and RIP doesn't have to rely on the class of the IP address anymore!<br />
<br />
<b>Broadcast updates has been replaced with multicast</b><br />
<br />
Since broadcasting routing tables to every host in your network creates a lot of overhead. RIPv2 multicasts updates are only received by those who are interested about them. Which is a lot more efficient.<br />
<br />
<b>Lack of authentication creates security vulnerabilities</b><br />
<br />
Since RIPv1 doesn't support authentication. Any device can send updates to your routers. If malicious device enters your network, it could advertise any networks to neighbouring routers and they would trust it fully.<br />
<br />
RIPv2 can exchange passwords with MD5 encryption.<br />
<br />
<b>Lack of VLSM made IP addressing inefficient</b><br />
<b><br /></b>
RIPv2 can send subnetmasks in its periodic updates, which allows RIP to handle any size of subnets. This made IP addressing a lot more efficient since you can allocate smaller blocks of IP addresses for networks that didn't have many hosts.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-33947430239394595942012-12-30T06:15:00.000-08:002012-12-30T06:15:20.021-08:00Inodes in Linux<div dir="ltr" style="text-align: left;" trbidi="on">
<b>What is a inode, Why we need them ?</b><br />
<br />
Have you ever wondered where is your access permissions located? How does your system know that you are the owner of your home folder? Is it written on the file itself ?<br />
<br />
Answer to your questions is the Inodes also known as Index nodes.<br />
<br />
Inode is a data structure, inodes stores all data about the file objects, except data content and file name. Unix doesn’t use the file name to refer to the file, it uses the inodes and inodes are pointing to actual block addresses where the data is located. inodes reside in Inode table (see <a href="https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout">Ext4 Disk Layout</a>)<br />
<br />
Windows (NTFS) equivalent is <a href="http://en.wikipedia.org/wiki/Master_File_Table#Internals">Master file table</a><br />
Max OSX (HFS) equivalent is <a href="http://en.wikipedia.org/wiki/Hierarchical_File_System">Catalog File</a><br />
<br />
POSIX standard description for inode is:<br />
<br />
<br />
<ul style="text-align: left;">
<li>File size in bytes</li>
<li>Owner and Group of the file</li>
<li>Device ID (device where file is contained)</li>
<li>file mode (access permissions)</li>
<li>Timestamps (Content last modified (mtime), Inode last modified(ctime) and Last accessed (atime))</li>
<li>Link count (how many hard links point to the inode)</li>
<li>Pointers to actual disk blocks that are containing the data</li>
<li>Additional system and user flags (limit its use and modification)</li>
</ul>
<br />
<br />
Unix or Linux systems doesn't usually store creation date, but ext4 has an attribute for creation date.<br />
<br />
crtime (Create time) and also a dtime (Delete time)<br />
<br />
inodes allows us to do <a href="http://itmeditate.blogspot.fi/2012/12/linux-symbolic-links-soft-and-hard-links.html">linking</a> and gives us significant performance increase, because inodes points us to the right data block when we are querying for files.<br />
<br />
<b>You can run out of inodes, what happens then ?</b><br />
<b><br /></b>
inode limit is decided at file system creation time. Its not a fixed value. You can check your current inodes usage with <b>df -i</b><br />
<b><br /></b>
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 14983168 95016 14888152 1% /
</code></pre>
<br />
If you happen to run out of Inodes before you run out of disk space, you simply cannot create any more files or directories that consume Inodes, your things start to get very messy and unstable :)<br />
<br />
<b>stat command</b><br />
<b><br /></b>
stat displays file or file system status.<br />
<br />
You can query file or file system with stat, for example for file:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@srv:~/symlink_test$ stat file1
File: `file1'
Size: 65 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 5506851 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ m) Gid: ( 1000/ m)
Access: 2012-12-30 14:38:23.983590932 +0200
Modify: 2012-12-30 14:38:49.112092037 +0200
Change: 2012-12-30 14:38:49.112092037 +0200
</code></pre>
<br />
and for file system (use -f flag)<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@srv:~/symlink_test$ stat -f /dev/sda1
File: "/dev/sda1"
ID: 0 Namelen: 255 Type: tmpfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 191863 Free: 191821 Available: 191821
Inodes: Total: 191863 Free: 191262
</code></pre>
<br />
<br />
<b>Inode data pointers, direct blocks and indirect blocks</b><br />
<b><br /></b>
One inode can point only to 12 blocks of data.<br />
<br />
So if your block size is 4096, that would mean 12x4096 = 49152 bytes (48kb). This limitation would suck so that's why inode also has 3 indirect block pointers.<br />
<br />
Indirect block pointer points to a block of block pointers, which.. again can point to indirect blocks that will point to new set of block pointers! This allows us to have very large files in our file system.<br />
<br />
I tried to illustrate this with a picture but i ended up with a big messy pile of lines. Please check the <a href="http://en.wikipedia.org/wiki/Inode_pointer_structure">wikipedia page</a> for more info.<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-48009694884048917492012-12-29T05:47:00.002-08:002012-12-30T06:24:08.342-08:00Linux Symbolic links: Soft and Hard links<div dir="ltr" style="text-align: left;" trbidi="on">
<b>What is a symbolic link? Why its important ?</b><br />
<div>
<b><br /></b></div>
<div>
Symlink (Symbolic link) is a reference to another file or directory. It allows you to point multiple file names to single <a href="http://itmeditate.blogspot.fi/2012/12/inodes-in-linux.html">inode</a> that points to a physical block address on the disk.</div>
<div>
<br /></div>
<div>
Symlink's are mostly used as a shortcut's, they can make your life a lot easier by making your directories of data available for you where you want it.</div>
<div>
<div>
<br /></div>
<div>
<div>
<b>How do i make a symlink ?</b></div>
<div>
<b><br /></b></div>
<div>
Use the following option in <b>ln</b> command:</div>
<div>
<br /></div>
<div>
<div>
-s, --symbolic</div>
<div>
make symbolic links instead of hard links</div>
<div style="font-weight: bold;">
<br /></div>
</div>
<div>
For example:</div>
<div>
<br /></div>
<div>
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ln -s file1 file1_symlink
ls -l
-rw-r--r-- 1 m m 0 2012-12-29 14:57 file1
lrwxrwxrwx 1 m m 5 2012-12-29 14:58 file1_symlink -> file1
</code></pre>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<b>How do i make a hard link ?</b><br />
<b><br /></b>
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ln file1 file1_hardlink
ls -l
-rw-r--r-- 2 m m 0 2012-12-29 15:03 file1
-rw-r--r-- 2 m m 0 2012-12-29 15:03 file1_hardlink
</code></pre>
</div>
</div>
<div>
<br /></div>
<div>
<b>What is the difference between soft and hard link ?</b></div>
<div>
<br /></div>
<div>
Most important difference between hard and soft is that soft link depends on the original file.</div>
<div>
<br /></div>
<div>
For example, if i create a soft link and delete the original file that i linked, i cannot access my file trough symlink anymore and it becomes broken link.<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@srv:~/symlink_test$ cat file1_symlink
Hello World!
m@srv:~/symlink_test$ rm file1
m@srv:~/symlink_test$ cat file1_symlink
cat: file1_symlink: No such file or directory
</code></pre>
<br />
But in the case of hard link, my file is always accessible if there is one hardlink existing of the file<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@srv:~/symlink_test$ cat original
Hello World!
m@srv:~/symlink_test$ ln original hard_linked
m@srv:~/symlink_test$ cat original hard_linked
Hello World!
Hello World!
m@srv:~/symlink_test$ rm original
m@srv:~/symlink_test$ cat hard_linked
Hello World!
</code></pre>
<br />
Also hard links do not link paths on different volumes or file systems, soft links do. Soft links also consume inodes but hard links always shares the same inode.<br />
<br /></div>
<div>
<b>Where is the symbolic link stored ?</b></div>
<div>
<br /></div>
<div>
Symlinks are just references to a physical location of a file, if you make symlinks, its doesn't meant that you are losing disk space by creating a copies. Symbolic links are stored in the same place as <a href="http://itmeditate.blogspot.fi/2012/12/inodes-in-linux.html">inodes</a>, <a href="http://itmeditate.blogspot.fi/2012/12/inodes-in-linux.html">inodes</a> are the place where disks resides its block addresses. </div>
</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-77493247932482734762012-10-30T13:31:00.000-07:002012-10-30T13:31:15.899-07:00App Engine Templates and CSS with Python<div dir="ltr" style="text-align: left;" trbidi="on">
HTML is much easier to maintain in App Engine if you use templates. Templates are way of storing you HTML code, it also has syntax to show your application data where you want it to be.<br />
<br />
Django's templating engine is included in webapp2 framework.<br />
<br />
Here is a sample code how to render html template:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> import webapp2
from google.appengine.ext.webapp import template
class index(webapp2.RequestHandler):
def get(self):
self.response.out.write(template.render('index.html', {}))
app = webapp2.WSGIApplication([('/', index)])
</code></pre>
<br />
Just remember to store your html file in the same folder.<br />
<br />
Then you probably want to add CSS to your project? Create folder called css (or whatever you want to call it) and add it as a static directory to your app.yaml:<br />
<br />
This will map your "physical" css directory into <project url>/css url.<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> - url: /css
static_dir: css
</code></pre>
<br />
Create your style.css file and refer it in index.html and you are done!<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <link href="css/styles.css" rel="stylesheet" type="text/css">
</code></pre>
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-75855403384319961592012-10-01T13:14:00.002-07:002012-10-01T13:15:06.346-07:00Add Workspaces to Windows using VirtualWin<div dir="ltr" style="text-align: left;" trbidi="on">
There is definitely one very important function missing in Windows and that is Workspaces.<br />
<br />
Workspaces are "virtual desktops" that you can switch on fly. For instance Workspace 1 can have your browser open, Workspace 2 your applications and Workspace 3 your music player and so on. This makes managing multiple windows alot more simpler and faster.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXZjsydAPxQpvcGxWTNok4FipfVW4SOKOFeewXw4u8VjfXzH8WS6x0rOelL7mD0XcYL3E_uk6fLDi81G74Nlog92svuqxbDrqRVZYoRSHItAuqrTrfs5sGW96YIWtVoXiQM2I7WIF350t1/s1600/virtualwin.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="204" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXZjsydAPxQpvcGxWTNok4FipfVW4SOKOFeewXw4u8VjfXzH8WS6x0rOelL7mD0XcYL3E_uk6fLDi81G74Nlog92svuqxbDrqRVZYoRSHItAuqrTrfs5sGW96YIWtVoXiQM2I7WIF350t1/s640/virtualwin.PNG" width="640" /></a></div>
<br />
It didn't take long googling to find this desktop manager called <a href="http://virtuawin.sourceforge.net/">"VirtualWin"</a>. VirtualWin is a free software licensed under the GNU General Public License. It works on many Windows operating systems (Win9x/ME/NT/Win2K/XP/Win2003/Vista/Win7)<br />
<br />
It looked interesting and i wanted to give it a go.<br />
<br />
Setting up application was easy, no need to configure anything if you want to go with default settings. By default VirtualWin has 2x2 workspaces that can be changed to whatever you want in Setup screen. You can bind your own hotkeys for swapping workspaces, default is Control-Alt-Arrows combination, same as in Ubuntu for example!<br />
<br />
For me windows was hiding application icon that tells my current Workspace, so i had to change icon behaviour.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcYAWaiVkWpL0iQc6XFj9QG6YD-db4xekLTc4pVBxjYd4U4gvdTOQpQT7uLpzzV_SKQ9lGQF9jQB0lIgfm1-ZiAqvROC1gC-cZtkvn_3qKi4E9_2ETQSZVhKW0HAa2g6hQx6DEpAIg1vbz/s1600/Notification_Area_Icons.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="54" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcYAWaiVkWpL0iQc6XFj9QG6YD-db4xekLTc4pVBxjYd4U4gvdTOQpQT7uLpzzV_SKQ9lGQF9jQB0lIgfm1-ZiAqvROC1gC-cZtkvn_3qKi4E9_2ETQSZVhKW0HAa2g6hQx6DEpAIg1vbz/s640/Notification_Area_Icons.PNG" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Control Panel\All Control Panel Items\Notification Area Icons</td></tr>
</tbody></table>
<br />
<br />
Moving windows between workspaces works with Alt-Windows-Right/Left, it feels bit weird since it moves you with the window to next workspace, this can be also changed by changing the bind command from "WIN: Move to next desktop and follow" to "WIN: Move to next desktop".<br />
<br />
What a great piece of software, i can only wish that i would have discovered this earlier!<br />
<br />
<a href="http://virtuawin.sourceforge.net/">VirtualWin project page</a><br />
<br />
<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-9914245921151146072012-10-01T12:41:00.002-07:002012-10-01T12:48:35.400-07:00Amazon EC2: Getting started (Part 2/2)<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://itmeditate.blogspot.fi/2012/10/amazon-ec2-getting-started-part-12.html">Back to Amazon EC2: Getting started (Part 1/2)</a><br />
<br />
Now our instance is launching, view your instance by selecting "instances" from left navigation bar<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibFbpr7wSfR3Ol19D3nOqWZfNjrs2mgPZKaydEeG9ed_EPN0bHmgrMvezp4w9622m70QhID11vl9GmbICH2GAfFVkDEVGOQcuXu6h2oU8d1aKOfjorB1iiBBH8FRr3cW9PqhJjjXzn4gOL/s1600/Screen+Shot+2012-09-15+at+11.27.36+AM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibFbpr7wSfR3Ol19D3nOqWZfNjrs2mgPZKaydEeG9ed_EPN0bHmgrMvezp4w9622m70QhID11vl9GmbICH2GAfFVkDEVGOQcuXu6h2oU8d1aKOfjorB1iiBBH8FRr3cW9PqhJjjXzn4gOL/s1600/Screen+Shot+2012-09-15+at+11.27.36+AM.png" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs9JZIs0LOtHJFFDJN13XFxttDS4fHLmt6_l352-JTBfFE2Gzdbm9LOZTl_2ea4Z7-Q0n99i8IvjAqnym9vr5CNBLpqoi25zb5wrqKLluU8vhIusQevrzBHnHRFSuSRZJCL-7_FXBkJU_O/s1600/Screen+Shot+2012-09-15+at+11.27.12+AM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="14" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs9JZIs0LOtHJFFDJN13XFxttDS4fHLmt6_l352-JTBfFE2Gzdbm9LOZTl_2ea4Z7-Q0n99i8IvjAqnym9vr5CNBLpqoi25zb5wrqKLluU8vhIusQevrzBHnHRFSuSRZJCL-7_FXBkJU_O/s640/Screen+Shot+2012-09-15+at+11.27.12+AM.png" width="640" /></a></div>
<br />
My instance is now running but its still Initializing, so we have to wait until instance is fully launched, this will take couple of minutes. Once "Initializing" will be replaced with something like 2/2 checks passed, instance is ready for use.<br />
<br />
Next select your instance and properties windows will be populated with information about your instance. We need public DNS address in order to connect our instance. Private DNS address is used for internal communication of your instances.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9MJe-W2cDjJPUSHZJp5kcuZfBTm0iGjgQLrQSolkMtE__6cVQQrWttop2Zgpy_15BcwNl5u8skxED8w9Y0YYlETD13qbIrE_K_u9DYyQLEsjLxKWE3vmSDOEUlZKYgfnHmfqA4iiKYDdM/s1600/Screen+Shot+2012-09-15+at+11.39.00+AM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="56" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9MJe-W2cDjJPUSHZJp5kcuZfBTm0iGjgQLrQSolkMtE__6cVQQrWttop2Zgpy_15BcwNl5u8skxED8w9Y0YYlETD13qbIrE_K_u9DYyQLEsjLxKWE3vmSDOEUlZKYgfnHmfqA4iiKYDdM/s400/Screen+Shot+2012-09-15+at+11.39.00+AM.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<b>Connecting to your server using PuTTY</b><br />
<br />
First you must generate .ppk file from your private key .pem file. Windows users can follow <a href="http://itmeditate.blogspot.fi/2012/09/generate-ppk-out-of-pem-using-puttygen.html">this</a> guide and Linux users <a href="http://itmeditate.blogspot.fi/2012/10/generate-ppk-out-of-pem-with-linux.html">this</a>.<br />
<br />
Copy paste your Public DNS or IP address to "Host name". Then browse to<br />
<br />
Connection -> SSH -> Auth and Browse for your .ppk file and click Open.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHWEbbIN0dGw_37VLsfqP1ssqyz6g3OBLfRpiQSMmJPlEWjm9sQgZrbiLvioFyqhpDLWffnH5Yy1cLHI4jB_5U2LK7euxVmRyWyLtNnKWuLZMpB_TM0eqeWcKEmLjirJ5Jlx5ye9r8-6yO/s1600/browse_private_key.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="304" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHWEbbIN0dGw_37VLsfqP1ssqyz6g3OBLfRpiQSMmJPlEWjm9sQgZrbiLvioFyqhpDLWffnH5Yy1cLHI4jB_5U2LK7euxVmRyWyLtNnKWuLZMpB_TM0eqeWcKEmLjirJ5Jlx5ye9r8-6yO/s320/browse_private_key.png" width="320" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Since you are probably connecting your server for the first time PuTTY will alert you that this host key is not yet in system cache. You can ignore this and press Yes.<br />
<br />
In ubuntu server, default login name is <b>ubuntu.</b><br />
<b><br /></b>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5GrwBH4nO7Iu3AL49X8AUDhxvAbmwYD95m-fFXFdgDzOyvRXBYziFxINFtlnu-39w8uyi1sAVocBMlG9Q1wFLp89J1PRC7jKg2dkHjVgCyvI8jkh2RiYIUcRzLow-2FMRSO4KWCc0vd3Y/s1600/welcome_to_ubuntu.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="15" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5GrwBH4nO7Iu3AL49X8AUDhxvAbmwYD95m-fFXFdgDzOyvRXBYziFxINFtlnu-39w8uyi1sAVocBMlG9Q1wFLp89J1PRC7jKg2dkHjVgCyvI8jkh2RiYIUcRzLow-2FMRSO4KWCc0vd3Y/s400/welcome_to_ubuntu.png" width="400" /></a></div>
<b><br /></b>
<br />
<br />
Now we are logged in! Have fun!<br />
<br />
If you want to setup LAMP server to your instance. Check out this:<br />
<br />
<a href="http://itmeditate.blogspot.com/2012/09/setting-up-lamp-in-ubuntu-server.html">Setting up LAMP in Ubuntu server</a></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-79831704916847225042012-10-01T12:40:00.005-07:002012-10-01T12:48:19.819-07:00Amazon EC2: Getting started (Part 1/2)<div dir="ltr" style="text-align: left;" trbidi="on">
EC2 = <b style="background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.200000762939453px;">Amazon Elastic Compute Cloud</b><br />
<br />
In this post we will create EC2 Micro instance.<br />
<br />
For now Amazon EC2 has been my weapon of choice for testing out stuff. Instances are easy to launch and if you run it for couple of hours its basically free.<br />
<br />
This is very simple guide that runs trough the process of creating a virtual machine in Amazon infrastructure.<br />
<br />
I'm not going to cover signing up part, but its easy to do just follow the instructions. You need a valid credit card in order to register.<br />
<br />
If you are registering first time to AWS, you will be eligible for Amazon's free tier!<br />
<br />
Yes! Free micro instance for 12-months, the performance is not going to rock your world buts its alright to run small website on it. More information about free-tier <a href="http://aws.amazon.com/free/">here</a><br />
<br />
<a href="http://aws.amazon.com/ec2/">http://aws.amazon.com/ec2/</a><br />
<br />
Once you get your account done you can log into your AWS Console. As you can see EC2 is only one part Amazon Web Services, we are not covering any other services than EC2 now.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivtvFbHfRGaB5G-W5-48B5-1K3Gp8rlumWuMsxPS4wugakH5SbSSMIBMbtTcAV7E79b12wb2bta5U0dMt-NSFZ4vCV7OwRKj_baB1ew0b0lUsc1A9A33Xb7mRFnbLPLxY_Pd2jTHWVVJtA/s1600/Screen+Shot+2012-09-14+at+7.07.52+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="267" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivtvFbHfRGaB5G-W5-48B5-1K3Gp8rlumWuMsxPS4wugakH5SbSSMIBMbtTcAV7E79b12wb2bta5U0dMt-NSFZ4vCV7OwRKj_baB1ew0b0lUsc1A9A33Xb7mRFnbLPLxY_Pd2jTHWVVJtA/s320/Screen+Shot+2012-09-14+at+7.07.52+PM.png" width="320" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Click EC2 to proceed.<br />
<br />
Next up its importat to choose correct region in upper left navigation bar. If you are setting up your instance for your personal testing use, its good to choose region nearest to you.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW2Yl8ZWSSRf4EUs7E415EIx281qyg3B1DrPkHkDp_LkqiAm76UfcUz6lbUk-GeuUCbaUH-nixP64O2RLM6xa-Bjkr1rCEDWXmGq9Gr94KncmEuirvsvHtczeo4dZHs0iLpYcbL1DI9YDy/s1600/Screen+Shot+2012-09-14+at+7.10.12+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW2Yl8ZWSSRf4EUs7E415EIx281qyg3B1DrPkHkDp_LkqiAm76UfcUz6lbUk-GeuUCbaUH-nixP64O2RLM6xa-Bjkr1rCEDWXmGq9Gr94KncmEuirvsvHtczeo4dZHs0iLpYcbL1DI9YDy/s1600/Screen+Shot+2012-09-14+at+7.10.12+PM.png" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Once the region is selected hit "Launch Instance" button in the middle of the screen.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwOYBsy-0yx2vdahjXGVYLkun8k9gIk99L0tUCdsBiypm5GOMwY5Grz946AKy03KMhF303V7Q_BQbm4ul_FKO3jc1Zid5bu8jSeXXkf33F8o-lpdzxu9MJqrldnzXUAfrvJtKeoQljwzDN/s1600/Screen+Shot+2012-09-14+at+7.12.37+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwOYBsy-0yx2vdahjXGVYLkun8k9gIk99L0tUCdsBiypm5GOMwY5Grz946AKy03KMhF303V7Q_BQbm4ul_FKO3jc1Zid5bu8jSeXXkf33F8o-lpdzxu9MJqrldnzXUAfrvJtKeoQljwzDN/s1600/Screen+Shot+2012-09-14+at+7.12.37+PM.png" /></a></div>
<br />
<br />
<br />
<br />
You can either use classical wizard or quick launch, both do the same but in our case Quick launch is quicker (duh) and correct image seem to be at the first page (Ubuntu Server 12.04.1 LTS)<br />
<br />
Next set the name for your instance and set the name for your Key Pair. You must also download your key from the Download button next to Name field.<br />
<br />
Key Pair? Yes, Amazon provides public/private key pairs, public key goes into your virtual machine and you will be using private key. These keys must match in order to establish a connection to your server.<br />
<br />
You can only download this file once while creating the key pair so don't loose it! So I'm going to choose 64-bit Ubuntu server, you can use whatever you want.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsvcjhFDQLOfQJY5QJ8kInAv7PcD2K11ob4P8fPzGxGbk4E-giKKZWifGcT-DAxzWSNgTtG4Dfj7-v3nUvMAZ6bv9IR_sssNsl1l0nQZfdt58J4A-a2U5ppab2oGxcEyEAh5yejo78re6C/s1600/Screen+Shot+2012-09-14+at+7.19.12+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="390" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsvcjhFDQLOfQJY5QJ8kInAv7PcD2K11ob4P8fPzGxGbk4E-giKKZWifGcT-DAxzWSNgTtG4Dfj7-v3nUvMAZ6bv9IR_sssNsl1l0nQZfdt58J4A-a2U5ppab2oGxcEyEAh5yejo78re6C/s640/Screen+Shot+2012-09-14+at+7.19.12+PM.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Then we review our instance, we have Type t1.micro it is a Micro instance, it has 613 MB of memory poor I/O performance. But for testing purposes it will do fine. Personally at this point i would rename security group since it cannot be renamed afterwards.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2D5X6xl5zFXYs1r9ud1fVBwyqr4vUo36ktiqGmeaPc-y8aYN_EldQYrWilNe6kApWW22G8hMyoV8WcNrThK7ZPINyltmQdeyaz0tV_c1rlgPd8Ax05jbL7mGh6suYhtqueMRXJWmpDMMO/s1600/Screen+Shot+2012-09-14+at+7.44.35+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="386" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2D5X6xl5zFXYs1r9ud1fVBwyqr4vUo36ktiqGmeaPc-y8aYN_EldQYrWilNe6kApWW22G8hMyoV8WcNrThK7ZPINyltmQdeyaz0tV_c1rlgPd8Ax05jbL7mGh6suYhtqueMRXJWmpDMMO/s640/Screen+Shot+2012-09-14+at+7.44.35+PM.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
You can create your custom security group if you click "Edit details". Check " Create new Security Group", name it and set some kind of description for it. From the "Create a new rule" Dropdown you select predefined groups, choose what you need and click "Add Rule". Here you could restrict from what source IP addresses can access your service, default 0.0.0.0/0 means everyone. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After you are finished, click Create</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZB9_m-7glnwn9ivTtNioZHTu1YelN50MNlLLt2cGFsc39T7nn4cmHuXRX7NF6dIYjxkdpbjeyKD0_w_dPKuveWwIxIegfZoJ0T1sIc0uCuNntW_hV8FVhPdVWbzWAiPvHG4zsaUSRJ2Pr/s1600/Screen+Shot+2012-09-14+at+7.57.10+PM.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZB9_m-7glnwn9ivTtNioZHTu1YelN50MNlLLt2cGFsc39T7nn4cmHuXRX7NF6dIYjxkdpbjeyKD0_w_dPKuveWwIxIegfZoJ0T1sIc0uCuNntW_hV8FVhPdVWbzWAiPvHG4zsaUSRJ2Pr/s640/Screen+Shot+2012-09-14+at+7.57.10+PM.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
Click Save details, then you will return to review windows and click Launch.<br />
<br />
<a href="http://itmeditate.blogspot.fi/2012/10/amazon-ec2-getting-started-part-22.html">Continue to part 2</a><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-9105722185345089842012-10-01T12:37:00.002-07:002013-05-23T11:01:04.000-07:00Generate .ppk out of .pem with Linux (Ubuntu)<div dir="ltr" style="text-align: left;" trbidi="on">
Here is a example how to convert .pem to .ppk using Ubuntu.<br />
<br />
First you need to install package <b>putty-tools</b><br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sudo apt-get install putty-tools
</code></pre>
<br />
After install, all you really need to do is this:<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> puttygen key.pem -o key.ppk
</code></pre>
<br />
But.. with <b>-P </b>switch you can set passphrase for extra security, this is recommended and easy to do:<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> puttygen key.pem -o key.ppk -P -C "My server key"
</code></pre>
<br />
It is also recommended to set comment for your key using <b>-C </b>switch, because this string will be prompted to you when you are entering your passphrase.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIoXPIgrmaDLFVL3UDx0W1fiatZwwMyFSFnWG-OG2BBhdJF5bHU58sI3xe236TqQ2FAMg5r6aXhcc1xnr3bVpthkSL0frnSpRYRKxNcDOnl8Py6qjFgo2h-HO3ZG1TQP0OEXdlq0zH2jlx/s1600/passphrase_prompt.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="38" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIoXPIgrmaDLFVL3UDx0W1fiatZwwMyFSFnWG-OG2BBhdJF5bHU58sI3xe236TqQ2FAMg5r6aXhcc1xnr3bVpthkSL0frnSpRYRKxNcDOnl8Py6qjFgo2h-HO3ZG1TQP0OEXdlq0zH2jlx/s400/passphrase_prompt.PNG" width="400" /></a></div>
<br />
<br />
<br />
<br />
Note that you can also change passphrase afterwards by using <b>-P </b>switch<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@box:~/Downloads$ puttygen -P key.ppk
Enter passphrase to load key:
Enter passphrase to save key:
Re-enter passphrase to verify:
</code></pre>
<br />
And you are done!<br />
<br />
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-6700800576218293856.post-46552120662853566602012-09-24T12:41:00.000-07:002012-09-24T12:41:35.486-07:00Setting up LAMP in Ubuntu Server<div dir="ltr" style="text-align: left;" trbidi="on">
This guide will take you trough process of installing fully functional LAMP server in Ubuntu. You can setup this easily in few minutes.<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sudo apt-get update
sudo tasksel
</code></pre>
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTXf4EvlUm2eOluaHpG6Y5_WxskK2WICTLLgIi_zUlbnmucZ6NZc8SDD3aEn6YBrkCWRTUL0bYDAhmSCNMUS17ijfcogArsEvt0SSx51NZbNFNi4fu2PVGl7uo2QdL3IpZ9gkYbj7h5nU-/s1600/tasksel.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="267" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTXf4EvlUm2eOluaHpG6Y5_WxskK2WICTLLgIi_zUlbnmucZ6NZc8SDD3aEn6YBrkCWRTUL0bYDAhmSCNMUS17ijfcogArsEvt0SSx51NZbNFNi4fu2PVGl7uo2QdL3IpZ9gkYbj7h5nU-/s400/tasksel.png" width="400" /></a>
<br />
<br />
<br />
<br />
Move to <b>LAMP server </b>and check it by pressing space, then click TAB to move to Ok and press Enter.<br />
<br />
tasksell will download and install all necessary packets for you. Next you must enter MySQL root password and confirm it.<br />
<br class="Apple-interchange-newline" />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkyqPviMkHnHfhSWrUVaAUgCzeKSS20yOl_gIhaIy0r3fPkR5dVXy4IiaKDYEGos9FF1_tqogoHOX4nXy7ExVZDjVqjA0lfgKFu2x1L6wKZKTbDQkA1mR_GWOIhW8SyrD6KYHMoCSgU0KN/s1600/mysql_root_tasksel.PNG" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="111" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkyqPviMkHnHfhSWrUVaAUgCzeKSS20yOl_gIhaIy0r3fPkR5dVXy4IiaKDYEGos9FF1_tqogoHOX4nXy7ExVZDjVqjA0lfgKFu2x1L6wKZKTbDQkA1mR_GWOIhW8SyrD6KYHMoCSgU0KN/s400/mysql_root_tasksel.PNG" width="400" /></a>
<br />
<br />
<br />
<br />
<br />
Once install is completed, verify it by connecting to http://<your public dns or ip>/<br />
<br />
You should see this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5eTrEp7GX1U274IA62sCp3TcNsuewadL4HdwLD8JR_uCyPUxfEM4Vsvcdu4O9SGhZlA6zs7C79DcnvZj7B2DcT0IXK6we6gfeCxadQDAa6tQVcgLVF-xeNDpFp9rEMA_R4tyhU8Ypd2qy/s1600/apache_it_works.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="100" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5eTrEp7GX1U274IA62sCp3TcNsuewadL4HdwLD8JR_uCyPUxfEM4Vsvcdu4O9SGhZlA6zs7C79DcnvZj7B2DcT0IXK6we6gfeCxadQDAa6tQVcgLVF-xeNDpFp9rEMA_R4tyhU8Ypd2qy/s320/apache_it_works.PNG" width="320" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Yup! it works, now we will set up phpmyadmin for administrating MySQL<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sudo apt-get install phpmyadmin
</code></pre>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPNPbcTQgtCBZY72TEjR817ptZsVqkRb2eVJ415y9veTZkwJfpdJ3-4dvvBYvxUnUM7Pq1Wt1iz1I4DqmB3YL4wnqd4LDtgdjzQnafmJ3UOqoRBxJYH5gNXk2hbB0j0GgQsfRaG3y4kGBE/s1600/phpmyadmin_reconfigure.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="261" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPNPbcTQgtCBZY72TEjR817ptZsVqkRb2eVJ415y9veTZkwJfpdJ3-4dvvBYvxUnUM7Pq1Wt1iz1I4DqmB3YL4wnqd4LDtgdjzQnafmJ3UOqoRBxJYH5gNXk2hbB0j0GgQsfRaG3y4kGBE/s400/phpmyadmin_reconfigure.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Setup will automatically configure phpmyadmin for you.<br />
<br />
Select "apache2" from the list by pressing space<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi3dvwvFRZXvIn0kV5rnb3P_7eAShbHwogLtH2c1MyvwbWuIBURJK94NDF8BiUR0f4I_ZU78rCqAtMU9XrXjOaR5k92PXmn-KoWckcazc4-b1yAVFMzgttEUNc1vYanlQa21aiyZGLeRqQ/s1600/configure_phpmyadmin.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="143" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi3dvwvFRZXvIn0kV5rnb3P_7eAShbHwogLtH2c1MyvwbWuIBURJK94NDF8BiUR0f4I_ZU78rCqAtMU9XrXjOaR5k92PXmn-KoWckcazc4-b1yAVFMzgttEUNc1vYanlQa21aiyZGLeRqQ/s400/configure_phpmyadmin.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Configure database for phpmyadmin with dbconfig-common? -> Yes</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLYuj5s2e_uIprYnhFOxhX_-CTtp16Rbe8ZkDjmzstCqmJQp8ZZ5jr19cjWfRPonV0RFex9HIgBR33LIVOapIyFWFo_OmLWuGnUEVdCaWYn7V3K9AhszOW6w2i7rmixvOHZ2TKnnyf3BtJ/s1600/password_for_db_administrative_user.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="97" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLYuj5s2e_uIprYnhFOxhX_-CTtp16Rbe8ZkDjmzstCqmJQp8ZZ5jr19cjWfRPonV0RFex9HIgBR33LIVOapIyFWFo_OmLWuGnUEVdCaWYn7V3K9AhszOW6w2i7rmixvOHZ2TKnnyf3BtJ/s400/password_for_db_administrative_user.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Here you must enter your MySQL root password. The one you entered earlier!</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4U5nFsIA8lBJ1O9tgu4bKv2AkYM9PNW68jPYfWe-SU4lnRTk2pffSvD1rZUwVxLtGx_t_pjs5eyCL-97FBKngNj5PFfCqkXB3xEssbYJzas46NZu4Cbrd6y9KYgF2gyQeQod4nZ7Q_mzU/s1600/mysql_application_password.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4U5nFsIA8lBJ1O9tgu4bKv2AkYM9PNW68jPYfWe-SU4lnRTk2pffSvD1rZUwVxLtGx_t_pjs5eyCL-97FBKngNj5PFfCqkXB3xEssbYJzas46NZu4Cbrd6y9KYgF2gyQeQod4nZ7Q_mzU/s320/mysql_application_password.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Enter password for application password for phpmyadmin</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
This is password for user "phpmyadmin" that will be used for communication between MySQL Server and phpmyadmin.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
And we are set again, verify installation by visiting http://<your public dns or ip>/phpmyadmin</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHvcXTmJzQiB0pwkVRgQsA7KHgyyn8koUTrGZaMrAX7qR_mZEbzY5MRPlWAXak5-Fm7dAIhlMZW7g48v1o8go4rfJlRxm_B-v55xp-0TA4Ue4Jii6rodYTasPsvUpc0I-yme3m2p2XauXM/s1600/phpmyadmin.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHvcXTmJzQiB0pwkVRgQsA7KHgyyn8koUTrGZaMrAX7qR_mZEbzY5MRPlWAXak5-Fm7dAIhlMZW7g48v1o8go4rfJlRxm_B-v55xp-0TA4Ue4Jii6rodYTasPsvUpc0I-yme3m2p2XauXM/s320/phpmyadmin.png" width="273" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
You can log in using "root" and your MySQL root password or with "phpmyadmin" and application specific password.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-80569111035568720822012-09-19T12:21:00.002-07:002012-10-02T11:58:16.739-07:00Generate .ppk out of .pem using PuTTYgen<div dir="ltr" style="text-align: left;" trbidi="on">
First you must download <span style="background-color: white;">PuTTYgen, y</span><span style="background-color: white;">ou can download it from </span><a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">here</a><span style="background-color: white;">.</span><br />
<span style="background-color: white;"><br /></span>
<span style="background-color: white;"><span style="background-color: white;">Open PuTTYgen and select </span>Load</span><br />
<div style="text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisdx9BC2j_K_FZYn7HiRrLM_2Db8k7aOCjsQyIhInUqMCy7nBqu74vReimRBuIEfF7-2wkyNcwE7lH-5jt3sHOcLU6XR9NXMrc2AGc5TSRNnKTMi-yK_aCSOOiPjo2QrwcoLj9oAAT3S9a/s1600/puttygen.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="1" height="304" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisdx9BC2j_K_FZYn7HiRrLM_2Db8k7aOCjsQyIhInUqMCy7nBqu74vReimRBuIEfF7-2wkyNcwE7lH-5jt3sHOcLU6XR9NXMrc2AGc5TSRNnKTMi-yK_aCSOOiPjo2QrwcoLj9oAAT3S9a/s320/puttygen.PNG" width="320" /></a></div>
<div style="text-align: left;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
Note that you must select <b>All Files (*.*)</b> from filter or you cannot locate the file. Click Open </div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0lZ_95VQklzAk8-Jzi-FQVl0SPBaGuTNy8t-NkqwHGLJiKIKISYc96lgjrYMsYEMCkNJBqXxSFbUS-Amh0p8LgqKjUU4N3nqZCq-YMJRZV9DzBu4TV2Mmxuv_5ZgYp9yFjieZVT-wmJcA/s1600/all_files.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="1" height="196" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0lZ_95VQklzAk8-Jzi-FQVl0SPBaGuTNy8t-NkqwHGLJiKIKISYc96lgjrYMsYEMCkNJBqXxSFbUS-Amh0p8LgqKjUU4N3nqZCq-YMJRZV9DzBu4TV2Mmxuv_5ZgYp9yFjieZVT-wmJcA/s320/all_files.PNG" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Next up "Save private key" should no longer be greyed out, click it and name your .ppk file.
<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiODXhbK6VLWdjM2_Ofsj1cRXPuTU8zluKxJNglhCpkOkp9sRqHATbjRDIZY8Xftu5OIhYiiXacgD2azwRqJ2oTvudNHEs-yYrgv34n8zUoznbGFpPhrJIKgnFOs008PCz4yMFpIa7Peah/s1600/myppk.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiODXhbK6VLWdjM2_Ofsj1cRXPuTU8zluKxJNglhCpkOkp9sRqHATbjRDIZY8Xftu5OIhYiiXacgD2azwRqJ2oTvudNHEs-yYrgv34n8zUoznbGFpPhrJIKgnFOs008PCz4yMFpIa7Peah/s1600/myppk.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-size: small; text-align: left;">And you are done!</span>
</td></tr>
</tbody></table>
<br />
<span style="background-color: white;"><b><br /></b></span>
<br />
<br /></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-76900332546841650292012-09-14T07:13:00.000-07:002013-01-20T00:47:19.085-08:00Linux: Using FTP in bash<div dir="ltr" style="text-align: left;" trbidi="on">
Default FTP client in Linux is simply called "ftp", it covers mostly all the basic needs and its easy to use.<br />
<br />
<b>Using FTP in command line</b><br />
<br />
Lets pretend that i have file called data.dat that i need to upload to ftpserver.net. First we start FTP by simply typing in "<b>ftp</b>".<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@srv:~$ <b>ftp</b>
ftp> <b>o ftpserver.net</b>
Connected to ftpserver.net.
220 ProFTPD 1.3.4b Server ready.
Name (ftpserver.net:m): <b>myusername</b>
331 Password required for myusername
Password:
230 User myusername logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
</code></pre>
<br />
So first of all we connect with command "<b>o</b>", followed by the server address, if connection is successful server will prompt you for username and password.<br />
<br />
After server lets you in, you can list directories by doing "<b>dir</b>" or "<b>ls</b>"<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ftp> <b>ls</b>
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwx--x--- 9 ftp ftp 4096 Sep 14 11:45 .
drwx--x--- 9 ftp ftp 4096 Sep 14 11:45 ..
drwx--x--x 4 ftp ftp 4096 Sep 3 20:00 .appdata
-rw-r--r-- 1 ftp ftp 220 May 12 2008 .bash_logout
-rw-r--r-- 1 ftp ftp 3116 May 12 2008 .bashrc
-rw------- 1 ftp ftp 89 Sep 13 22:12 .clipboard.txt
-rw-r--r-- 1 ftp ftp 675 May 12 2008 .profile
-rw-r----- 1 ftp ftp 34 Jun 5 2009 .shadow
drwxrwx--x 2 ftp ftp 4096 Sep 14 07:21 .spamassassin
drwx------ 2 ftp ftp 4096 Sep 3 20:01 application_backups
drwxr-xr-x 2 ftp ftp 4096 Apr 21 2011 backups
drwx--x--x 3 ftp ftp 4096 Jun 5 2009 domains
drwxrwx--- 3 ftp ftp 4096 Jun 5 2009 imap
drwxr-xr-x 2 ftp ftp 4096 Sep 14 11:45 upload
226 Transfer complete
ftp>
</code></pre>
<br />
Now we can proceed and upload file, there is a folder called upload so I'm going to use that one. You can create directories with "<b>mkdir</b>".<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ftp> <b>cd upload</b>
250 CWD command successful
ftp> <b>put /home/m/data.dat data.dat</b>
local: /home/m/data.dat remote: data.dat
200 PORT command successful
150 Opening BINARY mode data connection for data.dat
226 Transfer complete
ftp> <b>ls</b>
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwxr-xr-x 2 ftp ftp 4096 Sep 14 11:50 .
drwx--x--- 9 ftp ftp 4096 Sep 14 11:45 ..
-rw-r--r-- 1 ftp ftp 0 Sep 14 11:50 data.dat
226 Transfer complete
ftp>
</code></pre>
<div>
<br /></div>
<div>
With "<b>put</b>" command we first specify local location of the file, following that only the file name, since we are already in a correct folder. We could also use absolute paths here, like this: "<b>/upload/data.dat</b>". We verified that our file is indeed in upload folder with "<b>ls</b>".<br />
<br />
Note: You can delete files with command "<b>del</b>" and remove directories with "<b>rm</b>".<br />
<br />
Now we can exit<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ftp> <b>exit</b>
221 Goodbye.
</code></pre>
<br />
Polite FTP server will tell you Goodbye!</div>
<br />
<b>Upload file using NcFTP</b><br />
<br />
I personally wanted to have a ftp program that can upload a file in a single command, i couldn't do this with ftp so i needed to look for alternatives.<br />
<br />
Client called <a href="http://en.wikipedia.org/wiki/NcFTP">NcFTP</a> can do this. This doesn't come as a default so you need to install it.<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@srv:~$ sudo apt-get install ncftp
</code></pre>
<br />
With ncftp, you get a program called ncftpput. If i would want to upload same file as above with single line command it would look something like this:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@srv:~$ ncftpput -u myusername -p mypassword ftpserver.net /upload /home/m/data.dat
/home/m/data.dat: 183.41 kB 208.00 kB/s
m@srv:~$
</code></pre>
<br />
Here you first specify remote folder and after that local file location, exact opposite to ftp's put.<br />
<br />
Very handy for scripting!<br />
<div>
<br /></div>
<br />
<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-61721292350727857572012-09-13T04:06:00.002-07:002012-09-13T04:06:46.414-07:00Send commands to Linux screen<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://en.wikipedia.org/wiki/GNU_Screen">GNU Screen</a> is very powerful piece of software that lets you multiplex virtual consoles. I personally use it for running jobs & servers on background. I also use <a href="http://en.wikipedia.org/wiki/Irssi">irssi</a> trough screen.<br />
<br />
<b>Name your screens!</b><br />
<br />
When you run stuff at screen its recommended to set name for that session using -S switch.<br />
<br />
For example with irssi i would specify irssi also as session name.<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@srv:~$ screen -S irssi irssi
m@srv:~$ screen -list
There are screens on:
16425.irssi (09/13/2012 01:28:36 PM) (Detached)
16323.mc (09/13/2012 01:24:43 PM) (Detached)
2 Sockets in /var/run/screen/S-m.
</code></pre>
<br />
ID in front of your session name is PID of virtual screen console.<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@srv:~$ ps -A | grep 16425
16425 ? 00:00:00 screen
</code></pre>
<div>
<br /></div>
<div>
As you can see there is now two screens running, irssi and mc (mc is my minecraft server :-)). Why I'm telling this is simply because this way its bit easier to track what is running in your screen. Its not mandatory.</div>
<div>
<br /></div>
<div>
You can resume this sessions now with name, for example</div>
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> screen -r irssi
</code></pre>
<div>
<br /></div>
<div>
If you are new to screen here is a good tip for you, you can detach from screen by doing ctrl+a+d</div>
<div>
<br /></div>
<b>How to send commands to screen?</b><br />
<br />
Especially with Minecraft server its handy to communicate with your server without attaching your screen session. For automation this is good, you can do daily backups, restart your server and before all that, you can alert your users!<br />
<br />
This doesn't work if your screen is password protected.<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> screen -S mc -X stuff 'say Server going down for maintenance in 20 seconds'$'\012'
</code></pre>
<br />
First you specify session with <b>-S</b>, then you need to do <b>-X stuff '<message here>'</b><br />
<br />
<b id="internal-source-marker_0.35801973403431475"><span style="font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">"stuff"<span style="font-weight: normal;"> needs to be there because.. you are sending stuff to it. Sorry i couldn't find any details about this.</span></span></b><br />
<b style="font-weight: normal;"><span style="font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;"><br /></span></b>
<b><span style="font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">\012 <span style="font-weight: normal;">is a newline character, if you don't pass this, screen will input your message but wont "press enter" for you, so your message will remain in the console input screen.</span></span></b><br />
<b style="font-weight: normal;"><span style="font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;"><br /></span></b>
<b style="font-weight: normal;"><span style="font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;"><br /></span></b>
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUiXD7vGipOAbzEPNzQuoYFCtmcni8Jqkg8mEjAClVe_3PvtZZZUEmt-eaV41UiAW_8UEGk6wpphCSGLOruAYLaLyCaQKdM5GF2__lEXa7nkFFbdItbxd6jLfqqTUIDQrYREE__Z4u1NnC/s1600/maintenance.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="77" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUiXD7vGipOAbzEPNzQuoYFCtmcni8Jqkg8mEjAClVe_3PvtZZZUEmt-eaV41UiAW_8UEGk6wpphCSGLOruAYLaLyCaQKdM5GF2__lEXa7nkFFbdItbxd6jLfqqTUIDQrYREE__Z4u1NnC/s400/maintenance.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">OMG! Server going down</td></tr>
</tbody></table>
<b style="font-weight: normal;"><span style="font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;"><br /></span></b>
<br />
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-6700800576218293856.post-49819081160201852382012-09-13T01:52:00.000-07:002012-09-13T06:20:33.614-07:00Replicate linux data using rsync<div dir="ltr" style="text-align: left;" trbidi="on">
I¨ve always had multiple Linux boxes at my disposal, usually they are just old laptops or desktop that i have planned to use for something but never had time to do anything useful with them, so i have them just lying around.<br />
<div>
<br /></div>
<div>
They never had any kind of raid or redundancy and my data has been "kept save" just by holy spirit :-)<br />
<br />
Easy way to sleep without worrying is to replicate your data between servers. Easy way to achieve this is by using rsync and cron. In this example we don't use rsync protocol but we are using SSH connection for the transfer.<br />
<br />
First you should create SSH keys to your server to make them access each other without need to enter credentials.<br />
<br />
In this example i will create rsync from my home server to external server, in this case i have only 1 account for both servers that i will be using.</div>
<div>
<br />
<b>1. Create SSH Keys</b><br />
<br />
Im using ubuntu servers so first i need to edit file /etc/ssh/sshd_config and uncomment one line<br />
<br />
#AuthorizedKeysFile %h/.ssh/authorized_keys<br />
(remove # from the start)<br />
<br />
Then i will login to my home server and create SSH key with command <b>ssh-keygen -t rsa</b><br />
<br />
I didn't use any passphrase<br />
<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@homeserver:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/m/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/m/.ssh/id_rsa.
Your public key has been saved in /home/m/.ssh/id_rsa.pub.
</code></pre>
<br />
<br />
Now we need to open this public key in /home/profile/.ssh/ that we just created, and copy paste all of its contents to external server.<br />
<br />
login to external server<br />
Authorized keys will be stored at file "authorized_keys" in /home/profile/.ssh<br />
<br />
File didn't exist so i had to create it<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@external:~/.ssh$ touch authorized_keys
</code></pre>
<i><br /></i>
Open file with your favourite editor and paste contents of your public key into it + save.<br />
<br />
We should be all done, time to test<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> m@homeserver:~/.ssh$ ssh m@extserver
</code></pre>
<br />
Works! (at least for me), no password prompted, yippee.<br />
<br />
<b>2. rsync</b><br />
<b><br /></b>
I want to keep contents between my servers always identical, so i will use following rsync command:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> rsync -avz --delete /home/m/samba m@external:/home/m/backup/
</code></pre>
<i><br /></i>
-a is for archive mode, its very good for backups it will preserve when file was modified and who is the owner and so on<br />
<br />
-v is for verbose, so you will get some output about transfer itself<br />
<br />
-z is for compress, will save some bandwidth<br />
<br />
--delete will remove files on extserver that don't exist on sender, in my case homeserver<br />
<br />
If you need to specify alternate port for your connection, add <i>--rsh='ssh -p1234'</i> modify 1234 to your port<br />
<br />
<b>3. Cronjob</b><br />
<b><br /></b>
Now we create cron in order to make this rsync run automatically. I want to replicate all changes once per day, there might be some huge changes in my samba directory so i want to give some time for this process. 24 hours should be enough..<br />
<br />
Access crontab with:<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> crontab -e
</code></pre>
<i><br /></i>
In my case this will be easy, there is some predefined scheduling definitions that will work for me.<br />
@daily will run job everyday at midnight. Please see more at <a href="http://en.wikipedia.org/wiki/Cron">Cron wiki page</a><br />
<br />
So my crontab looks like this:<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> @daily rsync -avz --delete /home/m/samba m@external:/home/m/backup/
</code></pre>
<br />
<b>Some final words</b><br />
<br />
Actually this is kind of bad backup, since one human error may compromise all of my data. So if i delete a very important file.txt from my samba share, rsync will destroy it from external server also.<br />
<br />
There are many ways to overcome this, for example you could zip backup folder everyday for last x days, in my case this is not possible since i don't have enough disk space :-(<br />
<br />
Anyway, be careful !<br />
<br />
<br /></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6700800576218293856.post-75498438168771034342012-09-12T14:09:00.000-07:002012-10-01T11:55:20.496-07:00Experimenting with Python subprocess Popen<div dir="ltr" style="text-align: left;" trbidi="on">
Process control and management with Python is pure greatness. Parallel tasks can be easily launched and monitored, output can be captured and used later on if needed.<br />
<br />
You can communicate with your processes by sending data to stdin. You can also send in signals and all processes will give you return code after their execution.<br />
<br />
Official subprocess documentation can be found <a href="http://docs.python.org/library/subprocess.html">here</a><br />
<br />
I made small script to demonstrate subprocess.Popen<br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWfurQyTQYoB_xk7a2VBLWB0gaANlqmkiiFYdBmAkJXEtggsQ-cpHaEjAQrBQeVLUZPvdHZrIGw6cAeOKtqTQqcpQ4sjepnjQy-drw4OQwSP1wEuAuxONh1QmQGlrYfBKrXO-BQQf_DbdL/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> import random
import subprocess
import time
# Amount of spawned processes
amount = 10
# Process time
min = 5
max = 20
print " "
print "Subprocess example starting"
print "....................................."
time.sleep(1)
print " "
print "Spawning " + str(amount) + " processes"
# Store subprocesses in this array
process_list=[]
# Spawn all processes
for i in range (1, amount + 1):
timer = random.randint(min, max)
sp = subprocess.Popen("sleep " + str(timer), shell=True)
print "Spawning process nro " + str(i) + " | PID: " + str(sp.pid) + " | Timer set to: " + str(timer)
process_list.append(sp)
print "All processes spawned"
print " "
print "Waiting.."
print " "
time.sleep(5)
# Loop for processes, wait for completion
stop = 0
while stop != 1:
for sp in process_list:
sp.poll()
if str(sp.returncode) != "None":
print "Process (PID: " + str(sp.pid) + ") finished working! returncode: " + str(sp.returncode)
process_list.remove(sp)
time.sleep(0.1)
if len(process_list) <= 0:
stop = 1
print " "
print "....................................."
print "All subprocesses completed!"
</code></pre>
<br />
In this example script, first loop spawns 10 shells that will execute sleep timer randomly between 5 and 20 seconds. Second loop will just wait until every process has finished. poll() will set return code for process so it must be done once in a loop, so my application will notice finished processes.<br />
<br />
Its handy to store your processes in a list!<br />
<br />
Like in this case, if shell argument is set to true in Popen() .pid() (process ID) will belong to spawned shell. Alternatively you could do this:<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> sp = subprocess.Popen(["./sleep_subprocess.sh", str(timer)])
</code></pre>
<br />
Here is the output:<br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWfurQyTQYoB_xk7a2VBLWB0gaANlqmkiiFYdBmAkJXEtggsQ-cpHaEjAQrBQeVLUZPvdHZrIGw6cAeOKtqTQqcpQ4sjepnjQy-drw4OQwSP1wEuAuxONh1QmQGlrYfBKrXO-BQQf_DbdL/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Subprocess engine starting
.....................................
Spawning 10 processes
Spawning process nro 1 | PID: 14644 | Timer set to: 19
Spawning process nro 2 | PID: 14645 | Timer set to: 5
Spawning process nro 3 | PID: 14647 | Timer set to: 10
Spawning process nro 4 | PID: 14649 | Timer set to: 12
Spawning process nro 5 | PID: 14651 | Timer set to: 6
Spawning process nro 6 | PID: 14653 | Timer set to: 17
Spawning process nro 7 | PID: 14655 | Timer set to: 7
Spawning process nro 8 | PID: 14657 | Timer set to: 17
Spawning process nro 9 | PID: 14659 | Timer set to: 19
Spawning process nro 10 | PID: 14661 | Timer set to: 17
All processes spawned
Waiting..
Process (PID: 14645) finished working! returncode: 0
Process (PID: 14651) finished working! returncode: 0
Process (PID: 14655) finished working! returncode: 0
Process (PID: 14647) finished working! returncode: 0
Process (PID: 14649) finished working! returncode: 0
Process (PID: 14653) finished working! returncode: 0
Process (PID: 14661) finished working! returncode: 0
Process (PID: 14657) finished working! returncode: 0
Process (PID: 14644) finished working! returncode: 0
Process (PID: 14659) finished working! returncode: 0
.....................................
All subprocesses completed!
</code></pre>
<br />
If your process stays too long you can terminate it with .terminate() or if its stuck you can .kill() it!<br />
<br /></div>
Unknownnoreply@blogger.com0