Wednesday, March 31, 2010

How to Install and configure a Samba Server in linux rhel5 / centos /all about samba

Advertisements

Samba have mainly following important uses:
  1. As a domain controller
  2. As a file server

This post explains how to configure and install Samba Server (Samba linux) in redhat rhel5 / Centos5 system. it'll work for other similar distros.
Samba provides mainly two services
1)file and
2)print services.
It allows data transfer between Linux boxes and Windows boxes. Samba uses SMB protocol to communicate with windows.

### Important Daemons in Samba ###
These are the mail services or daemons that runs samba.
smbd (139/445 _cifs)
nmbd (137/138)
winbindd - Mapping of users [ADS]

### Installing and Configuring a Samba Server ###
If you have a yum server configured, execute the following steps. Else find the required rpms and install.
# yum install samba*

The following packages will be installed.
xinetd [dep]
samba
samba-client
samba-swat

Start the samba service.

#/etc/init.d/smb start
SMB services started
NMB services started
#chkconfig smb on


Important fields in /etc/samba.smb.conf [Samba configuration file] :

When you use samba server there is one important thing you have to note. Thats in the configuration file. In glogal settings there is a "workgroup" field. In that you have to give the domain name if your windows machine belongs to one. Or you can give workgroup name if it is belongs to any. For sharing files and folders workgroup is enough.
You can make the above changes in windows also, but it requires rebooting of the windows machine. So its better you change the corresponding fields in linux box.

There is also another field "server string" in global settings. Its just as hostname. You can give any name by which you can identify the samba box.

The field "host allow" specifies the hosts which are allowed for the particular share. See the example below.

host allow = 192.168.0.21 #allow 192.168.0.21 only
host allow = 192.168.0. # allows all the machines starting with 192.168.0. network.

The field "write list" specifies the group of users who has write permission on that share.
For example

write list = @admins #the group admins has the write permission on that share.
The field "valid users" means only that users specified has access to that share.

valid users = root, samba1
## Some useful samba linux commands ##


#findsmb
The command findsmb returns the systems running samba compatible services.

#smbtree
smbtree is a smb browser program in text mode. It is similar to the "Network Neighborhood" found on Windows computers. It prints a tree with all the known domains, the servers in those domains and the shares on the servers.

To login Annonimously to a Windows box. If enabled.
[root@vm1 ~]# smbclient //192.168.0.77/Share_name -N
Anonymous login successful

[root@vm1 ~]# smbclient -L 192.168.0.77 [192.168.0.77 is a Windows box]
binds to windows as guest user. you have to enable the guest user login.
shows the domains and workgroups but not the shares. To see shares you have to login as privillaged user.

How to list the shares in a windows machine to a samba server?
[root@vm1 ~]# smbclient -L 192.168.0.77 -U administrator
binds to windows as administrator. You can see all the shares in the system. It will promt password.
Note: administrator is the windows user.

### using samba credential file ###
Using a credential file you can save time. The format of the file and the usage given below.

#vi samba_password

username = administrator
password = ******
:wq
[root@vm1 ~]# smbclient -L 192.168.0.77 -A samba_passwd

### smbget ###
How to get a file from windows machine to linux samba server using smbget command?
smbget is a wget-like utility for download files over SMB
[root@vm1 ~]# smbget -u administrator -p redhat smb://192.168.0.77/chanku/samba_sambaget.txt
downloads samba_sambaget.txt to local system.

### smbtar ###
How to get all files in windows share archived to linux samba server?
smbtar is a shell script for backing up SMB/CIFS shares directly to UNIX tape drives or directories.

[root@vm1 ~]# smbtar -s 192.168.0.77 -u administrator -p redhat -t chanku.tar -v -x chanku
It will archive all the files and directories in share "chanku" and will download to local directory. Empty files will not be archived.

### Mounting a Windows Share to a Linux box ###
How to mount windows share to linux samba server using cifs?
[root@vm1 ~]# mount -t cifs -o username=administrator //192.168.0.77/chanku /mnt
mounts the remote windows share 192.168.0.77/chanku into local linux samba machine.

