Friday, April 29, 2011

To watch SSH users actions

To view your ssh user activities

#cat /dev/vcs1

this will show you what happens in first console. to check other consoles  /dev/vcs1 or vcs2 or vcs3.

To find IP address & To watch Linux Memory usage

Find out your router’s external IP address using the Linux command line

To Find Router external IP.Using the following commands we can see our router external IP address

without curl

#wget -O - -q icanhazip.com

with curl

#curl ifconfig.me
 
#curl icanhazip.com

#curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'



TO see Linux memory usage in real-time

If you want to display your memory usage in real-time, do a

#watch -d "free -mt"

It will display used and free memory every two seconds.

Wednesday, April 27, 2011

Linux Command For Gmail inbox checking

To check the gmail,u can access ur  gmail inbox from command prompt.

#curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if //; print "$2\n" if /<(title|name)>(.*)<\/\1>/;'

Wednesday, April 20, 2011

Few Error Logs and solutions

Template Error: The template file must be given

Error : Template Error: The template file must be given

Solution : The problem due the cpanel default page missing on the server so you can reset the default page setting by using following steps …

WHM Main >> Account Functions >> Web Template Editor > Revert to Default

Once done you will again see the cpanel default page.

If you are facing this error on number of domains then you need to add the apache conf entry for that domain manually into httpd.conf file.

Manager of pid-file quit without updating fi

Error : Manager of pid-file quit without updating fi

Solution : When try to restart the mysql service on the server then above error is generated.

This problem is occurred due the “mysql ” database crashed and should be repaired but the mysql is already stopped on the server so you need to use the following command to repair and optimize the database when mysql service is down on the server.

For Repair “mysql ” database

# find /var/lib/mysql/mysql -name '*.MYI' -exec myisamchk -r {} \;

For Optimize the database

# find /var/lib/mysql -name '*.MYI' -exec myisamchk -o {} \;

Then

# ps -ef | grep mysql

# killall -KILL mysql

# /etc/init.d/mysql stop

# /etc/init.d/mysql start

DB Error: connect failed in horde

Error : When try to access the Horde from cPanel then it shows following error.

Warning: fopen(/var/cpanel/horde/log/horde_0.log) [function.fopen]: failed to open stream: Permission denied in /usr/local/cpanel/3rdparty/lib/php/Log/file.php on line 216
A fatal error has occurred

DB Error: connect failed

Details have been logged for the administrator.

Solution: The problem due to the ” Horde Groupware Webmail Edition detected ” means when you have try to update the Horde by using following commands

root@server[~]# /usr/local/cpanel/bin/update-horde --force

Then it shows the following error

!!! Horde Groupware Webmail Edition detected !!!
Install or update of standard Horde Webmail is disabled.
Horde Groupware Webmail was installed with cPanel 11.25.1.
Downgrades of Horde are not permitted due to MySQL differences.

Then you need to move the file

root@server[~]# mv /var/cpanel/horde/groupware_version /var/cpanel/horde/groupware_version-bak

After that run following commands

root@server[~]# /usr/local/cpanel/bin/update-horde --force

Request exceeded the limit of 10 internal redirects

Error : Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace

Solution : When access the domain and the domain not shows the content and the server logs shows the above error then you need to add the following code in .htaccess file.

RewriteCond %{ENV:REDIRECT_STATUS} 200

Or
If you are facing this problem for the addon domain then add the following Rewrite rules in main domain .htaccess file.

RewriteCond %{HTTP_HOST} ^(www\.)?addon_domain\.com
Rewriterule .* – [L]

Crontab - 15 Cron Job Examples

An experienced Linux sysadmin knows the importance of running the routine maintenance jobs in the background automatically.

Linux Cron utility is an effective way to schedule a routine background job at a specific time and/or day on an on-going basis.

