Sunday, July 29, 2007

MMC Snap-ins

Following is a list of MMC (Microsoft Management Console) snapins which you can launch from Start -> Run

MMCDescription
certmgr.mscCertificate Manager
ciadv.mscIndexing Service
compmgmt.mscComputer management
devmgmt.mscDevice Manager
dfrg.mscDisk Defragment
diskmgmt.mscDisk Management
fsmgmt.mscShared Folders Management
eventvwr.mscEvent Viewer
gpedit.mscGroup Policy
lusrmgr.mscLocal Users and Groups
ntmsmgr.mscRemovable Storage
perfmon.mscPerformance Manager
secpol.mscLocal Security Settings
services.mscSystem Services
wmimgmt.mscWindows Management Instrumentation Manager


This information is based on Windows XP Professional/2003

Control Panel Applets

Many components of Control Panel can be launched from Start->Run independantly. All of these components have the extention 'cpl'. These independant components are called control panel applets.
AppletDescription
access.cplAccessibility Options
hdwwiz.cplAdd New Hardware Wizard
appwiz.cplAdd/Remove Programs
timedate.cplDate and Time Properties
desk.cplDisplay Properties
inetcpl.cplInternet Explorer Properties
joy.cplJoystick/Game Controller Properties
main.cpl keboardKeyboard Properties
main.cplMouse Properties
ncpa.cplNetwork Connections
telephon.cplPhone and Modem options
powercfg.cplPower Management
intl.cplRegional settings
mmsys.cpl soundsSound Properties
mmsys.cplSounds and Audio Device Properties
sysdm.cplSystem Properties
nusrmgr.cplUser settings
firewall.cplFirewall Settings (sp2)
wscui.cplSecurity Center (sp2)


This information is based on Windows XP Professional/2003

Application shortcuts from RUN

These application shortcuts will help you to launch many of the commonly used windows utilities from the Run option of start menu.

ShotrcutDescription
calcCalculator
charmapCharacter Map
cleanmgrCleans up hard drives
clipbrdWindows Clipboard viewer
cmdOpens a new Command Window (cmd.exe)
controlDisplays Control Panel
control printersPrinters and Faxes
drwatsonRecords programs crash & snapshots
dxdiagDirectX Diagnostic Utility
explorerWindows Explorer
ftpftp.exe program
iexploreInternet Explorer
inetmgrIIS Manager
mmcMicrosoft Management Console
msconfigConfiguration to edit startup files
msinfo32Microsoft System Information Utility
regeditRegistry Editor
syseditEdit system startup files (config.sys, autoexec.bat, win.ini, etc.)
taskmgrTask manager
sfc /scannowSystem File Checker
sndrec32Sound Recorder
sndvol32Volume control for soundcard


This information is based on Windows XP Professional/Windows 2003

Sunday, June 24, 2007

Creating Virtual File Systems in Linux

When you want to test some configuration involving file systems, its not always possible to use a live running system. In such situations it is a good idea to create a virtual filesystem in your hard disk, which will not affect the operation of your machine, except for occupying the hard disk space that you need.

The first step is to create an empty directory as the mount point for the virtual file system.
[root@LinuxBox1 ~]#mkdir /vfsmount

Now we have to create the virtual file system image. Here we will create a file vfs-image in the directory /var/vfs. This file will hold the virtual file sytem.
[root@LinuxBox1 ~]#mkdir /var/vfs

We will create a file system with a size of 100MB. For this we will have to create the file vfs-image with 100MB size.
[root@LinuxBox1 ~]#dd if=/dev/zero of=/var/vfs/vfs-image count=204800
204800+0 records in
204800+0 records out
104857600 bytes (105 MB) copied, 2.3716 seconds, 44.2 MB/s

The count option indicates how many blocks of data should be filled in the file vfs-image. By default 1 block= 512 bytes
1 MB= 512 x 2 x 1024=2048 Blocks
100 MB = 2048 x 100 Blocks = 204800 Blocks

To cross check this
[root@LinuxBox1 ~]#du -h /var/vfs/vfs-image
101M /var/vfs/vfs-image

Now format this file as an ext3 filesystem
[root@LinuxBox1 ~]#mkfs.ext3 -q /var/vfs/vfs-image
/var/vfs/vfs-image is not a block special device.
Proceed anyway? (y,n) y

'mkfs.ext3' is actually a short form for 'mkfs -t ext3'. You can avoid the warning regarding the file not being a block device by using the '-F' option

Now, to use this file system we will have to mount it. To make this mount permanent add an entry into fstab as follows

/etc/fstab

/var/vfs/vfs-image /vfsmount ext3 rw,loop 0 0

The loop option asigns an availiable loop device to the file system.

