Archive for the Category »Few good queries and suggestions «

How to change timezone on Linux server?

You can change the time zone for your server by using following command.

root@gunjan[~]#date

Wed Nov 11 19:30:29 EST 2009

For example we are changing time zone  from EST to GMT.

root@gunjan[~]#ln -sf /usr/share/zoneinfo/GMT /etc/localtime

root@gunjan[~]#date

Thu Nov 12 00:31:36 GMT 2009

Simple cgi script to check the Server uptime?

The following script you can use to check the Server uptime?

root@Gunjan [/usr/local/apache/cgi-bin]# nano loads
#!/bin/bash

echo Content-type: text/plain
echo

echo $(hostname)
echo “=>”
echo $(uptime)

What is Core Files in Linux?

A core file created when ever a program terminates unexpectedly and its also useful for determining what caused the termination. In many Linux server by default they do not produce core files when programs crash or terminates unexpectedly.

On  most of the Linux server core file size limitation is set to 0.You can check the core file size limit set in server by using following command.

root@gunjan [~]# ulimit -c
1000000

In above command core file size limit is 1000000 if output occur empty then it means core file size limit haven’t set on server and you can set it as

root@gunjan [~]# ulimit -c 1000000

or

root@gunjan [~]# ulimit -c unlimited

If you want to test core file limit is working on your server or not? then run following command

kill -s SIGSEGV $$

This above command will crashes your shell and produces core file in the current directory. as core.*

If core file is taking lots of disk space on server and you want to disable it then follow the steps one by one.

root@gunjan [~]#which httpd

/usr/sbin/httpd

root@gunjan [~]#pico /usr/sbin/httpd

And following line in /usr/sbin/httpd

ulimit -c 0

And then restart the Apache server

What is path for “ifconfig”?

The ifconfig is present under /sbin  director and the PATH of the normal users don’t point to /sbin directory and if execute “ifconfig” under normal by using any normal cPanel user login details then it will not show you.

you can set PATH to add /sbin  #PATH=$PATH:/sbin

Or you can enter command with full path like # /sbin/ifconfig

How to Open Passive FTP in iptable?

To Open Passive FTP in iptable root login is require.

If you want to open port range from 30000:64000 then run the following command from shell.

iptables -A INPUT -p tcp -m tcp –dport 30000:64000 -j ACCEPT

Similarly you can open passive post range as per your requirement.

How to install ssl on default services(http, exim, imap, pop3, cpanel/WHM)?

You can install SSL on default services(http, exim, imap, pop3, cpanel/WHM) from your WHM but you require root login details to

The all cert information save in following path

/var/cpanel/ssl/cpanel

You can install the certificate from your WHM >>  Main >> Service Configuration >> Manage Service SSL Certificates

Explain rmmod?

The “rmmod" is used to remove the module from kernel.The module name which you wan to remove from the Kernel (excluding the .ko) is specified to identify the module. The kernel will not remove a module that is currently being used in the kernel (a non-zero use count), but a -w option can be specified to "rmmod" to instruct the kernel to remove it once the use-count has decreased to zero.

root@gunjan#rmmod your_module

If you don’t know anything about “lsmod” then please read it first

Problem with cgi script?

Most of the time cgi script is not working properly after uploading by using FTP but script is working fine on local machine, why?

Because you need to be upload cgi script in ASCII Mode and Perl in BINARY Mode to run it without any problem.

How to reset the load value for server?

You can set the load value for server by using following steps but make sure that you are having root login details to make server wide chanegs.

Edit the file

/var/cpanel/cpanel.config

and change extracpus to a number larger then 0

Then run /usr/local/cpanel/startup afterwards to pickup the changes.

Send mail by using phpmail function.

You can create a simple php mail form by using following code..

————————–

<?
$to      = ’supp0rt@xyz.com’;
$subject = ‘The test for mail function’;
$message = ‘Hello’;
$headers = ‘From: test@abc123.com’ . “\r\n” .
‘Reply-To: test@testforever123.com’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();
mail($to, $subject, $message, $headers);
?>

————————–

If you are not able to receive the E-mail then you need to check whether your server is allowing to send an E-mail by using phpmail() or not?’ if you are having root login then check the servers main php.ini file.

root@Gunjan []# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

root@Gunjan []# cat /usr/local/lib/php.ini | grep disable_function
disable_functions=”system,passthru,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,highlight_file,phpmail”

and remove the phpmail() from server mail php.ini file and restart the Apache web server.

Or

If you are not having root login details then contact your hosting provider and ask them to enable the phpmail() for your hosting account.

You can also send me an E-mail at nsk.gunjan@gmail.com if you have any queries…