Archive for the Category »Linux Administrator Interview Questions «

How to set E-mail size in exim?

You can set the E-mail size limit from your WHM.

First login into WHM
Second select “Exim Configuration Editor”  present unde ” Service Configuration” section.
Third scroll down and  click on  “Advanced Editor” optoin.

You will see  the empty box (remember select first empty box) where you can type  (right underneath where you see #!!# cPanel Exim 4 Config), enter in the following:

message_size_limit = 100M

Fourth scroll down to the bottom of that screen and click “Save” option.

Exim configuration will be rebuilt with the new option and your Exim will be restarted.

How to check mysql servers set values?

Most of the time we need to check the mysql value set on server and most of the techs checks /etc/my.cnf file.If you want to check all values set in mysql on server. We can use following simple command.

mysqld –no-defaults –verbose –help

How to define iptables rules save option?

iptables creating rules after restarting the iptables. When iptables service is restarted settings from /etc/sysconfig/iptables file are applied and used with the iptables.

You can either set up iptables rule so that current stat is saved the rule upon restart or stop/start:

You need to make changes in following file as per your requirement for values received in following GREP result.

root@server[~]# grep IPTABLES_SAVE /etc/sysconfig/iptables-config
IPTABLES_SAVE_ON_STOP=”no”
IPTABLES_SAVE_ON_RESTART=”no”
IPTABLES_SAVE_COUNTER=”no”

Or overwrite current settings with iptables-save to /etc/sysconfig/iptables file:

root@server[~]# iptables-save > /etc/sysconfig/iptables

Note : Its always good if we use NO option for following options because some time due to wrong rule we face major problem to access server.

IPTABLES_SAVE_ON_STOP=”no”
IPTABLES_SAVE_ON_RESTART=”no”
IPTABLES_SAVE_COUNTER=”no”


Simple steps for SSH Server Hardening.

SSH Server Hardening in one of the security part to secure your server.Refer following steps to secure SSH.

root@serevr[~]#pico /etc/ssh/sshd_config

Uncomment  #Protocol 2, 1

Change to Protocol 2

Append these lines to the bottom:

LoginGraceTime 120
IgnoreRhosts yes
X11Forwarding no
Save file and restart the SSH service.

root@serevr[~]#/etc/rc.d/init.d/sshd restart

Note : SSH Protocol one  based servers are facing many automated root kits attacks.As a result to step up the security Protcol 2 should be enabled on server.The reason to use SSH Protocol 2 on any webserver is that it is more secure as compare to protocol 1.

/scripts/fixquotas gives error “edquota: Quota file not found or has wrong format”?

After running /scripts/fixquotas it gives following error message and showing unlimited disk space in WHM >> Main >> List account.

root@server [/]# /scripts/fixquotas –force
Installing Default Quota Databases……Done
Linux Quota Support
Quotas are now on
Resetting quota for user23 to 1000 M
edquota: Quota file not found or has wrong format.
No filesystems with quota detected.
edquota: Quota file not found or has wrong format.
No filesystems with quota detected.
Resetting quota for user2 to 1000 M
edquota: Quota file not found or has wrong format.
No filesystems with quota detected.
Resetting quota for dates to 1000 M
Resetting quota for userq to 1000 M
edquota: Quota file not found or has wrong format.

In this case refer following steps.

root@server [/]#touch /home/quota.user
root@server [/]#touch /home/quota.group
root@server [/]#chmod 600 /home/quota.user
root@server [/]#chmod 600 /home/quota.group

root@server [/]#quotacheck -acugv

Some time above command gives error message

root@server [/]# quotacheck -acugv
quotacheck: Cannot remount filesystem mounted on / read-only so counted values might not be right.
Please stop all programs writing to filesystem or use -m flag to force checking.

Than run following command

root@server [/]# quotacheck -acugvm
quotacheck: Scanning /dev/simfs [/] quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
done
quotacheck: Checked 33478 directories and 368211 files
quotacheck: Old file not found.
quotacheck: Old file not found.

Now run

root@server [/]#/scripts/fixquotas –force

It will sort out your issue ENJOY :)

