Saturday, September 24, 2011

// // Leave a Comment

Searching for files/text using SSH

In some cases you would need to find the location of a given file or to search for a certain text in all files under a directory. SSH provides two different commands, which can be used to accomplish this.

In order to search for a file location you can use the find command. Find is a very powerful tool and accepts various arguments allowing you to specify the exact search term (i.e search by name, by type or even by modified time).
For example, to search for a file called myFile.txt under the current folder (and all subfolders), you would need to use the following command:
find . -name myFile.txt
If you are uncertain about the file name or would like to match a part of the name, you can use a wildcard pattern:
find . -name “myFile*”
If you would like to list only directories and leave all files out of the result:
find . -type d
Or if you want to filter only files modified for the last 2 days, you would need to use:
find . -mtime -2

You can also search for a given text in the files content as well. The command you should be using in this case is ‘grep’ . Grep is a very powerful tool and accepts various command line arguments. For a full list it is recommended to check the manual pages by typing ‘man grep’.
An example of using grep to find a certain text can be found below:
grep  “database” configuration.php
The above command instructs grep to look for the string “database” in configuration.php file and display the containing line.  If you don’t know which file contains the text, you can use:
grep -r -H “database” *
This will make grep look recursively (-r option) and provide the result in human readable format (-H option) for the string “database” in all (*) files under the current working directory.
To only list the file names containing the string you are searching but omit the line containing it, you can use the -l argument:
grep -l “database” *
This will display the filenames containing the word database, but will not actually list the line containing it.
Grep can also be used to filter the results from other commands. For example, the line below will only output configuration.php result:
ls -la | grep configuration.php
In some rare cases, you would not like to use find or grep. For example, to find a certain file in the whole server, it would be best to use an alternative command -- whereis or which:
whereis perl
which perl
The execution of the above commands will locate the perl binary and display the full path(s) to it.
Read More
// // Leave a Comment

Move and copy files using SSH

