Monday, May 17, 2010

SUDOERS RPM INSTALLATION in AIX

1. Download the rpm file needed to install the sudoers package in AIX
http://www.bullfreeware.com/download/wpar_tt/listaixopensourcerpms.html
Search for the file sudo-1.6.7p5-3.aix5.1.ppc.rpm and download it

2. Copy the downloaded file to the AIX servers /tmp/SUDO directory

3. change the permission to chmod 777

4.smitty install-> Install and Update Software-> Install Software-->INPUT device / directory for software [.]#current directory
SOFTWARE to install (Press Esc+F4 which displays the rpm file in the directory)
ACCEPT new license agreements? Yes
and press enter to install the rpm File on your machine

5. Configuring logs for Sudo

vi /etc/sudoers

place an entry @ the end of the file

Defaults log_year,logfile=/var/log/sudo.log

SUDOERS FILE SAMPLE

# visudo

------------------------------------------------------------------------------------------
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# User privilege specification
root ALL=(ALL) ALL
sound ALL=(ALL) ALL
uday ALL=(ALL) ALL
sandeep ALL=(ALL) ALL
neha ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now

Defaults log_year,logfile=/var/log/sudo.log

#Defaults syslog=auth

----------------------------------------------------------------------------------------------------

6.Enter visudo command to view and putting an entry of the users in the /etc/sudoers quit it by saving it.
7. Login into the userlogin by opening a duplicate session of su and enter sudo -s for sudo -s login credentials.
8. Finally check the log file

# more /var/log/sudo.log
May 14 18:37:20 2010 : sound1 : TTY=pts/1 ; PWD=/home/sound1 ; USER=root ; COMMAND=/usr/bin/ksh
May 14 18:50:06 2010 : uday : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/bsh
May 14 19:23:34 2010 : sound1 : TTY=pts/3 ; PWD=/home/sound1 ; USER=root ; COMMAND=/usr/bin/ksh
May 17 14:23:05 2010 : sound1 : TTY=pts/2 ; PWD=/home/sound1 ; USER=root ; COMMAND=/usr/bin/ksh
May 17 14:27:56 2010 : neha : TTY=pts/2 ; PWD=/home/neha ; USER=root ; COMMAND=/usr/bin/ksh
May 17 14:30:45 2010 : neha : TTY=pts/2 ; PWD=/home/neha ; USER=root ; COMMAND=/usr/bin/ksh
May 17 14:31:49 2010 : sandeep : TTY=pts/2 ; PWD=/home/sandeep ; USER=root ; COMMAND=/usr/bin/ksh

This is the way to use the sudoers in AIX.

Wednesday, April 7, 2010

simple script to zip / rar it in command line




#########################################################
# Script to ZIP the file and NULL the previous Log file #
#########################################################

ZIPing the file

cd "D:\Program Files\WinZip\"
winzip32 -min -a -en -r C:\Backup1\rbb__%date:~7,2%-%date:~4,2%-%date:~10,4%.zip C:\Backup1\rbb.txt
cat /dev/null > C:\Backup1\rbb.txt


RARing the file

cd "C:\Program Files\WinRAR"
Rar a D:\rob__%date:~7,2%-%date:~4,2%-%date:~10,4%.rar D:\rob.txt
cat /dev/null > D:\robocopy.txt

Friday, January 15, 2010

ROLLBACK SCRIPT ON AIX





AIX TL/ML Reject Script ( In applied state)

Rollback
D=/tmp;installp -s | awk '{print $1"\t" $3 }'>$D/AIX.REJ;installp -rgX -f $D/AIX.REJ;rm $D/AIX.REJ &

Rollback Preview
D=/tmp;installp -s | awk '{print $1"\t" $3 }'>$D/AIX.REJ;installp -rpg -f $D/AIX.REJ;rm $D/AIX.REJ &

Details of the Script
# Assigning tmp directory to D
# Moving the file list in applied state to AIX.REJ file by filtering 1st and 3rd column of the output installp -s in tmp directory
# Rollback with the help of the command with the file list available in AIX.REJ
# Removing the file AIX.REJ