How to install Webmin?

You can install webmin by using following steps.

root@gunjan[~]#cd /usr/local/src

root@gunjan[~]#wget http://sourceforge.net/projects/webadmin/files/webmin/1.500/webmin-1.500-1.noarch.rpm/download

root@gunjan[~]#rpm -Uvh webmin-1.500-1.noarch.rpm

warning: webmin-1.500-1.noarch.rpm: Header V3 DSA signature: NOKEY, key ID xxxxx
Preparing… ########################################### [100%]
Operating system is CentOS Linux
1:webmin ########################################### [100%]
Webmin install complete. You can now login to http://server.domain.com:10000/
as root with your root password.

How to install YUM on plain Server?

First you need to login into shell as root user than follow the steps one by one.

[root@gunjan]#mkdir /root/support  && cd /root/support

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/gmp-4.1.4-10.el5.i386.rpm

[root@gunjan]#rpm -Uvh gmp-4.1.4-10.el5.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/readline-5.1-3.el5.i386.rpm

[root@gunjan]#rpm -Uvh readline-5.1-3.el5.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-2.4.3-27.el5.i386.rpm

[root@gunjan]#rpm -Uvh python-2.4.3-27.el5.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/libxml2-2.6.26-2.1.2.8.i386.rpm

[root@gunjan]#rpm -Uvh libxml2-2.6.26-2.1.2.8.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/libxml2-python-2.6.26-2.1.2.8.i386.rpm

[root@gunjan]#rpm -Uvh libxml2-python-2.6.26-2.1.2.8.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/expat-1.95.8-8.2.1.i386.rpm

[root@gunjan]#rpm -Uvh expat-1.95.8-8.2.1.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm

[root@gunjan]#rpm -Uvh python-elementtree-1.2.6-5.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/sqlite-3.3.6-5.i386.rpm

[root@gunjan]#rpm -Uvh sqlite-3.3.6-5.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm

[root@gunjan]#rpm -Uvh python-sqlite-1.1.7-1.2.1.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/elfutils-0.137-3.el5.i386.rpm

[root@gunjan]#rpm -Uvh elfutils-0.137-3.el5.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/rpm-python-4.4.2.3-18.el5.i386.rpm

[root@gunjan]#rpm -Uvh rpm-python-4.4.2.3-18.el5.i386.rpm

[root@gunjan]#It will throw following error.

[root@gunjan]# rpm -Uvh rpm-python-4.4.2.3-18.el5.i386.rpm

warning: rpm-python-4.4.2.3-18.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
error: Failed dependencies:
popt = 1.10.2.3-18.el5 is needed by rpm-python-4.4.2.3-18.el5.i386
rpm = 4.4.2.3-18.el5 is needed by rpm-python-4.4.2.3-18.el5.i386
rpm-libs = 4.4.2.3-18.el5 is needed by rpm-python-4.4.2.3-18.el5.i386

In that case search dependencies in following URL

http://rpm.pbone.net/

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/m2crypto-0.16-6.el5.6.i386.rpm

[root@gunjan]#rpm -Uvh m2crypto-0.16-6.el5.6.i386.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-urlgrabber-3.1.0-5.el5.noarch.rpm

[root@gunjan]#rpm -Uvh python-urlgrabber-3.1.0-5.el5.noarch.rpm

[root@gunjan]#wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/yum-3.2.22-20.el5.centos.noarch.rpm

[root@gunjan]#rpm -Uvh yum-3.2.22-20.el5.centos.noarch.rpm

It will throw following error.

[root@gunjan]# rpm -Uvh yum-3.2.22-20.el5.centos.noarch.rpm
warning: yum-3.2.22-20.el5.centos.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
error: Failed dependencies:
python-iniparse is needed by yum-3.2.22-20.el5.centos.noarch
rpm-python is needed by yum-3.2.22-20.el5.centos.noarch
yum-fastestmirror is needed by yum-3.2.22-20.el5.centos.noarch
yum-metadata-parser >= 1.1.0 is needed by yum-3.2.22-20.el5.centos.noarch

