RSS

Category Archives: Linux

A Begginer’s guide to shell scripting

Shell scripts are one of the easiest programming languages to learn. They are a Linux administrators best friend and you can use them to automate tasks like a server backup or even just to email you the IP address of your Raspberry Pi server on boot.

In this post we will see how to write a simple shell script and then proceed to some intermediate shell scripting examples.

Before we start, I recommend you install “VIM”, a file editor, via yum .

Let’s get started with a simple script to tell us the disk usage in the current directory

techarena51.com

 
Leave a comment

Posted by on June 11, 2014 in Centos, Fedora, Linux, Shell Scripting, Ubuntu

 

Tags:

Getting started with GitHub

Git is a version control system used for the up keep of your software. It’s sort of like a back up of your software which you can revert to incase of any errors or incorrect code change I am documenting a few Git commands that can be used with any Linux Distro. Installing Git Read More

 
Leave a comment

Posted by on April 3, 2014 in Linux

 

How to Install Lighttpd with Iredmail

Lately, I have been trying different web servers with the following Goals in Mind.

The response should be fast (as in resolve quick in a 2G network or a score of 90 n above in page speed)

Should be resource friendly, utilize less memory as possible.

With these two Goals in mind I have been experimenting with Nginx and Lighttpd .

Read More

 
Leave a comment

Posted by on May 21, 2013 in IredMail, Linux

 

Tags: ,

Shell scripting Interview questions

Hey Guys n Gals,

I m back after a long time, work work work…..I have started to write small articles help full to others and this one is shell scripting interview questions.

So here goes

This was asked at Capgemini

How will you save the output of the TOP command in a file?

Use  Top in batch mode

# top -b -n1 > filename.txt

The -b option is for batch mode and the -n option is for the number of iterations in this case 1.

You can use the -d to option to to specify the time between two iterations

# top -b -n1 -d10 > filename.txt

The delay is 10 seconds

 
 

Tags: , ,

Wired Network Device not managed Ubuntu 11.04

This is a common problem in Ubuntu 11.04, I tried to connect via a wired cable and was stunned to find that there was no auto Etho 🙂

After Googling for a while, I came across the solution below, hope it helps you guys

Solution is as follows
Step 1. Open the Network manager conf file

sudo gedit /etc/NetworkManager/NetworkManager.conf  

Step 2
Change the below line to true

managed=false

Step 3
Reboot your System

Visit blogadda.com to discover Indian blogs

 
1 Comment

Posted by on October 25, 2011 in Linux, Ubuntu

 

Tags: , , , , ,

How to connect MTNL 3G or any usb data card on Linux

Ok So I Bought a MTNL 3G dongle and was struggling to connect to the 3g network.

Tried everything usb mode switch, installed the software that came along with the client, network manager but no luck.

Finally thanks to manager I got the solution. If you have installed the software that comes with the dongle remove it.

Thats it then try to connect and its works successfully.

The software blocks the port which needs to be connected on and hence I was stuck.

Looking forward to enjoying my unlimited connection.

If the above still does not work then you need to type the code below

 

lsusb

After connecting the datacard type the command above you will get an output as below

Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 003: ID 0a5c:2145 Broadcom Corp. Bluetooth with Enhanced Data Rate II
Bus 004 Device 002: ID 08ff:2810 AuthenTec, Inc. AES2810
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 230d:0003
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Here the number after ID is your Vendor id and your product id respectively. If you are not sure which is yours then remove your datacard run lsusb copy the output and then compare it with the output you got with datacard.

After you have got that, you will need to install usb_modeswitch as follows


sudo apt-get install usb-modeswitch

Once done type the following command


sudo usb_modeswitch -v 230d -p 0003 -u 3

Where -v and -p we got from lsubs earlier.

and thats it you can either connect it from Network manager or with wvdial


sudo wvdialconf
sudo wvdial

You need to edit /etc/wvdialconf with your apn, username and password.

Click here for MTNL 3g tariffs

 
2 Comments

Posted by on September 28, 2011 in Linux, Ubuntu

 

Tags:

PHP search using PostgreSQL

A simple search form to search  the db and display the contents via PHP and PostgreSQL

Name the below as index.html

 

<h2>Search</h2>
<form name=”search” method=”post” action=”search.php”>
Seach for: <input type=”text” name=”find” /> in
<Select NAME=”field”>
<Option VALUE=”emailaddress”>emailaddress</option>
<Option VALUE=”domainname”>domainname</option>
</Select>
<input type=”hidden” name=”searching” value=”yes” />
<input type=”submit” name=”search” value=”Search” />
</form>

Name the below as search.php

 

 

<?

$searching = $_POST[‘searching’];
$find = $_POST[‘find’];
$field = $_POST[‘field’];

//This is only displayed if they have submitted the form

if ($searching ==”yes”)
{
echo “<h2>Results</h2><p>”;

//If they did not enter a search term we give them an error
if ($find == “”)
{
echo “<p>You forgot to enter a search term”;
exit;
}

// We preform a bit of filtering
//$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);

// attempt a connection
// $dbh = pg_connect(“host=hostname port=5432 dbname=dbname  user= username password=password”);
//if (!$dbh) {
//  die(“Error in connection: ” . pg_last_error());
// }
include_once(“connection/connection.php”);

// execute query
$sql = “SELECT * from table where $field = ‘$find’ limit 30 “;

$result = pg_query($dbh, $sql);
if (!$result) {
die(“Error in SQL query: ” . pg_last_error());
}

echo “<table border=’1′>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email address</th>
</tr>”;

while ($row = pg_fetch_array($result)) {

echo “<tr>”;
echo “<td> ” . $row[0] . “</td>”;
echo ” <td>” . $row[1] . “</td>”;
echo “<td> ” . $row[2] . “</td>”;
echo “</tr>”;

}
echo “</table>”;

$rows = pg_num_rows($result);

if ($rows == 0)
{
echo “Sorry, but we can not find an entry to match your query<br><br>”;
}

//And we remind them what they searched for
echo “<b>Searched For:</b> ” .$find;

echo “<b>Number of rows :</b> ” .$rows;

// free memory
pg_free_result($result);

pg_close($dbh);
}
?>

 

 
Leave a comment

Posted by on September 6, 2011 in Centos, Fedora, Hosting, Internet, Linux, Red hat, Ubuntu

 

Tags:

 
%d bloggers like this: