Sunday, December 16, 2007

What is "Force User" in SAMBA ?

[uniqname]
comment = Unique comment
path = /path/to/the/stuff
public = no
writable = yes
printable = no
valid users = user1,user2,user3
force user = sushanth

The 'force user' directive means that at the point of connection the real
users identity is lost and the user now is 'sushanth'.

Tuesday, November 6, 2007

Configuring Disk Quota

To implement file quota we need to edit /etc/fstab file and add the usrquota and grpquota option to the partition for which you want to enable quotas

#vi /etc/fstab

/dev/VolGroup00/LogVol00 /ext3 defaults,usrquota,grpquota 11

save the file

Remount the filesystem

#mount -o remount

or if we have entered more than one filesystem in the fstab file then to remount all the filesystem

#mount -a remount

Run quotacheck command to check for an errors on the filesystem with quota check

#quotacheck -augmv

Syntax info are as follows:

a= perform quotacheck on all filesystems
m= the filesystem should not be mounted as read-only mode
u & g= tells to check for users and groups

Turn on the quota

#quotaon -augmv

Apply the quota for a particular user

#edquota -u sushanth

Apply quota for particular group

#edquota -r susgrp

Monday, November 5, 2007

Disk Space Management Using LVM

Before starting this task it is necessary to install the LVM package

Linux Kernel 2.4.x has the LVM inbuilt.

In this blog we will focus on how to create an LVM layout and then mount it under the home directory

My root partition is sda1 and sda2 is my swap

To start partitioning run fdisk on /dev/sda

#fdisk /dev/sda
Enter p to create a new primary partition , accept all the default values for the start and end cylinders.

The next step is to change the partition into LVM. This means that we need to change the disk system ID into 8e as a partition type.

The above mentioned task can be done using fdisk command

Now we will create a volume group.

Volume group is nothing but two or more physical volumes together form a volume group.To bring our disk under the volume group we will have to configure our physical volumes.

#pvcreate /dev/sda (this command will initialise the physical volume)

We will now create a volume group which uses this physical volume

# vgcreate home2 /dev/sda (home2 is the volume group)

In this manner we can have multiple physical volume under volume group home2

Now we have created the volume group, now we will create logical volumes. We can have many logical volumes under one volume group. Or we can use one complete logical group has one Logical volume.

#lvcreate -n downloads --size 1G home2

The above mentioned command will create a logical volume as download with 1GB space under volume group home2

-n is used to name the logical volume.

Before we can use the Logical Volume, we need to format it and then mount it.

We will create a directory under /mnt as mystuff.

Now we will format the logical volume (/dev/home2/download)

#mkfs ext3 /dev/home2/download

Once the formatting is over we will mount the logical volume on to the /mnt/mystuff

#mount /dev/home2/download /mnt/mystuff

To make a permanent entry

#vi /etc/fstab

/dev/home2/download /mnt/mystuff ext3 defaults 12

save the file

Mount NTFS partition on a Linux Machine from Command Prompt

Check the Kernel Version

#uname -r

Install the following rpm

#rpm -ivh kernel-ntfs.rpm

The rpm is available at www.linux-ntfs.org

#modprobe ntfs

Mount the NTFS partition

#mount -t ntfs /dev/hdb /mnt/ntfs

(create a directory ntfs under mnt directory)

Make the mount permanent by making an entry in the /etc/fstab

#vi /etc/fstab

/dev/hdb /mnt/ntfs ntfs defaults 00

save the file

Tuesday, October 30, 2007

NFS Configuration

We will configure NFS, whereby we will mount /test directory on the other machine

NFS Server Configuration:

Create a Directory which we need to Mount using NFS

#mkdir /test

Start the following services :

#service portmap start

#service nfs start

#service nfslock start

Edit the following file:

#vi /etc/exportfs

/test xxx.xxx.xxx.xxx(ro,sync,no_root_squash)

(xxx.xxx.xxx.xxx replace it with NFS client IP address)

save the file

#export -avr

NFS Client Configuration:

Start the following services

#service nfs start

#service nfslock start

#service portmap start

Create a directory:

#mkdir test1

#mount xxx.xxx.xxx.xxx:/test /test1

(xxx.xxx.xxx.xxx replace it with NFS server IP Address)

Squid Proxy Configuration

The SQUID is a Linux based utility that can be used to distribute internet to all the computers within the network

Squid configuration file : squid.conf

Location: /etc/squid

Edit the squid.conf file

#vi squid.conf

(Search for the default acl list and add the following)

