How to create automatic home directories in Solaris 10

To achieve automatic home-directory creation in solaris is little bit difficult. If it is NFS/NIS, we can achieve this through autofs(auto_mater) method. I saw many other post saying that they have achieved this with LDAP by using scripts. I Tried the same method with scripts and it didn’t worked for me.


There is another way we can achieve this by using pluggable authentication modules(PAM).Compared to linux, solaris PAM is very limited and there is not much modules on it.


Here is the summery :


1. installed sun studio( To get gcc and other development tools)
2. compiled Linux PAM modules on solaris
3. copied the modules to security directory
4. included module in /etc/pam.conf


Download and install Solaris Studio :


Download and extract Linux PAM modules :


export PATH


cd /var/tmp/Linux-PAM-0.81
cp _pam_aconf.h libpam/include/security
cd modules/pammodutil
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -Iinclude modutil_cleanup.c
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -Iinclude modutil_ioloop.c
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -Iinclude modutil_getpwnam.c -D_POSIX_PTHREAD_SEMANTICS
cd ../pam_mkhomedir
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -I../pammodutil/include pam_mkhomedir.c
ld -o -B dynamic -G -lc pam_mkhomedir.o ../pammodutil/modutil_*.o
cp /usr/lib/security/
cd /usr/lib/security
ln -s


finally comment /home in /etc/auto_master file


restart autofs:
svcadm disable autofs
avcadm enable autofs


include in /etc/pam.conf


other session required skel=/etc/skel/ umask=0022

Linux Shell Script For Monitoring System network with ping command

Here is a simple script to monitor server IP status with lock. Script will send only 1 email when IP is not reachable.If it came back, it will send another mail



while true
CS=$(ping -c $COUNT $SERVER | grep ‘received’ | awk -F’,’ ‘{ print $2 }’ | awk ‘{ print $1 }’)
if [ $DEBUG -eq 1 ]
echo “STATUS = $CS”
if [ $CS -ne 0 ]
echo “$SERVER is up”

elif [ $CS -eq 0 ]
echo “$SERVER is down”
if [ $CS -ne 0 ] && [ $FAILED -eq 0 ]
if [ $DEBUG -eq 1 ]
echo “$SERVER is back up”
if [ $DEBUG = 0 ]
echo “$SERVER is came up at $(date)” | /bin/mailx -s “$SERVER is came up at ” -r “$SENDEREMAIL” “$NOTIFYEMAIL”
elif [ $CS -eq 0 ] && [ $FAILED -eq 1 ]
if [ $DEBUG -eq 1 ]
echo “$SERVER failed”
if [ $DEBUG = 0 ]
echo “$SERVER went down $(date)” | /bin/mailx -s “$SERVER went down ” -r “$SENDEREMAIL” “$NOTIFYEMAIL”
sleep $PAUSE


Automount samba shares from fstab

To Configure Automount of Cifs/Smbfs (windows share) ,make sure you installed cifs-utils add the share details to /etc/fstab


Samba share , password protected shares
//host/share /mnt/share cifs defaults,credentials=/etc/fstab_credentials 0 0


And add the authentication detais to /etc/fstab_credentials. If the file not there, create one with below details




After that issue mount -a to re-read fstab


Redhat -6 Local and Online Repo creation script

Hi Friends.


I was testing some backup software’s, each day i used to create separate Virtual Machine on my Vmware. After installation of RHEL 6, configuring local and online repos are my first job (I am bit lazy to do this every time).


For that i created a shell script to do this things automatically.


I am not a scripting expert. Here is my script. I tested with Rhel6 only


To convert MIDI files into Arduino sketches

The intention of this experiment to play MIDI tones by using Arduino. This is very easy with some resistors and one speaker.

The components which used are:

1. Arduino UNO

2. Three 470 Ohm Resistors

3. one speaker/buzzer


First thing we need to take some midi sound files .eg:  This is James Bond movie tone.Next thing we need to convert it into Arduino Sketch. For that we need one special software called Miditones. Download latest MidiTones .exe file. This is a command line utility. create one folder and copy-paste Miditones.exe and .midi file which we downloaded earlier .


Some Useful Linux Commands

  1.  Linux Sed command to change values inside file

# sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config


  1. PERL script to check Linux machine type

# perl -MConfig -e ‘print “$Config{myarchname}\n”;’


  1. To check Fibre cable status – Simple script
ls /sys/class/fc_host | while read i; do
echo $i
cat /sys/class/fc_host/$i/port_state


Linux Tips and Tricks

Delete files that are ‘X’ days old

Sometimes ins linux, you want to clear out older files in a directory. One example could be if you have a security system and it continuously writes video files to a directory on your NAS until it fills it have figured out that it keep a week’s collections of videos, there will be plenty of space for other users. So, here is a command that will delete all files that are older than seven days . So remember to execute this command with caution as it can delete your important data if not used correctly


#find /path/to/files/ -type f -mtime +7 -exec rm -rf {} \;


find : This command will search for files.
/path/to/files : This is the top level directory to start searching
-type f : This ensures we don’t remove directories , but only files.
-mtime +7 : Removes files older than ‘7’ days. Change to ‘+14’ to delete files older than two weeks.
-exec : This indicates what to do with files we found.
rm -rf  :  Removes the files recursively and forcefully.
{} : This represents each file we find.
\; : This is the end of exec.
On successfully testing the above command you can create a Cron job to automate this task