smbfs - rhel4
cifs - rhel5 common internet file system

###File masks and Directory masks###
[root@vm1 ~]# mount -t cifs -o username=administrator,file_mode=0777,dir_mode=0755 //192.168.0.77/chanku /mnt
will mount the share with file permissions 777 and directory permissions 755.

###Mounting Samba permanently###
How to mount a windows share to linux samba server permanently?
Goto /etc/fstab and add the entry for samba share as shown below
//192.168.0.77/chanku /mnt cifs defaults,username=administrator,password=redhat,file_mode=0777,dir_mode=0755 0 0

[FOR COMMUNICATING A WINDOWS MACHINE AND A SAMBA SERVER SMOOTHLY THEY SHOULD BE IN SAME WORKGROUP]

### Adding a SAMBA user ###
How to add a samba user to linux samba server?
#smbpasswd -a username
Give and verify password for username

### Configuring WINS Client For Samba ###
speed ups the resolution of netbios name to IP

Samba name resolution:
Default Order
1. /etc/hosts
2. /etc/samba/lmhosts
3. WINS - One or more IP Addresses
4. Broadcast 192.168.0.255

### Steps In windows ###
Installation:
Control panel -> Add/Remove programs -> Add/Remove Windows components ->
network services -> Windows Interent Name Service -> Install

Configuration:
Start -> Administrative tools -> WINS Check!

Control panel -> Network Connections -> Local Area Connection -> Properties ->
TCP/IP -> Advanced -> WINS tab

Add wins server IP
Ip of windows machine. Which we use as wins server.
Display records after restarting the smb service in linux box[steps below] and click find now

### Steps in linux ###
vi /etc/samba/smb.conf
Name resolve order = wins host lmhosts bcast
wins support = no
wins server = 192.168.0.60
#service smb restart

now when we execute
#smclient -v -U administrator -L linuxcbt2k3
gives the result fast because itstead of using broadcast search, it uses wins server for resolution.
-v for verbose. to check whether it is still using broadcast method.

### Share Level Security ###
Default is User level. We can change it in smb.conf file. as

security = user
or
security = share

in /etc/samba/smb.conf file
[public]
path = /public
public = yes It is to enable guest user mount in windows.
read only = yes

in output of #testparm
[public]
path = /public
guest ok = Yes

### SAMBA - SWAT ###
SWAT - Samba Web Administration Tool

### SWAT INSTALLATION ###
#yum install samba-swat

vi /etc/xinetd.d/swat

