Archive for the ‘Linux’ Category

Configuring Linux Best Practise

Monday, April 13th, 2009

yum update

yum install sysstat

chkconfig --level 123456 bluetooth off
chkconfig --level 123456 avahi-daemon off
chkconfig --level 123456 cups off
chkconfig --level 123456 iptables off
chkconfig --level 123456 ip6tables off
chkconfig --level 123456 pcscd off
chkconfig --level 0123456 yum-updatesd off
chkconfig --level 0123456 smartd off
chkconfig --level 0123456 hidd off
chkconfig --level 0123456 gpm off
chkconfig --level 0123456 apmd off

chkconfig --level 345 ntpd on
chkconfig --level 345 ntpdate on

vi /etc/ntp.conf
vi /etc/sysconfig/selinux
vi /etc/sysconfig/network-scripts/ifcfg-eth0

yum install kernel source

Tuesday, November 18th, 2008

yum install kernel-devel

Support 4G or more memory for Fedora / RHEL / CentOS

Sunday, August 17th, 2008

If you have 4 GB or more RAM use the Linux kernel compiled for PAE capable machines. Your machine may not show up total 4GB ram. All you have to do is install PAE kernel package.

This package includes a version of the Linux kernel with support for up to 64GB of high memory. It requires a CPU with Physical Address Extensions (PAE).
The non-PAE kernel can only address up to 4GB of memory. Install the kernel-PAE package if your machine has more than 4GB of memory (>=4GB).

To install PAE Kernel.

yum install kernel-PAE

Replacing a string inline using Perl CLI

Sunday, February 24th, 2008

This is a technique to replace a string in a file or a number of files using Perl.

perl -pi -e ‘s/old_string/new_string/g’ file_pattern

Can’t locate Net/SNMP.pm in @INC ….

Saturday, February 16th, 2008

If you are getting this error, you will need to install NET::SNMP Perl CPAN module.

The easiest way to install the NET::SNMP module is to by the CPAN CLI interface.

# perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell — CPAN exploration and modules installation (v1.7602)
ReadLine support available (try ‘install Bundle::CPAN’)

cpan> install Net::SNMP

sudo: sorry, you must have a tty to run sudo

Sunday, December 30th, 2007

if you are trying to run a command via sudo and encounter the following error:

sudo: sorry, you must have a tty to run sudo

then you can comment out the following parameter in the /etc/sudoers

#Defaults requiretty

Setup SMTP Auth in sendmail

Tuesday, October 30th, 2007

This is a simple how-to to configure SMTP authenication in Sendmail.

1. install sendmail-cf rpm
#> yum install sendmail-cf

2. edit /etc/mail/sendmail.mc, verify it contains the following options

define(`SMART_HOST’, `cluster9out.us.messagelabs.com’)dnl
define(`confAUTH_OPTIONS’, `A’)dnl
TRUST_AUTH_MECH(`LOGIN PLAIN’)dnl
define(`confAUTH_MECHANISMS’, `LOGIN PLAIN’)dnl
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl

3. execute this command
#> cd /etc/mail
#> make
#> service sendmail restart
#> /usr/sbin/saslauthd -a shadow

4. edit /etc/rc.d/rc.local, add the line below
/usr/sbin/saslauthd -a shadow

SSH Auto Login

Monday, June 25th, 2007

On the client that requires to login to the remote, execute the following command to generate the public and private keys.

[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
3e:b1:6d:44:73:e6:ca:af:3c:06:48:f1:f2:c1:5a:b6 root@localhost.localdomain

append the public key to the remote server
on the client
cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwA3AQEAsr8DueNT........... root@localhost.localdomain

on the server
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwA3AQEAsr8DueNT........... root@localhost.localdomain"
>> ~/.ssh/authorized_keys2

You may need to change root@localhost.localdomain to suit your need.

Adding Static Route on Startup

Saturday, June 2nd, 2007

Create if /etc/sysconfig/static-routes does not exist.

# Routing to HK
eth0 net 192.168.2.0 netmask 255.255.255.0 gw 172.16.1.6
eth0 net 192.168.1.8 netmask 255.255.255.248 gw 172.16.1.6
# Routing to Japan
eth0 net 192.168.3.0 netmask 255.255.255.0 gw 172.16.1.1
eth0 net 192.168.4.0 netmask 255.255.255.0 gw 172.16.1.1

set the hardware clock to the current system time

Saturday, June 2nd, 2007


hwclock --systohc