Often you will need to move one or more files/folders or copy them to a different location. You can do so easily using an SSH connection. The commands which you would need to use are mv (short from move) and cp (short from copy).
The mv command syntax looks like this:
mv configuration.php-dist configuration.php
By issuing the above command we will move (rename) the file configuration.php-dist to configuration.php. 
You can also use mv to move a whole directory and its content:
mv includes/* ./
This will move all files (and folders) in the includes/ directory to the current working directory.
In some cases however, we will need to only update the files and move only files that were changed, which we can do by passing ‘-u’ as argument to the command:
mv -u includes/* admin/includes
The copy (cp) command works the same way as mv, but instead of moving the files/folders it copies them. For example:
cp configuration.php-dist configuration.php
The command will copy the configuration.php-dist file to configuration.php and will preserve the original file (the file will NOT be removed after it is copied).
cp also accepts various arguments:
cp -R includes/ includes_backup/
-R instructs cp to copy files recursively (for example, a whole directory). To overwrite already existing files you should use the -f argument:
cp -Rf includes/ admin/includes/

A more convenient way to copy files/folders is to use a 3rd party application, such as Midnight Commander. All our servers have mc (midnight commander) installed and it is available by executing the appropriate (mc) command using the command prompt.  Once inside the application you will see two sections - left and right. You can easily copy/move files from the left side directory to the right side using a semi-visual approach. You can even use your mouse to select files and function keys to execute commands.
You can see a picture of it below:
Midnight commander

 As you can see on the screenshot, there are numbers from 1 to 10 at the bottom of the console screen. These represents shortcuts to certain commands and are activated using the corresponding function key (i.e F1 for help, F5 to copy, etc).
Read More
// // Leave a Comment

How To Recover root password under linux with single user mode

It happens sometime that you can't remember root password. On Linux, recovering root password can be done by booting Linux under a specific mode: single user mode.
This tutorial will show how to boot Linux in single user mode when using GRUB and finally how to change root password.
During normal usage, a Linux OS runs under runlevels between 2 and 5 which corresponds to various multi-user modes. Booting Linux under runlevel 1 will allow one to enter into a specific mode, single user mode. Under such a level, you directly get a root prompt. From there, changing root password is a piece of cake.

1. Entering runlevel 1

Some Linux distribution, such as Ubuntu for instance, offer a specific boot menu entry where it is stated "Recovery Mode" or "Single-User Mode". If this is your case, selecting this menu entry will boot your machine into single user mode, you can carry on with the next part. If not, you might want to read this part.
Using GRUB, you can manually edit the proposed menu entry at boot time. To do so, when GRUB is presenting the menu list (you might need to press ESC first), follow those instructions:
  • use the arrows to select the boot entry you want to modify.
  • press e to edit the entry
  • use the arrows to go to kernel line
  • press e to edit this entry
  • at the end of the line add the word single
  • press ESC to go back to the parent menu
  • press b to boot this kernel
The kernel should be booting as usual (except for the graphical splash screen you might be used to), and you will finally get a root prompt (sh#).
Here we are, we have gained root access to the filesystem, let's finally change the password.

2. Changing root password

As root, changing password does not ask for your old password, therefore running the command:
# passwd
will prompt you for your new password and will ask you to confirm it to make sure there is no typo.
That's it, you can now reboot your box and gain root access again
Read More
// // Leave a Comment

How to edit a file via ssh

To edit a file via ssh we have the following editors: 

  • nano / pico
  • vim
  • vi
  • touch

Suppose we want to edit a file /home/w3tools/index.html using vim editor.

To edit this file use the following steps:

        1. Log in to server via ssh using any client (recommended: Putty)

        2. Run the following commands.
vim /home/w3tools/index.html
        3. Now the file index.html will be opened. To edit the file press i. Now make changes in the file.
        4. To save the file Press Esc then wq .

Your file will be updated successfully.
If index.html doesn't  exist it will be created automatically.

Note: To exit file editor without saving the file press Esc then q.

Read More
// // Leave a Comment

How to change root password via ssh.

To change the root password via ssh, use the following steps:

1. Log in to ssh by using any client(recommended: Putty).

2. Run these commands after it
su - root
3. Enter your new password for root. Confirm your password by re-entering it.


Read More
// // Leave a Comment

PHP - lame encoder mp3 conversion

Uses PHP - lame to change ID3 tags and convert bitrate of a mp3 file.

You can change album,artist,trackno,genre,year,comment,artist,art and bitrate.

Link to lame encoder : Click here

Enjoy guys !

Source: TechnosLab
Read More
// // Leave a Comment

How to add tags/labels to bloggers posts via Gdata api

Read More
// // Leave a Comment

HTTP authentication via PHP

Here's a small snippet that let's you implement htaccess style http authentication in your PHP scripts. Just define user and password and you are ready to go !

Go Here To download the code:

Make sure that this code block is present in topmost of your scripts or it'll give errors and authentication will be messed up.
Read More
// // Leave a Comment

Bypass download timer is a great tool for fetching torrents and downloading them over http through our favorite download manager. From last week, they have imposed a timer on download page that limits us from downloading a fetched torrent instantly. Now we can either pay them to gain premium access to their services or we can find a work around. While I suggest you to go for premium membership, I also give you a work around.

On the page where you are asked to wait for the download to begin, just put this in the browser's address bar and hit enter.


and you would get the download link(s) immediately. Please note that Google chrome doesn't support javascript execution in address bar so it would not work for chrome users. 
Source: TechnosLab
Read More
// // Leave a Comment

How to Change The Default SSH Port.

To force or change the default SSH to run on a non standard port, use the following steps: 

1. Open /etc/ssh/sshd_config in your favorite text editor:

2. Look for the below lines: 

# Port 22

3. Uncomment and edit this line to change the default port.
For example you can set it to:

Port 99

4. Save the file, and restart the SSH.

/etc/init.d/ssh restart

NOTE: Removing the # will uncomment and you will need to remove this for any change in the port.
Read More
// // Leave a Comment

How to force remove a dead node from solusvm.

This command will help you in removing a dead node from solusvm master. Since the node is dead therefore we cannot remove it using the available option in the master.
Login to SSH in the master server and run below command.

php /usr/local/solusvm/scripts/deletenode.php --level=force --comm=delete --id=

The node id can be found in the VPS Control Panel. Click on node list and note down the ID of the node you want to remove.

Example: Suppose you want to remove a node having ID = 5

Then the command will be like:

php /usr/local/solusvm/scripts/deletenode.php --level=force --comm=delete --id=5

Similarly you can force remove any node from the solusVM master. This will only remove the NODE from master and will not remove any physical VPS inside that node.
Read More
// // Leave a Comment

How to change a forgotten MySQL root password from SSH.

To change the MySQL root password, run the below commands as root:
/etc/init.d/mysql stop
killall -9 mysql 
/etc/init.d/mysql --skip-grant-tables --user=root start

Connect to mysql with the following command:
mysql -u root

Execute the below command in the mysql client: 
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';

The 'newpwd' will be the new password for the MySQL.
Read More
// // Leave a Comment

What does serial, refresh, retry, expire, minimum and TTL mean?

Details of SOA parameters used in DNS records:

Serial — The zone serial number, incremented when the zone file is modified, so the slave and secondary name servers know when the zone has been changed and should be reloaded. 

Refresh — This is the number of seconds between update requests from secondary and slave name servers. 

Retry — This is the number of seconds the secondary or slave will wait before retrying when the last attempt has failed. 

Expire — This is the number of seconds a master or slave will wait before considering the data stale if it cannot reach the primary name server. 

Minimum — Previously used to determine the minimum TTL, this is used for negative caching. This is the default TTL if the domain does not specify a TTL.

TTL (time to live) - The number of seconds a domain name is cached locally before expiration and return to authoritative nameservers for updated information.

Read More

Friday, September 23, 2011

// // Leave a Comment

Speed Up Your Javascript Load Time

Javascript is becoming increasingly popular on websites, from loading dynamic data via AJAX to adding special effects to your page.

Unfortunately, these features come at a price: you must often rely on heavy Javascript libraries that can add dozens or even hundreds of kilobytes to your page.

Users hate waiting, so here are a few techniques you can use to trim down your sites.

Find The Flab

Like any optimization technique, it helps to measure and figure out what parts are taking the longest. You might find that your images and HTML outweigh your scripts. Here’s a few ways to investigate:

1. The Firefox web-developer toolbar lets you see a breakdown of file sizes for a page (Right Click > Web Developer > Information > View Document Size). Look at the breakdown and see what is eating the majority if your bandwidth, and which files:

2. The Firebug Plugin also shows a breakdown of files – just go to the “Net” tab. You can also filter by file type:

3. OctaGate SiteTimer gives a clean, online chart of how long each file takes to download:

Disgusted by the bloat? Decided your javascript needs to go? Let’s do it.

Compress Your Javascript

First, you can try to make the javascript file smaller itself. There are lots of utilities to “crunch” your files by removing whitespace and comments.

You can do this, but these tools can be finnicky and may make unwanted changes if your code isn’t formatted properly. Here’s what you can do:

1. Run JSLint (online or downloadable version) to analyze your code and make sure it is well-formatted.

2. Use Rhino to compress your javascript. There are some online packers, but Rhino actually analyzes your source code so it has a low chance of changing it as it compresses, and it is scriptable.

Install Rhino (it requires Java), then run it from the command-line:
java -jar custom_rhino.jar -c myfile.js > myfile.js.packed 2>&1

This compresses myfile.js and spits it out into myfile.js.packed. Rhino will remove spaces, comments and shorten variable names where appropriate. The “2>&1″ part means “redirect standard error to the same location as the output”, so you’ll see any error messages inside the packed file itself (cool, eh? Learn more here.).

Using Rhino, I pack the original javascript and deploy the packed version to my website.

Debugging Compressed Javascript

Debugging compressed Javascript can be really difficult because the variables are renamed. I suggest creating a “debug” version of your page that references the original files. Once you test it and get the page working, pack it, test the packed version, and then deploy.

If you have a unit testing framework like jsunit, it shouldn’t be hard to test the packed version.

Eliminating Tedium

Because typing these commands over and over can be tedious, you’ll probably want to create a script to run the packing commands. This .bat file will compress every .js file and create .js.packed:
for /F %%F in ('dir /b *.js') do java -jar custom_rhino.jar -c %%F > %%F.packed 2>&1
Read More
// // Leave a Comment

How To Optimize Your Site With GZIP Compression

Compression is a simple, effective way to save bandwidth and speed up your site. I hesitated when recommending gzip compression when speeding up your javascript because of problems in older browsers.

But it's the 21st century. Most of my traffic comes from modern browsers, and quite frankly, most of my users are fairly tech-savvy. I don't want to slow everyone else down because somebody is chugging along on IE 4.0 on Windows 95. Google and Yahoo use gzip compression. A modern browser is needed to enjoy modern web content and modern web speed -- so gzip encoding it is. Here's how to set it up.

Setting up the server

The "good news" is that we can't control the browser. It either sends the Accept-encoding: gzip, deflate header or it doesn't.

Our job is to configure the server so it returns zipped content if the browser can handle it, saving bandwidth for everyone (and giving us a happy user).

For IIS, enable compression in the settings.

In Apache, enabling output compression is fairly straightforward. Add the following to your .htaccess file:
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:

SetOutputFilter DEFLATE

Apache actually has two compression options:

mod_deflate is easier to set up and is standard.
mod_gzip seems more powerful: you can pre-compress content.

Deflate is quick and works, so I use it; use mod_gzip if that floats your boat. In either case, Apache checks if the browser sent the "Accept-encoding" header and returns the compressed or regular version of the file. However, some older browsers may have trouble (more below) and there are special directives you can add to correct this.

If you can't change your .htaccess file, you can use PHP to return compressed content. Give your HTML file a .php extension and add this code to the top:


We check the "Accept-encoding" header and return a gzipped version of the file (otherwise the regular version). This is almost like building your own webserver (what fun!). But really, try to use Apache to compress your output if you can help it. You don't want to monkey with your files.

Verify Your Compression

Once you've configured your server, check to make sure you're actually serving up compressed content.

View the headers: Use Live HTTP Headers to examine the response. Look for a line that says "Content-encoding: gzip".


As exciting as it may appear, HTTP Compression isn't all fun and games. Here's what to watch out for:

Older browsers: Yes, some browsers still may have trouble with compressed content (they say they can accept it, but really they can't). If your site absolutely must work with Netscape 1.0 on Windows 95, you may not want to use HTTP Compression. Apache mod_deflate has some rules to avoid compression for older browsers.
Already-compressed content: Most images, music and videos are already compressed. Don't waste time compressing them again. In fact, you probably only need to compress the "big 3" (HTML, CSS and Javascript).
CPU-load: Compressing content on-the-fly uses CPU time and saves bandwidth. Usually this is a great tradeoff given the speed of compression. There are ways to pre-compress static content and send over the compressed versions. This requires more configuration; even if it's not possible, compressing output may still be a net win. Using CPU cycles for a faster user experience is well worth it, given the short attention spans on the web.

Enabling compression is one of the fastest ways to improve your site's performance. Go forth, set it up, and let your users enjoy the benefits.
Read More

Thursday, September 22, 2011

// // Leave a Comment

All about facebook passwords

So far, you must have been thinking that just like other websites, you have a single password on facebook. Well it's quite shocking to know that you actually have three facebook passwords and not just one. In fact everybody on facebook has three passwords that they can use to log in. Surprised ? So was I but you need not worry.

The passwords are not a security issue or a bug. Developers at facebook have intentionally done so to make our lives easier. Let me make it clearer through an example. Assume that your facebook password is abCDef, then other two valid passwords for your account are Abcdef and ABcdEF. The explanation for three passwords is quite simple.

abCDef is your actual password.
Abcdef is your password in capitalized format. ( Useful for logging from a mobile device ).
ABcdEF is your password with it's case reversed. ( Useful for logging with Caps Lock on ).

See how much facebook developers care for us ? If you haven't already tried this, try logging in with the other two passwords and share your experiences.

Source: TechnosLab
Read More
// // Leave a Comment

Google+ Social Networking Website – Login

The leading search engine and generalised name as a father of internet has came in booming market of social networking along with its never stopping and unmatchable service as Google Plus, which is also writes as Google+ or G+. Official URL is It’s just going to be proved as new Social Networking Site from Google. This deafening provision of social networking by Google has almost made community to wait for their sweet grapes like taste of services. This phenomenon will make the people nigh mostly which would make the world smaller.

Google Plus LogoFull spices features are made integrated to make feeling of great sociality which will make this one of the best social network. Cool features are concerned, the wall for the posting of messages purpose is provided with Google Plus along with users can change their status and comment on others’ too. Term is also embedded that makes users to add their friends in private hangout circle.

Users would be able to make dissimilar types of circles for family, friends, colleagues etc. Feature is crafted with the facility that enables all of the members to chat with buddies who are present in their Gmail account. Furthermore people can upload their or particular photos, focusing videos, events etc. Will Google+ overtake Facebook, Twitter or other social site is more important question for all experts.

Among more similar featuring services, Google Plus is embedded with some coolest features such as inbuilt Picasa. Now you can upload unlimited photos in Picasa album. Users are made with ability to import their respective contacts from Yahoo and Hotmail but not from Facebook. Parting from this side, the improvement in the serving ability is increased herein with the intention to do all the things right with Gmail, Reader, Docs, or Calendar, here profile user can get best privacy setting.

Google Plus Login Steps

#1. Open page: and hit ‘Sign in’ button
#2. Now write Email and password
#3. Have you faced any problems, visit ‘Can’t access your account?’
#4. Select blue coloured ‘Sing in button’
[If you want to create new account, visit page]

Google Plus Login

Video chat with a group, huddle, get the news not a feed, make circles secret, what strangers are saying and make a best relation with stranger – all these best features that user can’t get from Facebook. Google Plus project team still improved their best ability.

Circles: create round circles that you want with interested friends, relationships, family, etc. Circles will show only those person profiles that you add to do video chat
Stream: latest updates, gossip and information from various added people profile circles. The personalised backing to any post or comment liked is to be mentioned by the +1 criterion
Photos: Tagging and uploading is made like presented never before on G+, making this facility as concrete good looking. Along with the integration of Picasa, service enables members to tag anyone’s picture
Sparks: The provision of Sparks is same as its name implies. It has been crafted just like to be display tape which would be generated automatically based on user request.
Read More
// // Leave a Comment

Google plus is now open to public

After being tested immensely for 90 days, google plus is now ready to make it's transition form an invite only to a public beta. Yes, google plus is now open to all. In a yet another feature update post on official the blog, Vic Gundotra from Google expressed how happy they are to introduce Google plus's 100th feature: open signups. The post also includes updates regarding pre-existing features like hangouts bringing it to the screens of your phones, though only for android 2.3+ devices with a front facing camera, whereas support for iOS devices is expecated soon. It's certainly good to see how hard they are working to make Google plus stand out and heavily transform our online social activities.
Read More