Linux Crontab Format
MIN HOUR DOM MON DOW CMD
Table: Crontab Fields and Allowed Ranges (Linux Crontab Syntax)Field Description Allowed Value
MIN Minute field 0 to 59
HOUR Hour field 0 to 23
DOM Day of Month 1-31
MON Month field 1-12
DOW Day Of Week 0-6
CMD Command Any command to be executed.

1. Scheduling a Job For a Specific Time Every Day

The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on 10th June 08:30 AM.

Please note that the time field uses 24 hours format. So, for 8 AM use 8, and for 8 PM use 20.
30 08 10 06 * /home/raj/full-backup
30 – 30th Minute
08 – 08 AM
10 – 10th Day
06 – 6th Month (June)
* – Every day of the week
2. Schedule a Job For More Than One Instance (e.g. Twice a Day)

The following script take a incremental backup twice a day every day.

This example executes the specified incremental backup shell script (incremental-backup) at 11:00 and 16:00 on every day. The comma separated value in a field specifies that the command needs to be executed in all the mentioned time.
00 11,16 * * * /home/raj/bin/incremental-backup
00 – 0th Minute (Top of the hour)
11,16 – 11 AM and 4 PM
* – Every day
* – Every month
* – Every day of the week
3. Schedule a Job for Specific Range of Time (e.g. Only on Weekdays)

If you wanted a job to be scheduled for every hour with in a specific range of time then use the following.
Cron Job everyday during working hours

This example checks the status of the database everyday (including weekends) during the working hours 9 a.m – 6 p.m
00 09-18 * * * /home/raj/bin/checkdatabase
00 – 0th Minute (Top of the hour)
09-18 – 9 am, 10 am,11 am, 12 am, 1 pm, 2 pm, 3 pm, 4 pm, 5 pm, 6 pm
* – Every day
* – Every month
* – Every day of the week
Cron Job every weekday during working hours

This example checks the status of the database every weekday (i.e excluding Sat and Sun) during the working hours 9 a.m – 6 p.m.

4. How to View Crontab Entries?
View Current Logged-In User’s Crontab entries

To view your crontab entries type crontab -l from your unix account as shown below.

raj@mail$ crontab -l
0-55/5 * * * * /usr/sbin/vnstat.cron

[Note: This displays crontab of the current logged in user]
View Root Crontab entries

Login as root user (su – root) and do crontab -l as shown below.
root@mail# crontab -l
no crontab for root
Crontab HowTo: View Other Linux User’s Crontabs entries

To view crontab entries of other Linux users, login to root and use -u {username} -l as shown below.
root@mail# crontab -u raj -l

00 09-18 * * * /home/raj/checkdatabase
5. How to Edit Crontab Entries?
Edit Current Logged-In User’s Crontab entries

To edit a crontab entries, use crontab -e as shown below. By default this will edit the current logged-in users crontab.
raj@mail$ crontab -e

*/10 * * * * /home/raj/debian/bin/check-disk-space
~
"/tmp/crontab.XXXXyjWkHw" 2L, 83C

[Note: This will open the crontab file in Vim editor for editing.
Please note cron created a temporary /tmp/crontab.XX... ]

When you save the above temporary file with :wq, it will save the crontab and display the following message indicating the crontab is successfully modified.
~
"crontab.XXXXyjWkHw" 2L, 83C written
crontab: installing new crontab
Edit Root Crontab entries

Login as root user (su – root) and do crontab -e as shown below.
root@mail# crontab -e
Edit Other Linux User’s Crontab File entries

To edit crontab entries of other Linux users, login to root and use -u {username} -e as shown below.
root@mail# crontab -u raj -e

00 09-18 * * * /home/raj/ubuntu/bin/check-db-status
~
~
~
"/tmp/crontab.XXXXyjWkHw" 2L, 83C
6. Schedule a Job for Every Minute Using Cron.

Ideally you may not have a requirement to schedule a job every minute. But understanding this example will will help you understand the other examples mentioned below in this article.
* * * * * CMD