[root@LinuxBox1 ~]#mount -a
[root@LinuxBox1 ~]#mount|grep vfs-image
/var/vfs/vfs-image on /vfsmount type ext3 (rw,loop=/dev/loop0)
[root@LinuxBox1 ~]#df -h|grep vfs-image
/var/vfs/vfs-image 97M 5.6M 87M 7% /vfsmount

Now just to demonstarate that we can use this filsystem in the same way as other filesystems:
[root@LinuxBox ~]# cd /vfsmount/
[root@LinuxBox ~]# mkdir temp

Now create a 5MB sized file

[root@LinuxBox vfsmount]# dd if=/dev/zero of=/vfsmount/temp/test-space-usage count=10240
10240+0 records in
10240+0 records out
5242880 bytes (5.2 MB) copied, 0.129863 seconds, 40.4 MB/s

Check the filesystem usage
[root@LinuxBox vfsmount]# df -h|grep vfs-image
/var/vfs/vfs-image 97M 11M 82M 12% /vfsmount

Wednesday, May 23, 2007

Job scheduling with cron

Cron is the task scheduling daemon in linux. The daemon is called 'crond' and the program that manipulate cron jobs is 'crontab'. Once the daemon is started, it goes into sleep and wakes up every minute to examine all the files containing crontab entries. If a job is scheduled to run at the current minute, it will be executed and the daemon will go back to sleep.

A user can manipulate the cronjobs for his account using the command 'crontab'. Some security restrictions are imposed on use of this command with two files /etc/cron.allow & /etc/cron.deny.

If the file /etc/cron.allow exists, the user should be listed in that inorder to run crontab. If this file doesnt exist the user should not be listed in /etc/cron.deny to run crontab. If both the files does not exist, no users other than root is allowed to use crontab.

Cron jobs for individual users are stored in a seperate text file /var/spool/cron/username which is edited by corresponding user with the command 'crontab -e'

The system wide crontab configuration file is /etc/crontab. What this does is run the cronjob files under a set of directories.

/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


As the name of the directories indicate, the files inside the directories are inspected by cron once every hour, day, week and month. The files insied this directories will be in the standard cronjob format as indicated below.

For per user crontab files (/var/spool/cron/username) the format is:

minute hour day month dayofweek command-to-be-scheduled

For all other crontab files the format is

minute hour day month dayofweek USER command-to-be-scheduled


Values for each field:


minute: 0-59
hour: 0-23
day: 1-31
month: 1-12 (or short names as jan,feb,jun etc can be used)
dayofweek: 0-7 ( or short names as sun, mon,fri etc; 0 & 7 represent Sunday )

For all these fields following rules apply:

Asteric (*) in any field indicate all applicable values for that field.
A hiphen (-) between two digits specify all the values in between inlcuding the two.
A comma seperated list specify all the values listed.

Eg:

10 9 * * 0 = 10:10 AM every sunday
0 10-17 * * * = Everyday at 10AM, 11AM..5PM
15,30,45 9 * * * = Everyday 9:15 AM, 9:30AM and 9:45 AM
*/5 * * * * = Every 5 minutes

USER: the user account under whose privilege the cron job should be run.

The command to execute can be a standatd linux command or a script. Whatever thing that can be executed in shell can be substituted here.

At the starting of the file, we can set the environemnt variables under which the cron job should run. Comments can be inserted with '#'. You can see both these in the /etc/crontab example above.

The script `run-parts` that you see in the crontab file is a standard script that takes a directory as its argument and run all the binaries under that directory.

Individual users can manipulate only their personal crontab file. All other files are managed by root.

In addition to the directories mentioned above, there is one more directory /etc/cron.d. If you want to run task at a custom time, ie not every hour/day/week/month the files should be put in this directory.

crontab command

For individual users to manipulate their cronjobs, use the command crontab.

To add a new job or edit an existing:
[safeer@LinuxBox1 ~]$crontab -e

This will open /var/spool/cron/safeer in the default editor. Now the user can edit this file just like any text file.


To add a job to run a script under the home directory to run at 10 minutes after 10 AM every day

10 10 * * * ~/bin/backup.sh >> backup.log 2>&1

To view safeer's current crontab entries:
[safeer@LinuxBox1 ~]$crontab -l
10 10 * * * ~/bin/backup.sh >> backup.log 2>&1


To remove all the cuurent cron jobs for safeer:
[safeer@LinuxBox1 ~]$crontab -r


The root user can edit anu users cronjob with the -u switch. With this command root can edit the croontab for user safeer:
[root@LinuxBox1 ~]#crontab -[e/l/r] -u safeer

The service name for cron is crond. Use this to start or stop the service. You will hardly need to do this ever.
[root@LinuxBox1 ~]#service crond restart