Posts

Showing posts from March, 2013

Cherokee Web Server on Linux ( Cross-platform Web server ) :

Cherokee is one of the fastest and most flexible web server's available. Cherokee is able to gracefully handle many concurrent connections while maintaining a low memory footprint. It supports a large variety of technologies, features, load balancing capabilities, platforms, and provides an administration interface to configure your server and sites. Installation: RPM: [root@ranjith ~]# rpm -Uvh http://download.fedora.redhat. com/pub/epel/5/i386/epel- release-5-4.noarch.rpm YUM: [root@ranjith ~]# yum install cherokee start Cherokee and add it to the default runlevel (to start at boot time). [root@ranjith ~]# /etc/init.d/cherokee start [root@ranjith ~]# chkconfig cherokee on Configuration Unlike Apache, Cherokee itself provides an interface for administering the web server. To start the admin interface, run the following command in the shell. [root@ranjith ~]# cherokee-admin -b The output of this command will show the login pass, and URL. Similar to the

Bash Test Operators

STRINGS: ------------------------------------- syntax: if [ "$str1" operator "$str2" ] then    command fi ------------------------------------- =     is equal to ==     is equal to     if (( $1 == $2 )) [Note: Used within double parentheses] The == comparison operator behaves differently within a double-brackets test than within single brackets. [[ $a == z* ]]     True if $a starts with an “z” (pattern matching). [[ $a == "z*" ]]     True if $a is equal to z* (literal matching). [ $a == z* ]     File globbing and word splitting take place. [ "$a" == "z*" ]     True if $a is equal to z* (literal matching). !=     is not equal to <     is less than, in ASCII alphabetical order >     is greater than, in ASCII alphabetical order -n     string is not “null.” -z     string is “null, ” that is, has zero length INTEGERS:  -------------------------------------------- syntax: if [ "$string1" operator &qu

Zombie Processes in Linux

What is a zombie? Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table. Since this process is not alive, it cannot react to signals. Zombie state can finish when the parent dies. All resources of the zombie state process are cleared by the kernel. Causes of Zombie Processes: When a subprocess exits, its parent is supposed to use the "wait" system call and collect the process's exit information. The subprocess exists as a zombie process until this happens, which is usually immediately. However, if the parent process isn't programmed properly or has a bug and never calls "wait," the zombie process remains, eternally waiting for its information to be collected by its parent. Killing Zombie Processes: Zombie processes persist until their parent process ends, at which point they are adopted by the "init" system process and shortly cle

swap partition VS swap file

Swap File: 1. If the hard disk is full or corrupted,swap file will get damaged. 2. System speed get decrease as soon the hard disk space is full. 3. It should be on a particular location where it should not get damaged or accidentally copied with other files. 4. It have advantage to increase the swap space on a system that have already installed with linux. 5. In any case if we need to increase the swap space of the system immediately we can do it. 6. We can able to create and keep the swap file on external device. 7. New kernel have nearly achieved to make both swap partitions and swap file speed closer. 8. Swap file will get fragmented. Swap Partition: 1. Reside on a separate hard disk space. 2. Multiple Os on a single machine can share the same partition. 3. Fragmentation is less compare to swap file. 4. If hard disk is corrupted the swap partition would not be functioning. 5. Reduce accident loss or corruption.

What is Swap Space?

 Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory. Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files. Swap Space Calculation

How to echo colored text in linux shell script:

Colored text in Linux shell script:   Having a colourful display on shell script is something that’d beautify your experience. Using colour text and echos will help you to highlight and distinguish the shell output on a linux prompt. Try following command on you bash: syntax: echo -e "\033[COLOR1;COLOR2m sample text\033[0m" The semicolon separated numbers "COLOR1" and "COLOR2" specify a foreground and a background color.The order of the numbers does not matter, since the foreground and background numbers fall in non- overlapping ranges."m" terminates the escape sequence, and the text begins immediately after that.Although setting the colors separately also work (i.e. \033[44m\033[32m). echo -e "\033[33;31m Color Text" - red echo -e "\033[33;32m Color Text" - green echo -e "\033[33;33m Color Text" - yellow echo -e "\033[33;34m Color Text" - blue echo -e "\033[33;35m Color Text" - Magenta echo

Shell Script To Display Logged in Users and Load:

To know current users and server load while login: Place the below code in /root/.bashrc file, a=$(cat /proc/loadavg | awk '{print $1}') echo -e "\033[33;34m" echo -e "Server load average is : $a\n" b=$(who | awk '{print $1}' | wc -l) echo -e "Current users : $b" echo -e "\033[33;m" Hereafter, You can find the load and current user info in each login.

Table './mysql/user' is marked as crashed and should be repaired

How to make mysql service online from crash! mysqld started [ERROR] /usr/sbin/mysqld: Table './mysql/user' is marked as crashed and should be repaired [ERROR] /usr/sbin/mysqld: Table './mysql/user' is marked as crashed and should be repaired [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/user' is marked as crashed and should be repaired mysqld ended Which means DB: /var/lib/mysql/mysql table: "user" has been crashed. To resolve this issue, please perform the commands below: root@ranjith [/var/lib/mysql/mysql]# service mysql start --skip-grant-tables now with mysql started, you can repair the mysql/user table root@ranjith [/var/lib/mysql/mysql]# mysqlcheck -r mysql user or Repair ALL database tables thorugh: http://techietent.blogspot.in/ 2013/02/how-repair-all- database-tables.html After that, root@ranjith [/var/lib/mysql/mysql]# service mysql stop Shutting down MySQLs [ OK ] root@ranjith [

URL redirection using .htaccess

.htaccess The .htaccess file is a small text document that generally sits in the same location as your index.php or index.htm pages. It gives you the ability to interact with Apache on an individual domain-to-domain and directory-to-directory basis. # This will allow to Redirect index page in site like (http://domain.com/index.html): Options +FollowSymLinks RewriteCond %{THE_REQUEST} ^.*/index.html RewriteRule ^(.*)index.html$ http://www.yoursite.com/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^.*/index.php RewriteRule ^(.*)index.php$ http://www.yoursite.com/$1 [R=301,L] # This will allow you the Redirection on New Domain: Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L] # This will allow you to make All http request to https request for a Domain: RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}   # For PHPFox script: RewriteEngine On RewriteCond %{HTTPS} !^on$ Rewrite

Command Aliases

Command Aliases If you always run a command with the same set of options, you can have bash create an alias for it. This alias will incorporate the required options, so that you don't need to remember them or manually type them every time. For example, if you always run ls with the -l option to obtain a detailed directory listing, you can use this command: root@server # alias ls='ls -l' To create an alias that automatically includes the -l option. Once this alias has been created, typing ls at the bash prompt will invoke the alias and produce the ls -l output. You can obtain a list of available aliases by invoking alias without any arguments, and you can delete an alias with unalias. Quickly jump to frequently-used directories You probably already know that the $PATH variable lists bash's "search path" - the directories it will search when it can't find the requested file in the current directory. However, bash also supports the

NGINX: SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause

If you are facing below error in Nginx! SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause Installing WHM interface... deploying booster rockets Traceback (most recent call last): File "/usr/local/src/publicnginx/nginxinstaller2", line 9, in ? import createvhosts File "/usr/local/src/publicnginx/createvhosts.py", line 2, in ? import yaml File "/usr/lib/python2.4/site-packages/PyYAML-3.10-py2.4-linux-i686.egg/yaml/__init__.py", line 26 SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause This error normally happen if you install first time, You have not needed this fix is you are upgrading from old version. NOTE: Please don't run this fix multiple time # tar xf nginxadmin.tar # cd publicnginx ## ./pythonfix After that you can run installer as per bellow, # ./nginxinstaller install It should FIXED now!!! Please check: htt