Free Web Hosting

Useful Linux Shell Commands

August 7th, 2008 Bala Krishna Posted in General, Linux, Linux Commands, PHP Programming, PHP Tutorial, Tips and Tricks, Web Technology No Comments »

ls : List files/directories in a current directory, equivalent to dir command in dos/windows.
ls -al : Shows all files and directories with the details attributes for each file.

cd : Change directory
Examples:
cd ~ : Change your directory to your home directory.
cd - : Change to the last directory you were in.

tail : Reads and display the end of the file
Examples:
tail /var/www/me.txt : Display last 20 lines (by default) lines of the given file.
tail -f /var/www/me.txt : Watch the file continuously, while it’s being updated.
tail -400 /var/www/me.txt : Print last 400 lines of the file to the screen.

more : Open file one screen at a time.
Examples:
more /etc/log.txt : Opens the file one screen at a time rather than all at once. Press Space to go to next page.

pico : easy to use file editor
Examples:
pico /home/mysite/public_html/you.html : edit the you.html file from the public_html directory.

vi : popular editor in linux, have lots of features but harder to use
Examples:
vi /home/mysite/public_html/you.html : edit the you.html from the public_html directory.

grep : looks for certain patterns in files
Examples:
grep root /etc/passwd : shows all matches of root in /etc/passwd
grep -v root /etc/passwd : shows all lines that do not match root

touch : create an empty file
Examples:
touch /home/mysite//public_html/new.html : create an empty file called new.html in the directory /home/mysite//public_html/

ln : create’s “links” between files and directories
Examples:
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf : Now you can edit /etc/httpd.conf rather than the original. changes will affect the orginal, however you can delete the link and it will not delete the original.

rm : delete a file
Examples:
rm filename.txt : Deletes filename.txt, It will confirm you before deleting file.
rm -f filename.txt : Deletes filename.txt without confirmation.
rm -rf tmp/ : Recursively deletes the directory tmp, and all files in it, including subdirectories.

last : shows who logged in with the time
Examples:
last -20 : shows only the last 20 logins
last -20 -a : shows last 20 logins, with the hostname in the last field

netstat : shows all current network connections.
netstat -an : shows all connections to the server, the source and destination ips and ports.
netstat -rn : shows routing table for all ips bound to the server.

top : shows useful live system info
processes in a table format, memory information, uptime and other useful info. This is excellent for managing your system processes, resources and ensure everything is working fine and your server isn’t bogged down. top then type Shift + M to sort by memory usage or Shift + P to sort by CPU usage

ps: ps is short form of process status, equivalent to the top command. It’s used to show currently running processes with their PID.

A process ID is a unique number that identifies a process, with that you can kill or terminate a running program on your server (see kill command).
Examples:
ps U username : shows processes for a certain user
ps aux : shows all system processes
ps aux –forest : shows all system processes like the above but organizes in a hierarchy that’s very useful!

file : attempts to guess what type of file a file is by looking at it’s content.
Examples:
file * : prints out a list of all files/directories in a directory

du : shows disk usage.
Examples:
du -sh : shows a summary of total disk space used in the current directory, including subdirectories.
du -sh * : same as above, but for each file and directory. helpful when finding large files taking up space.

wc : word count
Examples:
wc -l filename.txt : tells how many lines are in filename.txt

