Saturday, October 25, 2014

Copy files with original timestamp in Linux commandline

If you move files on Linux with command mv, time-stamp won't be change, But if you copy with command cp, it'll take current time for time-stamp. If we wanna get original time-stamp, you can use following command on Linux,

cp -R -u -p /source /destination

What is time-stamp ?

When we create or modify file / directory, it'll store creation and / or modification date and time on file / directory properties. Which is called time-stamp.





Friday, October 24, 2014

Setting up default permissions to Files and Directories

Most of the Linux beginners / Linux - Level 1 administrator do this funny thing. Setting up 777 permission to files and folders.

With, chmod -R 777 folder_name

Some times it'll help to destroy the server easily by hackers.

Let's come to topic, How to setup default / basic level permission to files and folders.

chmod -R 777 folder_name will give you files and folders with read, write and execute permission, Mostly we no need of execute permission for files.

If we try to change it as chmod -R 666 folder_name, we are not able to open directory.

If we have 100s of sub directory with 1000 of files in each directory,... oh my god.... How do we fix it worst thing.... Here is command.

first open your parent directory, with
cd parent_directory_name

And run following commands,

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

Working: On first command It'll check type of the object whether it is file or directory, if it is directory it'll change permission to 755, else leave. On second same condition, if it is file then change permission to 644 else leave with same,

Copy mysql database table by query / command line

We can find lot of solutions to make copy of table.
Here is one of the simple solution which I got while google.

Copy table with in a Database

use databasename;

CREATE TABLE exampletable_copy LIKE exampletable;
INSERT exampletable_copy SELECT * FROM exampletable; 


Copy table from Database-1 to Database-2

use databasename2;

CREATE TABLE exampletable_copy LIKE exampletable.databasename1;
INSERT exampletable_copy SELECT * FROM exampletable.databasename1


Hint:
First query used to create table with structure of original table.
Second query used to copy data from table to table-copy.

Tuesday, October 21, 2014

Create mail account and alias by command line with parallel plesk panel

Following command is used to create mail account by Linux command line for parallel plesk panel

/usr/local/psa/bin/mail --create [email protected] -mailbox true -passwd Pa55w0rd -antivirus in


Following command is used to create mail account by Linux command line for parallel plesk panel

/usr/local/psa/bin/mail -u [email protected] -aliases add:alias1,alias2,alias3,alias4,alias5,alias6


Note : Change bold place as your requirement


You can use this line multiple time for create more mail accounts / alias accounts, Need to work some more for get input from text file and create mails and alias. I'll try to update soon with script.

Disabling local mail for a domain on parallel plesk panel

When we migrate mail servers with parallel plesk panel, We can use plesk migration manager.

But some case, we migrate server manualy,

Last time I faced following issue,

Server 1 : Current server
Server 2 : New Server

We had around 50 domain / subscription in our server. We planned to switch Server 1 to Server 2 one by one.

By commands & scripts, we've created all domains and mail accounts to Server 2. But we didn't change all domain MX to server 2. That means first 20 domains run in Server 2 and another 30 domains in Server 1.

In this case we got issue for deliver emails from Server 1 to Server 2 and vise-versa.

In this case problem with resolving domain

Any mail server first try to check whether domain in local server or not. If it in local server, it'll deliver mail to mail box directly. In our case both server have all 50 domains and their mail box. So it trying to deliver mails with in server. So it not reach to real location of mail box.

Solution !!! It's not a good idea to remove domains and mail account which is not usable. I've tried with disabling mail box in plesk panel. No use of it. Because it'll just stop sending mail to mail box. But local domain resolvation  won't be stop.

So I've to stop mail service for that domain, following command helped to do that.

/usr/local/psa/bin/mail --off domain.com

If you want to enable domain again, use following command

/usr/local/psa/bin/mail --on domain.com



Force Qmail to process all mails in the queue

Some times qmail not deliver mails, due to connection issue, in that case we can force qmail to send mails forcefully with following command.

This will send alarm signal to mail send.


 kill -ALRM `ps ax | grep [q]mail-send | awk '{print $1}'`


Source : Plesk support

Monday, October 20, 2014

Changing mail queue life time in qmail installed with plesk

Default queue life time is 7 days. That means, your mails will be stored in queue for 7 days if it not able to deliver. 

We can reduce this queue time with following steps.

To check current queue life time:

/var/qmail/bin/qmail-showctl | grep life

Time mentioned as seconds,


To set queue life time:

echo "172800" > /var/qmail/control/queuelifetime

Here I've set queuelifetime is 2 days.


For changes to take effect

service qmail restart

or

/etc/init.d/qmail restart

Tuesday, June 3, 2014

Timezone restore in Linux

We got problem in Centos 6 server with plesk panel,

Timezone got reset frequently on one that server, I've found the issue on update of tzdata package, Working on it to find permanent solution, But in mean time I've used following script for reset timezone.

# /bin/sh
TZ=`date '+%Z'`
CTIME=` date '+%Y/%m/%d'-'%T'`
if [[ "$TZ" != IST ]] ; then
touch /var/log/timezone-script.log
echo "["$CTIME"]" "Current time-zone is" $TZ "and Needs to change" >> /var/log/timezone-script.log
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
else
echo "["$CTIME"]" "Current time-zone is" $TZ "and Working fine" >> /var/log/timezone-script.log
fi
Change your timezone what you need, I'm using IST and using log file to know status. Even we can use mail function on it.
 Default location of timezone is /usr/share/zoneinfo/ 

Saturday, April 5, 2014

Wednesday, March 5, 2014

Skype Full Installer for Windows Desktop

You can download latest version of Skype full installer (Offline Installer) from following link,

Official Skype offline installer http://www.skype.com/go/getskype-full

Saturday, January 11, 2014

STEPPED IN TO 5th YEAR OF MY CAREER LIFE

I have successfully stepped in to 5th Year of My Career Life

As


System Administrator