The * means all the possible unit — i.e every minute of every hour through out the year. More than using this * directly, you will find it very useful in the following cases.
When you specify */5 in minute field means every 5 minutes.
When you specify 0-10/2 in minute field mean every 2 minutes in the first 10 minute.
Thus the above convention can be used for all the other 4 fields.
7. Schedule a Background Cron Job For Every 10 Minutes.

Use the following, if you want to check the disk space every 10 minutes.
*/10 * * * * /home/raj/check-disk-space

It executes the specified command check-disk-space every 10 minutes through out the year. But you may have a requirement of executing the command only during office hours or vice versa. The above examples shows how to do those things.

Instead of specifying values in the 5 fields, we can specify it using a single keyword as mentioned below.

There are special cases in which instead of the above 5 fields you can use @ followed by a keyword — such as reboot, midnight, yearly, hourly.
Table: Cron special keywords and its meaningKeyword Equivalent
@yearly 0 0 1 1 *
@daily 0 0 * * *
@hourly 0 * * * *
@reboot Run at startup.

8. Schedule a Job For First Minute of Every Year using @yearly

If you want a job to be executed on the first minute of every year, then you can use the @yearly cron keyword as shown below.

This will execute the system annual maintenance using annual-maintenance shell script at 00:00 on Jan 1st for every year.
@yearly /home/raj/red-hat/bin/annual-maintenance
9. Schedule a Cron Job Beginning of Every Month using @monthly

It is as similar as the @yearly as above. But executes the command monthly once using @monthly cron keyword.

This will execute the shell script tape-backup at 00:00 on 1st of every month.
@monthly /home/raj/suse/bin/tape-backup
10. Schedule a Background Job Every Day using @daily

Using the @daily cron keyword, this will do a daily log file cleanup using cleanup-logs shell scriptat 00:00 on every day.
@daily /home/raj/arch-linux/bin/cleanup-logs "day started"
11. How to Execute a Linux Command After Every Reboot using @reboot?

Using the @reboot cron keyword, this will execute the specified command once after the machine got booted every time.
@reboot CMD
12. How to Disable/Redirect the Crontab Mail Output using MAIL keyword?

By default crontab sends the job output to the user who scheduled the job. If you want to redirect the output to a specific user, add or update the MAIL variable in the crontab as shown below.
raj@mail$ crontab -l
MAIL="raj"

@yearly /home/raj/annual-maintenance
*/10 * * * * /home/raj/check-disk-space

[Note: Crontab of the current logged in user with MAIL variable]


If you wanted the mail not to be sent to anywhere, i.e to stop the crontab output to be emailed, add or update the MAIL variable in the crontab as shown below.
MAIL=""
13. How to Execute a Linux Cron Jobs Every Second Using Crontab.

You cannot schedule a every-second cronjob. Because in cron the minimum unit you can specify is minute. In a typical scenario, there is no reason for most of us to run any job every second in the system.
14. Specify PATH Variable in the Crontab

All the above examples we specified absolute path of the Linux command or the shell-script that needs to be executed.

For example, instead of specifying /home/raj/tape-backup, if you want to just specify tape-backup, then add the path /home/raj to the PATH variable in the crontab as shown below.
raj@mail$ crontab -l

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/home/raj

@yearly annual-maintenance
*/10 * * * * check-disk-space

[Note: Crontab of the current logged in user with PATH variable]
15. Installing Crontab From a Cron File

Instead of directly editing the crontab file, you can also add all the entries to a cron-file first. Once you have all thoese entries in the file, you can upload or install them to the cron as shown below.
raj@mail$ crontab -l
no crontab for ramesh

$ cat cron-file.txt
@yearly /home/raj/annual-maintenance
*/10 * * * * /home/ramej/check-disk-space

raj@mail$ crontab cron-file.txt

raj@mail$ crontab -l
@yearly /home/raj/annual-maintenance
*/10 * * * * /home/raj/check-disk-space

Note: This will install the cron-file.txt to your crontab, which will also remove your old cron entries. So, please be careful while uploading cron entries from a cron-file.txt.