In that case search dependencies in following URL

http://rpm.pbone.net/

Once you complete all dependencies you can update yum by using following command

[root@gunjan]#yum -y update

Maximum file limit reach while starting Apache?

Maximum file limit reach error is occur while we are starting the Apache server at that time you can fix the issue by using root login details.

root@gunjan[~]#pico /etc/sysctl.conf
Add following line as

fs.file-max = 22992

Save and exit from the file.

You need to run following command from shell to active changes.

root@gunjan[~]#sysctl -p
It will increase the maximum number of open files for your Server.

How to install install Eaccelerator?

To install Eaccelerator manually refer following steps one by one carefully.

1. First you need to login into shell as root user

2. Now we’ll make the eaccelerator directory:

root@gunjan[]#cd ~

root@gunjan[~]#mkdir /eaccelerator/

root@gunjan[~]#cd /eaccelerator/

2. Now download the source file

root@gunjan[~]#wget http://heanet.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.4-rc1.tar.bz2

root@gunjan[~]#bzip2 -d eaccelerator-0.9.4-rc1.tar.bz2

root@gunjan[~]#tar xvf eaccelerator-0.9.4-rc1.tar

3. Now install Eaccelerator:

root@gunjan[~]#cd eaccelerator-0.9.4-rc1/

root@gunjan[~]#export PHP_PREFIX=”/usr”

root@gunjan[~]#$PHP_PREFIX/bin/phpize

root@gunjan[~]#./configure –enable-eaccelerator=shared –with-php-config=$PHP_PREFIX/bin/php-config

root@gunjan[~]#make

root@gunjan[~]#make install

4. Now basically eaccelerator installed, now we need to edit the php.ini files to
include Eaccelerator extension.

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[~]#pico /usr/local/lib/php.ini

copy and paste following lines php.ini carefully
———————-
extension=”eaccelerator.so”
eaccelerator.shm_size=”16?
eaccelerator.cache_dir=”/tmp/eaccelerator”
eaccelerator.enable=”1?
eaccelerator.optimizer=”1?
eaccelerator.check_mtime=”1?
eaccelerator.debug=”0?
eaccelerator.filter=””
eaccelerator.shm_max=”0?
eaccelerator.shm_ttl=”0?
eaccelerator.shm_prune_period=”0?
eaccelerator.shm_only=”0?
eaccelerator.compress=”1?
eaccelerator.compress_level=”9?
———————-

For a Zend extension install server (only if you have Zend installed on your server, or
if you’re going to install it)

———————-
zend_extension=”/usr/lib/php4/eaccelerator.so”
eaccelerator.shm_size=”16?
eaccelerator.cache_dir=”/tmp/eaccelerator”
eaccelerator.enable=”1?
eaccelerator.optimizer=”1?
eaccelerator.check_mtime=”1?
eaccelerator.debug=”0?
eaccelerator.filter=””
eaccelerator.shm_max=”0?
eaccelerator.shm_ttl=”0?
eaccelerator.shm_prune_period=”0?
eaccelerator.shm_only=”0?
eaccelerator.compress=”1?
eaccelerator.compress_level=”9?
———————-

5. Now you need to make the cache directory on your server, where the cache files will be
stored for eaccelerator
root@gunjan[]#cd ~

root@gunjan[~]#mkdir /tmp/eaccelerator/

root@gunjan[~]#chmod 0777 /tmp/eaccelerator/

6. Now restart Apache so that Eaccelerator will start working:

service httpd restart

Now check eAccelerator by using following command

root@gunjan[~]#php -v
PHP 5.2.11 with Suhosin-Patch 0.9.7 (cli) (built: Nov 20 2009 14:28:34)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
with the ionCube PHP Loader v3.3.7, Copyright (c) 2002-2009, by ionCube Ltd., and
with SourceGuardian v8.0, Copyright (c) 2000-2009, by Inovica Ltd.
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH

You done it enjoy :)