acl mynetwork src xxx.xxx.xxx.xxxx / xxx.xxx.xxx.xxx (subnet)
acl mynetwork src xxx.xxx.xxx.xxx / xxx.xxx.xxx.xxx (for individual IP)

Then add acl (access control list) to the "http_access list" with the following line

http_access allow mynetwork

Default port is always 3128

You can comment this line and add any specific port we require

http_port 3128

Once the above mentioned changes has been done, save the file

Restart the squid service

#/etc/rc.d/init.d/squid restart

or we can use the following command

#squid -z

#squid

One the client system , just all the proxy IP address (Squid Server IP address) and port 3128 or any other port specified in squid.conf file

Sunday, October 21, 2007

Changing Kernel Parameters

To Display all the available Kernel Parameters

# sudo sysctl -a | sort | more

Each Kernel parameters are in a field = value format

For Example:

Kernel.threads-max = 16379

Decreasing the PID value will improve the performance

To change the parameter

# sudo sysctl -w kernel.threads-max=16000

The above command will change the parameter temporarily, once the machine reboots the parameters will come back to its previous value.

To make the new changes permanently , Edit the following

# /etc/sysctl.conf

Enter in the parameter changes

For example:

#vi /etc/sysctl.conf

kernel.threads-max=16000

save the file

Thursday, October 18, 2007

Change Linux Server date from GST to GMT

Edit the following :

# vi /etc/sysconfig/clock
Zone="GMT0"
UTC=true
ARC=false
:wq!

Delete file name localtime

#cd /etc

#rm -i localtime

Create a softlink

#ln -s /usr/share/zoneinfo/GMT0 /etc/localtime

Now check the date

Synchronise hardware clock with system clock

#hwclock --show

#hwclock --set --date="today's date time"

eg:

#hwclock --set --date="02/19/207 18:10:00"

#hwclock --show

#date

Synchronise hardware clock to system clock

#hwclock --hctosys

Wednesday, October 17, 2007

Compile and Install a New Linux Kernel

Download the latest kernel from www.kernel.org

#wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.19.tar.gz

#tar zxvf linux-2.4.19.tar.gz

#cd linux-2.4.19

Now you have to configure the kernel options
This is place where you select all the features you want to compile into the kernel. If you have an existing configuration from the older kernel, copy the old .config file to the top level of your source and use make oldconfig instead of menuconfig. This oldconfig process will carry over your previous settings and prompt you if, there are new features not covered by the earlier .config file.
We will presently follow a technique whereby we are just Compiling and Installing a new Kernel.

#make menuconfig

Now you will have to build all the dependencies for your chosen configuration.

#make dep

Now we can compile the actual Kernel

#make bzImage

The resulting kernel file is : arch/i386/boot/bzImage

Now you have to load the modules

#make modules

Install the modules

#make modules_install

Due to some reason you want to re-compile the whole kernel once again. You can use make command to delete intermediate file.
make mrproper command will delete he .config file

Task are as follows:

make mrproper
make menuconfig
make dep
make clean
make bzImage
make modules
make modules_install

Once the task is completed, now we have to boot from the new kernel. I take into consideration that LILO is installed in boot sector.

Before changing its better practice to take a backup

#cp arch/i386/boot/bzImage/vmlinuz-2.4.19

#cp system.map /boot

Now once the above mentioned steps are done we can tell the LILO about the new kernel

Edit the following lilo.conf file

#vi /etc/lilo.conf

image=/boot/vmlinuz-2.4.19
label="Linux 2.4.19"

:wq!

To apply the changes and boot from the new kernel

# lilo -v

Reboot the server.

Wednesday, October 10, 2007

Network Bonding Configuration

1. #/etc/sysconfig/network-scripts

2. create a file
# touch ifcfg-bond0

3. Edit the file
#vi ifcfg-bond0

4. Enter in the details
DEVICE=bond0
USERCTL=no
ONBOOT=yes
BROADCAST=xxx.xxx.xxx.xxx
NETWORK=xxx.xxx.xxx.xxx
NETMASK=xxx.xxx.xxx.xxx
GATEWAY=xxx.xxx.xxx.xxx
IPADDR=xxx.xxx.xxx.xxx

5. Edit ifcfg-eth0
#vi ifcfg-eth0

6. Enter in the details
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

7. Edit ifcfg-eth1
#vi ifcfg-eth1

8. Enter in the details
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

if the operating system is RHEL 32-bit then edit the following

1. #vi /etc/modules.conf
alias bond0 bonding
options bonding miimon=100 mode=0

if the operating system is RHEL 64-bit then edit the following

1. #vi /etc/modprobe.com
alias bond0 bonding
options bonding miimon=100 mode=0

Restart the network services

# service network restart