# default: off
# description: SWAT is the Samba Web Admin Tool. Use swat \
# to configure your Samba server. To use SWAT, \
# connect to port 901 with your favorite web browser.
service swat
{
disable = no //Change the 'yes' to 'no'.
port = 901
socket_type = stream //means tcp based
wait = no
# only_from = 127.0.0.1 //If not commented can be accessible only from localhost. increase security
user = root //In order to bind privillaged port 901
server = /usr/sbin/swat
log_on_failure += USERID
:wq

#service xinetd restart

### SWAT INTERFACE ###
Take any browser and give following url in address bar.
http://IP_of_samba_server:port_number_of_swat[901]
http://192.168.0.21:901

samba log files can be found in
/var/log/samba

### NETBIOS ALIASES ###
setting alias

access the global section in swat
goto advanced mode
netbios aliases [give names]
now you can access the aliases machine in many names.

### Blocking a particular user from accessing a share. ###
goto swat and take shares section
goto the advance mode
choose the share u want to modify
in invalid users field
give the user names u want to block with commas.

Restart the service
#service smb restart

How to install and configure Samba-swat in rhel5 linux / centos

Advertisements

### SWAT INSTALLATION ### For rhel5/ centos5
If you have a yum server configured, run the following command. else find the rpm and install.

#yum install samba-swat

Open the following swat configuration file
#vi /etc/xinetd.d/swat

# default: off
# description: SWAT is the Samba Web Admin Tool. Use swat \
# to configure your Samba server. To use SWAT, \
# connect to port 901 with your favorite web browser.
service swat
{
disable = no //Change the 'yes' to 'no'.
port = 901
socket_type = stream //means tcp based
wait = no
# only_from = 127.0.0.1 //If not commented can be accessible only from localhost. increase security
user = root //In order to bind privillaged port 901
server = /usr/sbin/swat
log_on_failure += USERID
:wq //Save and quit

#service xinetd restart //restart the service

### SWAT INTERFACE ###
accessing in browser

http://IP_of_samba_server:port_number_of_swat[901]
an example

http://192.168.0.21:901

Monday, March 22, 2010

Remote installation of centos linux using pxe with dhcp tftp and syslinux

Advertisements

PXE server helps to install the operating systems through network boot. Its very useful and very time saving.

This post tells how to configure a PXE Server in Redhat linux and other variants.
PXE Configuration

dhcp + tftp + syslinux

Install the packages
#yum -y install dhcp*
#yum -y install tftp*
#yum -y install syslinux*

Open the dhcp configuration file and add the following
[root@sysadmin ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
#

subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers                  192.168.1.1;
        option subnet-mask              255.255.255.0;
        option domain-search              "lukup.internel";
        option domain-name-servers       8.8.8.8;
        option time-offset              -18000;
    range 192.168.1.10 192.168.1.100;
    allow booting;
    allow bootp;
    next-server 192.168.1.254;
    filename "pxelinux.0";
}


Copy the pxlinux.0 file to /tftpboot
#cd /tftpboot
#cp /usr/lib/syslinux/pxelinux.0 .

Copy the kernel and initrd.img files from DVD[/media/images/pxeboot/] to /tftpboot/
#cp -rv /media/images/pxeboot/initrd.img .
#cp -rv /media/images/pxeboot/vmlinuz .

Add kickstart file to /tftpboot/
#vi ks.cfg Only if wanted. Otherwise you have to do attended remote installation.
nfs --server 192.168.1.2 --dir /media/rhel5 Just an example line!

 You need to modify the tftp configuration file under /etc/xinet.d as follows.

[root@sysadmin pxelinux.cfg]# cat /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
#    protocol.  The tftp protocol is often used to boot diskless \
#    workstations, download configuration files to network-aware printers, \
#    and to start the installation process for some operating systems.
service tftp
{
    disable    = no
    socket_type        = dgram
    protocol        = udp
    wait            = yes
    user            = root
    server            = /usr/sbin/in.tftpd
    server_args        = -s /tftpboot
    per_source        = 11
    cps            = 100 2
    flags            = IPv4
}
[root@sysadmin pxelinux.cfg]#

Create PXE configuration directory
#mkdir /tftpboot/pxelinux.cfg/
#cd /tftpboot/pxelinux.cfg/

Create PXE configuration file### That is ###/tftpboot/pxelinux.cfg/default file
#vi default
PROMPT 1 To give the prompt [boot: ]. Otherwise it will automatically install the default label
DISPLAY boot.msg It shows the 1st window for options.
TIMEOUT 100 Wait for the choice this much time and after that will continue with deafult.
DEFAULT main Defines the main installation method. The default one.
ONERROR LOCALBOOT 0

LABEL main The declaration of main label. In case if we didint give choice, this will execute.
KERNEL vmlinuz If in /tftpboot/ directory. If it is in /tftpboot/RHEL5-NFS u've to give RHEL5-NFS/vmlinuz
APPEND initrd=initrd.img Path of initrd.img.
LABEL 1
KERNEL Kernel location of choice 1 in boot.msg
APPEND Location of initrd.img

An Example
kernel RHEL5-NFS/vmlinuz
append initrd=RHEL5-NFS/initrd.img ramdisk_size=6457 method=nfs:192.168.1.2:/media/rhel5 ip=dhcp
LABEL 2
settings for option 2.
:wq

###Creating options message for the PXE boot###
#cd /tftpboot/
#vi boot.msg
##########################
Installing RHEL5 You can design this as you like.
##########################

1. RHEL5 NFS
2. RHEL5 FTP Set all these according to the entries in /tftpboot/pxelinux.cfg/default
3. RHEL5 HTTP
4. RHEL5 RESCUE

##########################

NOTE: Give execute permission for all files in /tftpboot/

###Restart the services###
#service dhcpd start
#service xinetd start
#chkconfig tftp on

Another example is:
[root@sysadmin pxelinux.cfg]# cat default
DISPLAY boot.msg
PROMPT 1
TIMEOUT 100
DEFAULT main
ONERROR LOCALBOOT 0

LABEL main
kernel vmlinuz
APPEND initrd=initrd.img network ks=nfs:192.168.1.254:/media/kick/ks.cfg

LABEL 1
kernel vmlinuz
APPEND initrd=initrd.img network ks=nfs:192.168.1.254:/media/kick/ks.cfg


Useful links
http://www.linuxhelp.in/2012/02/remote-installation-of-centos-linux.html
http://www.linuxhelp.in/2012/02/lets-see-how-to-install-configure-dhcp.html
http://docs.fedoraproject.org/install-guide/f7/en_US/ap-pxe-server.html
http://syslinux.zytor.com/wiki/index.php/PXELINUX

Saturday, March 20, 2010

How to setup xen virtual machine in rhel5 / centos5

Advertisements

Xen is a virtualization software/ virtaul machine or virtual private server used in linux platform as VMware, Virtuzzo, openVZ, Parallelz etc. It decreases the need of dedicated machines. It is easy to configure. See the steps below!

First we have to check whether the processor support virtual machines or not
#cat /proc/cpuinfo
flags : pae

PAE is Physical Address Extension.

[or Processor with Intel VT technology]

##3Installing xen Virtual private server###
This is using a yum server. If you dont have a yum server configured, install the needed rpms.

yum -y install xen* kernel-xen*

7 packages will be installed

kernel-xen
kernel-xen-devel
xen
xen-devel
libvirt
libvirt-python
python-virtinst

#yum -y install virt-manager /if not installed

###Change in grub.conf###
default=0 /Edited grub.conf n made xen boot 1st.
restart
[otherwise you can select the xen kernel from grub menu while booting]

###Installation of Virtual Machine###
Two installation methods
[just execute the following command in terminal for graphical installation]
#virt-manager
[just execute the following command in terminal for text installation]
#virt-install


###In text mode install###

virt-install must be run as root and, once invoked, will ask a number of questions before creating the guest system. The question are as follows:

What is the name of your virtual machine? - The name by which the guest system will be referenced when managing and monitoring the system with other tools.

How much RAM should be allocated (in megabytes)? - The amount of system memory to be made available to the guest operating system.

What would you like to use as the disk (path)? - The path to the file or disk partition to be used to contain the guest operating system.

Would you like to enable graphics support? (yes or no) - Defines whether the graphical installer is used (in a VNC window) or the text based installer in the shell.

What is the install location? - The location of the installation files for the OS. This can be an ftp, nfs, http, ISO image or local CD or DVD device location.

###Commands###
For listing Domain and virtual instances
#xm list

For starting a virtual machine
#xm create vm_name
#xm console vm_name

For shutting a virtual machine
#xm destroy vm_name

How to configure or setup VNC server in linux rhel5 / centos5

Advertisements

Sometimes we need to access remote servers. Most times we just ssh into them. But what if we required graphical access. VNC server comes there. It helps us to login to remote server graphically. Just as in remote desktop in Windows. VNC is Virtual network Computing.

How to Configure a VNC server In linux?
###VNC Server configuration###
#yum -y install vnc*

For using this we need to setup a password for the server. We can set it by the linux command vncpasswd.
###Set the password###
#vncpasswd

###Restart the service###
#service vncserver start

To make VNC server we need to run the following command. While executing it. it will create some files.
###Run the server command###
#vncserver
or
#vncserver :13 The display number. Default will be one. If available.

This file will be generated when executing the above command. We need to do a small change in that in order to make it was server.
# vi .vnc/xstartup
uncomment the following lines.
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

#service vncserver restart

###VNC Client configuration###
[Accessing the VNC server from the client]
###Run the vncviewer command###
#vncviewer
Server : 192.168.1.101:2 Give the IP of Server with the display ID
Password: ****** Give the password

Its over. Have fun


###Installation through VNC###

boot: linux vnc vncpassword=redhat ip=192.168.1.101 netmask=255.255.255.0 gateway=192.168.1.10 //if more than one ethernet device is present u have to select one from them. But no need to configure the ips again.

language selection
network selection //if more than one is present

client
vncviewer ip:1
password: redhat

If you are getting grey screen when login via vnc, configure the vnc as follows.


[root@server ~]# cat /root/.vnc/xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &
#twm &
[root@server ~]#


Kill all the processes associated with vnc and restart the service and execute vncserver command again.
done!!

How to configure disk qouta in centos linux

Advertisements

Quota is used for limiting the disk usage for users or groups.

To verify that the quota is enabled in the kernel
#grep CONFIG_QUOTA /boot/config-`uname -r`

CONFIG_QUOTA=y -enables limit on usage
CONFIQ_QUOTACTL=y -associated with disk quota manipulation.

If you have custom or upgraded kernel. Enable quota by running any of the following commands.
#make menuconfig
#make gconfig
#make xconfig

Check the quota package
#rpm -q quota

[root@server ~]# rpm -q quota
quota-3.13-1.2.3.2.el5
[root@server ~]#


For using Quotas the partition we are using for quota [quota can only be used per partition.] should be mounted with quota options. For that go to /etc/fstab and edit the partition mount options.

#vi /etc/fstab
LABEL=home /home ext3 defaults,usrquota,grpquota 1 1
:wq

If the partition is already mounted remount it for affecting changes in mount options.
#mount -o remount /home

Check the filesystem is mounted with changed options. If not, you may have to umount and mount again or u've to restart the system.
#mount -to check
Device_name on /mount_point type ext3 (rw,usrquota,grpquota)

Create quota database
#quotacheck -mcug /home
[ If you are using quotacheck -cug, it will throw an error that it cannot remount the filesystem mounted on m_point so counted values might not be right. Please stop all the programs writing to filesystem or use -m flag to force checking. This will happen when we use the filesystems like "/". Many processes are writing into "/" that time. Thats why it is throwing this error.]

-c option specifies that the quota files should be created for each file system with quotas enabled.
-u option specifies to check for user quotas.
-g option specifies to check for group quotas.
If not, those files will be created.

quotacheck -mcug /home -will create following files in /home
aquota.group
aquota.user

Assign quota policies for user
#edquota username
#quota username -shows the quota for set for that user

Assign quota policies for group
#edquota -g groupname -think a user should exist with that group
#quota -g groupname -shows the quota for set for that group

Defining prototypical users
edquota -p user1 user2

To see all user qouta reports
#repquota -a

To see the user quotas in /home
#repquota -u /home
To see the group quotas in /home
#repquota -g /home
To see the quotas in appropriate size
#repquota -s /home -shows used space and hard limit in MB
To check the quota is on or not
#quotaon -v /home

To update the usage
#quotacheck -mavug -execute this often for knowing latest usage info. Put it in cronjob. may need -f option.
[This will check all the files and directories in all partitions which is mounted with quota options.]
-a Check all mounted non-NFS filesystems in /etc/mtab
-v Verbose. Displays the information as it proceeds.
-u Checks for the user quotas.
-g Checks for the group quotas.


Add quotacheck to daily cron
# cat /etc/cron.daily/quotacheck
quotacheck -avug


Setting grace period
#edquota -t
10days not 10 days.

To enable and disable the qoutas
#quotaon -vaug with -m if needed. For only one partition; quotaon -vug /home
#quotaon -vaug -will turn on all the quotas [group and user]
#quotaoff -vaug -will turn off all the quotas [gruop and user]

How to schedule jos in linux using cron in rhel5 or centos5

Advertisements

Cron job is a job scheduling utility. If we configure a cron job to run on certain time, cron will run it according to the configuration.

These are the packages needed to install cron job.
###Packages :###
vixie-cron
crontabs
anacron

### Service ###

/etc/init.d/crond

###vixie-cron installs the services and man pages:###

[root@server ~]# rpm -ql vixie-cron
/etc/cron.d
/etc/pam.d/crond
/etc/rc.d/init.d/crond
/etc/sysconfig/crond
/usr/bin/crontab
/usr/sbin/crond
/usr/share/man/man1/crontab.1.gz
/usr/share/man/man5/crontab.5.gz
/usr/share/man/man8/cron.8.gz
/usr/share/man/man8/crond.8.gz
/var/spool/cron

###crontabs installs main configuration Directories:###

[root@server ~]# rpm -ql crontabs
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
/etc/crontab
/usr/bin/run-parts

### anacron installs 0anacron scripts ###

[root@server ~]# rpm -ql anacron
/etc/anacrontab
/etc/cron.daily/0anacron
/etc/cron.monthly/0anacron
/etc/cron.weekly/0anacron
/etc/rc.d/init.d/anacron
/usr/sbin/anacron

/usr/share/doc/anacron-2.3
/usr/share/doc/anacron-2.3/COPYING
/usr/share/doc/anacron-2.3/README
/usr/share/man/man5/anacrontab.5.gz
/usr/share/man/man8/anacron.8.gz
/var/spool/anacron

### Scheduling a cron job ###
Log in as the user who you want to execute the job.

#crontab -e //This will open a file in which u can specify Cron jobs. Press "i" for insert mode.

Cron job has a special format. It has six fields

Min Hour Date Month Day Program
[0-59] [0-23] [1-31] [1-12] [0-7] command
Jan,Feb Sun,Mon
Etc etc
0=7=Sun
[You can configure multiple jobs in next line(line by line)]
[save the file]
:wq

Example 1:
Suppose you want to run a job on February 19th at 10:35am. Job is creating a directory named test_cron under "/".

35 10 19 2 * mkdir /test_cron
Min Hr Date Month Every Day job

"*" Symbol in a field represents all valid values.

Example 2:
Multile values can be separated by commas.

0,15,30,45 * * * * touch /abc

This will update timestap of "/abc" in every 0th, 15th, 30th, and 45th minute of every hour. Every date, every month, every day of week.

Example 3:
Suppose you want to run a job every week days at 5 pm. Eg: Shutdown system everyday at 5 pm.

0 17 * * 1-5 init 0

Example 4:

*/15 * * * * who

The above line will run the "who" command every 15th minute, of every hour, of every
month, for all days of the week.


### Other crontab commands ###

#crontab -l //This will list the cron jobs of the logged user.
#crontab -u user_name -l //This will list the jobs of the user user_name.
#crontab -r //This will remove the users cron jobs.

All jobs will be saved in "/var/spool/cron/"
Normal users do not have access to that directories.

### Main Directories and Files ###

/etc/cron.deny //Contains the list of restricted users to schedule jobs.
/etc/cron.allow //Contains the list of allowed users to schedule jobs.

### Access Control ###

1.If both cron.deny and cron.allow do not exist, Only root user can schedule jobs.
2.If only cron.deny exists, all users excepts the users listed in cron.deny can schedule jobs.
3.If only cron.allow exists, root and listes users can schedule jobs.
4.If both files exits, then cron.deny will be ignored.

### Main directories in /etc ###

/etc/crontab runs and controls the executables in following direcotries.

1./etc/cron.hourly //Contains the files that are scheduled to be run hourly.
2./etc/cron.daily //Contains the files that are scheduled to be run daily.
3./etc/cron.weekly //Contains the files that are scheduled to be run weekly.
4./etc/cron.monthly //Contains the files that are scheduled to be run monthly.
5./etc/cron.d //Contains the additional system crontab files.

An example /etc/crontab file

[root@server ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

Hourly jobs will execute at 1st minute of every hour, every date, every month, every week day. As root user. Run-parts is a script which run the jobs.
Daily jobs will execute at 4:02am everyday.
Weekly jobs will execute every Sunday at 4:22am
Monthly jobs wll execute every 1st day of month, at 4:42am

Example 5:
Suppose you want to run a few jobs in every two days

Create a directory "/etc/cron.2days with permission 755. And copy all the jobs to that directory.

#mkdir -m 755 /etc/cron.2days

And create and configure an entry for /etc/cron.2days in /etc/crontab

* * * * 0,2,4,6 root run-parts /etc/cron.2days

Restart the crond service.


### The Anacron System ###

The anacron runs the cron jobs that did not run when the computer is down. The daily jobs runs at 4:02am. At that time most computers [Eg Laptops] will be down. Anacron runs these non executed jobs when the system is up.

### Configuration File ###

/etc/anacrontab

There are four fields in each entry:

Period Delay Job-identifier Command

The period is specified in days, the delay in minutes. The job-identifier can contain any non-blank character, except slashes. It is used to identify the job in Anacron messages, and as the name for the job's timestamp file. The command can be any shell command.

An example /etc/anacrontab:

[root@server etc]# cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

1 65 cron.daily run-parts /etc/cron.daily
7 70 cron.weekly run-parts /etc/cron.weekly
30 75 cron.monthly run-parts /etc/cron.monthly
[root@server etc]#

1st entry means, if the jobs in /etc/cron.daily have not been run in one day, it will wait 65 minutes after reboot and then runs it.

### How Anacron works:###

When Cron runs the run-parts command from /etc/crontab for cron.daily, cron.weekly, and cron.monthly, the first command to run is 0anacron. This command sets a timestamp in a file in /var/spool/anacron thats notes the time that this was last run.

On boot-up, the anacron command runs. The anacrontab file specifies how often the commands in cron.daily, cron.weekly, and cron.monthly should run. If they have nto run in this time, the anacron waits a few minuts as specified in second field of anacron entry and run the commands.

How to configure kickstart with remote installation in rhel5 [kickstart + dhcp] or centos5

Advertisements

KickStart [Unattended Installation]
When installing linux we have to sit if front of the system and answer the questions whenever it asks. This process is time consuming and needs one to attend while installation take process.Kickstart helps to install system unattended. We can create an answer file and notify the system to take the answers from the file. The file is known as kickstart file. We can configure dhcp such a way that it will automatically provide the system the path and details of the kickstart file in the network .In windows systems kickstart file is known as answer file. In this post we will see howto configure kickstart server linux step step and doing the remote installation using kickstart.

it is advised to read the remote installation post if you dont have much idea about remote installation.
These are the steps happening.
Server[dhcp+ks] client
1. asks IP and location of kickstart file
2.gives the info
3. Takes the ks.cfg file and mounts share of OS

How to configure Automounter in rhel5 or centos5

Advertisements

###Automounter###

###Service: autofs###
#service autofs start

###Main configuration file###
/etc/auto.master

###Sub configuration files###
/etc/auto.misc For CD,Floppy etc.
/etc/auto.direct For the directories starting with"/".

###Adding a automount share###
#vi /etc/auto.master

Goto the following lines
/misc /etc/auto.misc
/net -hosts

Add this lines after the above lines
/- /etc/auto.direct
:wq

Suppose u want to automount /media/rhel5 @ 192.168.1.2 to /remote in your local

machine

#mkdir /remote

#vi /etc/auto.direct
/remote 192.168.1.2:/media/rhel5
:wq

#cd /remote
NFS share will be mounted automatically when u execute cd command to /remote. It will

be automatically unmount if you are not using the share for a particular amount of time.

You can set this time as shown below.

in /etc/auto.master file
/- /etc/auto.direct --timeout=60 Time is in seconds.