Saturday, April 16, 2011

லினக்ஸ் வரலாறு

க்னூ/லினக்ஸ் (GNU/Linux) என்பது கணினிகளில் உள்ள ஓர் இயக்குதளமாகும்..

இவ்வியக்குதளம் பொதுவாக லினக்ஸ் என்ற பெயரால் அறியப்படுகிறது. ஆனாலும், இதன் மிகச்சரியான நிறுவன ஏற்புப் (உத்தியோகபூர்வமான) பெயர் க்னூ/லினக்ஸ் என்பதேயாகும்.

* 1983: ரிச்சர்ட் ஸ்டால்மன் அவர்களால் க்னூ திட்டம் தொடங்கப்படுகிறது. இத்திட்டம் யுனிக்ஸ்">யுனிக்ஸ் இயக்குதளத்தை ஒத்த திறந்த ஆணைமூல இயக்குதளம் ஒன்றினை உருவாக்குதலை நோக்கமாக கொண்டிருந்தது.

* 1990: க்னூ செயல் திட்டம் ஏறத்தாழ நிறைவடையும் நிலையை அண்மித்தது. ஓர் இயக்குதளத்துக்கு தேவையான செயலிகள் (இன்னமும் எழுதப்படவில்லை)">செயலிகள், காம்பைலர்கள், உரைத்தொகுப்பிகள், யுனிக்சை ஒத்த ஆணைமுகப்பு (command shell) போன்றவை அனைத்தும் செய்து முடிக்கப்பட்டுவிட்டன. மிக அடிப்படை நிலையில் இருக்கும் கரு (கருனி) ( kernel) ஒன்றை உருவாக்கும் பணி மட்டுமே முற்றுப்பெறவில்லை. அப்போது GNU Hurd என்ற கரு (கருனி) வடிவமைக்கப்பட்ட வண்ணமிருந்தாலும், அது போதாததாகவே உணரப்பட்டது.

* 1991: லினக்ஸ் ஸ்டோவாட்ஸ் என்பவர், அக்காலத்தில் அவருக்கு பல்கலைக்கழகத்தில் கற்பித்த பேராசிரியர், இயங்குதளங்களை பற்றி கற்பிப்பதற்காக வடிவமைத்து வைத்திருந்த மினிக்ஸ் (இன்னமும் எழுதப்படவில்லை)">மினிக்ஸ் என்ற மென்பொருளை மேம்படுத்த முயன்றுகொண்டிருந்தார். இதற்கான அனுமதி மறுக்கப்படவே, மினிக்சை ஒத்த இயக்குதளம் ஒன்றை வடிவமைக்கத் தொடங்கினார். இதன் படிவளர்ச்சி நாளடைவில் ஒரு முழுமையான இயக்குதள கருவைத் (கருனியைத்) தந்தளித்தது.

* 1991 செப்டெம்பர் 17: லினக்ஸ் தனது இயங்குதளத்தை இணையத்தில் கிடைக்கச்செய்கிறார். இதன் ஆணைமூலத்தை பெற்ற ஏராளமான நிரலாளர்கள் (இன்னமும் எழுதப்படவில்லை)">நிரலாளர்கள் லினக்சை மேன்மேலும் வளர்த்தெடுக்கிறார்கள்.

அக்காலத்தில் லினக்சை செயற்படுத்த மினிக்ஸ் தொகுதி தேவைப்பட்டது. லினக்ஸ் கருவினை (கருனியை) செயற்படுத்த ஒரு சிறந்த இயக்குதளத்தின் தேவை உணரப்பட்ட நிலையில் லினக்ஸ்ஸும் அவருடன் பணியாற்றிய ஏனைய நிரலாளர்களும் க்னூ செயற்றிட்டத்தின் மென்பொருட்களுடன் லினக்சை ஒருங்கிணைப்பது என்ற முடிவுக்கு வந்தனர்.