cp : copy a file
Examples:
cp filename filename.backup : copies filename to filename.backup
cp -a /home/mysite/old/* /home/mysite/new/ : copies all files, retaining permissions form one directory to another.

kill: terminate a system process
Examples:
Syntax: kill -9 PID Examples: kill -9 431
Syntax: kill PID Examples: kill 10550

AddThis Social Bookmark Button

Control PHP Error Reporting With .htaccess

July 6th, 2008 Bala Krishna Posted in Blogging, Error Log, Linux, Linux Commands, Web Development, Web Technology No Comments »

Create .htaccess file or use existing .htaccess file in your hosting site. Add below line at the top of file content.
[sourcecode language='php']
# to stop php startup errors
php_flag display_startup_errors off
# to stop all php errors and warning
php_flag display_errors off
[/sourcecode]
You can also control level of error reporting. Here is the .htaccess syntax:
[sourcecode language='php']
# php directive for setting error level
php_value error_reporting integer
[/sourcecode]
Example:
[sourcecode language='php']
# report everything except run-time notices.
php_value error_reporting 8191
# report both fatal and non-fatal compile-time warnings by the Zend Engine
php_value error_reporting 128
# report run-time notices, compile-time parse errors, run-time errors and warnings
php_value error_reporting 8
# report fatal run-time errors and unrecoverable errors
php_value error_reporting 1
[/sourcecode]

AddThis Social Bookmark Button

What is Difference Between DNS CNAME & A Record

July 1st, 2008 Bala Krishna Posted in Godaddy Hosting, Linux, Linux Commands, Tips and Tricks, Web Development, Web Hosting, Web Technology 1 Comment »

CNAME stands for Canonical Name for a domain. CNAME is an alias records that create association between a sub-domain and antother domain or subdomain.

And, A Record simply creates an association between a domain/sub-domain name and an IP Address.

Example CNAME
gallery.bala-krishna.com -> gallery.another-domain.com -> 64.1.236.65

you can see above CNAME require two DNS lookup to translate domain/subdomain to an IP Address. If client request for gallery.bala-krishna.com then DNS record will return gallery.another-domain.com then gallery.another-domain.com has to query DNS to translate gallery.another-domain.com into IP Address.

CNAME Record Syntax:
www  14400  IN  CNAME  bala-krishna.com

Example A Record

gallery.another-domain.com -> 64.1.236.65

In case of gallery.another-domain.com, A record directly point to an IP Address so the DNS lookup directly returns IP Address to the client rather then domain/subdomain. hence only one DNS lookup required.

A Record Syntex:
ftp    14400  IN   A   67.159.45.3

AddThis Social Bookmark Button

Operating System Deadlock Explained

June 10th, 2008 Bala Krishna Posted in Linux, Operating System Tutorial, Tips and Tricks No Comments »

Boss said to secretary: For a week we will go abroad, so make arrangements.

Secretary makes call to her husband: For a week my boss and I will be going abroad, you look after yourself.

Husband makes call to his secret lover: My wife is going abroad for a week, so let’s spend the week together.

Secret lover makes call to small boy whom she is giving private tuition: I have work for a week, so you need not come for class.

Small boy makes call to his grandfather: Grandpa, for a week I don’t have class ‘coz my teacher is busy. Let’s spend the week together.

Grandpa (the 1st boss ;) ) makes call to his secretary: This week I am spending my time with my grandson. We cannot attend that meeting.

Secretary makes call to her husband: This week my boss has some work, we cancelled our trip.

Husband makes call to his secret lover: We cannot spend this week together, my wife has cancelled her trip.

Secret lover makes call to small boy whom she is giving private tuition: This week we will have class as usual.

Small boy makes call to his grandfather: Grandpa, my teacher said this week I have to attend class. Sorry I can’t give you company

Grandpa (Boss) makes call to his secretary: Don’t worry this week we will attend that meeting, so make arrangements ..

AddThis Social Bookmark Button

PHP Fatal Error Fix: Can’t use method return value in write context

May 15th, 2008 Bala Krishna Posted in Blogging, Browser Stuff, Bug Fix, General, Linux, Linux Commands, PHP Function, PHP Programming, PHP Tutorial, Tips and Tricks No Comments »

PHP compiler generate fatal error if you use function return value in read/write context. Although this is not applicable for all PHP supported function but PHP function like empty does not support use of the function in this way. In other words, php empty function cannot check the return value of a function or method. It can only check variables so use only variable inside empty function. Any other function or expression inside empty function will lead to generate fatal error.

Example Problem Solution:

Wrong
if(empty(trim($testimony))) echo “Empty”; else echo “Not Empty”;

Correct
$testimony = trim($testimony);
if(empty($testimony)) echo “Empty”; else echo “Not Empty”;

Wrong
if(empty($bobj->get_results(’post’)) { // Processing Code }

Correct
$tmp = $bobj->get_results(’post’);
if(empty($tmp)) { // Processing Code }

AddThis Social Bookmark Button

Fedora 9 Released

May 14th, 2008 Bala Krishna Posted in CentOS, Events, Linux, Linux Commands, Operating System Tutorial No Comments »

Fedora 9 Download

Finally Fedora 9 has been released. Fedora is a community supported operating system sponsored by Red Hat. It is maintained by fedora community members accross the world. Beside RHEL, Fedora is free, open to use and modify it to best suit your need. You are always open to distribute it.

New Features

  • GNOME 2.22 used in this release that includes webcam photo and video creation utility called Cheese.
  • Improved network filesystem support.
  • New improved international clock applet.
  • Google Calendar support and custom email labels in Evolution.
  • New Remote Desktop Viewer and improved accessibility features.
  • KDE 4.0.3 and Xfce 4.4.2 is included in this release.
  • NetworkManager 0.7 provides improved mobile broadband support, including GSM and CDMA devices, and now supports multiple devices and ad-hoc networking for sharing connections.
  • It is now enabled by default on installations from DVD, CD, the network, and Live images.
  • Supports partition resizing for ext2/3, NTFS filesystems.L
  • Live USB images support available.
  • FreeIPA makes managing auditing, identity and policy processes easier by providing web-based and command line provisioning, and administration tools to ease system administration. FreeIPA combines the power of the Fedora Directory Server with FreeRADIUS, MIT Kerberos, NTP and DNS to provide an easy, out of the box solution.
  • Next generation Ext4 support for better performance, higher storage capacity and several other new features.
  • Fedora 9 uses Upstart, an event-based replacement for the /sbin/init daemon.
  • Firefox 3 support for native look and feel and desktop integration.
  • By default now support and installed free and open source Java environment OpenJDK 6
  • OpenOffice.org 2.4 included with many new features.
  • Fedora 9 includes Perl 5.10.0 features a smaller memory footprint and other improvements.
  • Fedora 9 features a 2.6.25 based kernel.
  • Automatic report kernel crashes to http://www.kerneloops.org

Download

i386 - Install DVD
x86_64 - Install DVD
ppc - Install DVD
i386 - Install CDs
x86_64 - Install CDs
ppc - Install CDs

Check out more download option here

AddThis Social Bookmark Button

Wordpress 2.5 Popularity Contest Plugin Fatal Error Fix

April 23rd, 2008 Bala Krishna Posted in Browser Stuff, Bug Fix, General, Linux, Linux Commands, PHP Function, PHP Programming, PHP Tutorial, Tips and Tricks, Word Press, Wordpress Plugin No Comments »

If you are using Alex popularity plug-in then you might face this error while upgrading plug-in automatically in WP 2.5. This error generate due to invalid wp-header file path in plug-in file. Unfortunately, Alex not released new fixed version of the this popular plug-in. However, fix is really very simple and anyone can fix issue just by editing one single plug-in file. Please follow steps below to fix this error in your installation:

  1. Deactivate older version of the plugin. If you are installing first time skip this step.
  2. Download the latest release from wordpress.org or plugin author website.
  3. Open popularity-contest.php in your favorite editor and scroll down to line 59. Replace
    require('../../wp-blog-header.php');

    with

    require('../wp-blog-header.php');
  4. Save file and upload file to your plugins folder.
  5. Reactivate the plugin
AddThis Social Bookmark Button

Gallary2 Platform Failure Error Fix

March 17th, 2008 Bala Krishna Posted in Blogging, Browser Stuff, Bug Fix, FFMPEG, FFMPEG-PHP, Firefox Add-On, Gallery2, General, Linux, Linux Commands, Tips and Tricks, Web Development, Web Technology, Word Press, Wordpress Plugin No Comments »

This is common error occur due to wrong permission setting in Gallery2 data directory. During module uninstall, gallery2 restore directory permission and other changes as it was before the module installation. This feature sometime break gallery directory permission and directory does not work. See Image bellow for exact error description.

Gallary2 Platform Failure Error Fix

Solution:

Try changing gallery data directory “/g2data” permission to 777. If this does not fix your problem then try changing permission to “/g2data/smarty/templates_c“. After this step delete all content including directory inside “/g2data/smarty/templates_c” directory. This should fix ERROR_PLATFORM_FAILURE problem.

AddThis Social Bookmark Button

Uber Uploader ClipShare Rayzz Ostube Failed to Find File Length Error

February 4th, 2008 Bala Krishna Posted in Blogging, Browser Stuff, Bug Fix, CentOS, Crawler, FFMPEG, FFMPEG-PHP, Linux, Linux Commands, Online Media, Operating System Tutorial, PHP Function, PHP Programming, PHP Tutorial, Tips and Tricks, VBScript, Web Development, Web Directory, Web Hosting, Web Technology, uber-uploader, windows xp No Comments »

You may receive “Failed To Find Flength File” error during file upload using uber uploader. The main cause of this problem is due to apache mod_security enabled on your host. Apache mod_security may prevent writing flength file duing file upload. This will cause uploder to determine file length for percentage calculation and uploader produce file length error.

Solution: This problem can be easily solve by turn off mod_security through .htaccess . We need to turn off mod_security for uploader directory. To solve this problem, create .htaccess file with the following line and upload file to the directory where uploader files reside.

<IfModule mod_security.c>
# Turn off mod_security filtering.
SecFilterEngine Off

# The below probably isn’t needed,
# but better safe than sorry.
SecFilterScanPOST Off
</IfModule>

AddThis Social Bookmark Button

Memory Management with Fixed Partitions (MFT)

January 31st, 2008 Bala Krishna Posted in Linux, Linux Commands, Operating System Tutorial, Web Technology, Window Application No Comments »

The basic memory management approach is to divide memory into several fixed size of partitions where each partition accommodate only one program for execution. The program residing in memory will be bound by the number of partitions. When a program terminates that partitions is free for another program waiting in queue.

For example, refer the figure. the memory is divided in 6 regions the first region is reserved for the operating system. The remaining five regions are for user program area. The above figure there partitions are occupied by the program P1,P2,P3 only the first and last one are free for allocation. Once partitions are defined operating system keeps track of status of memory partitions.

Memory Management with Fixed Partitions (MFT)

The two most common strategies to allocate free partitions to ready processes are:

  • First Fit: The approach followed in first fit is to allocate first free partitions large through to accommodate the process.
  • Best Fit: The approach followed is the best fit is to allocate smallest free partition that meets the requirement of the process.

Both these strategies require a partition description table to find out the free partitions. However, the first fit terminates after finding the first such partitions whereas the best fit continues searching for the near exact size. As result, the first fit executes faster whereas the best fit achieves higher utilization of memory by searching the smallest free partition.

To explain these two strategies, let us take one example. A new process P4 with size 80K is ready to be allocated into memory whose partition layout is given in the figure using first fit strategy, P4 will get the first partition having 120K of unused memory space. This is internal fragmentation, Since the 120K of memory space is wasted. No other process requires this much of memory space will be allocated to the next partition but can not utilize this free space left in the above partition. Therefore, to reduce the internal fragmentation best fit will continue. Searching for the best posible partition and allocate the last partition to the process having fast 20k bytes of unused memory. Here also we have internal fragmentation but only 20k of memory space is wested.

AddThis Social Bookmark Button




|