Wednesday, September 2, 2015

RHEL 7 - Configure NTP client on your system


RHEL 7, you cna use chrony rather than standard ntp package

1. Install chrony
# yum install chrony

2. Configure chrony
# vi /etc/chrony.conf

server 192.168.10.110 iburst

3. Restart the service
# systemctl enable chronyd
# systemctl start chronyd


4. Verify the reach level
# chronyc sources -V
# chronyc tracking

RHEL - Autofs mount entry

Autofs mount

$ more /etc/auto.master
+auto.master

#/home   /etc/auto.home     --timeout 60
/-      /etc/auto.direct   --timeout 60


$ more /etc/auto.direct
# Mount hector for NFS shares
/repo_tmp      -rw,soft,intr,tcp,noatime   server1:/data/repo_tmp
/archive          -rw,soft,intr,tcp,noatime   server2:/data/archive
/backup          -rw,soft,intr,tcp,noatime   server3:/data/backup

RHEL7 - Crontab Example

1. Add cron entry for a root user
# crontab -e
23    22    *    *    *    /bin/echo    "Hello, World !!!"

2. Add cron entry for a user
# crontab -eu sarah
23    14    *    *    *    /bin/echo    "hyer"
3. To deny a user from running cron
# vi /etc/cron.deny
john

# systemctl status crond
# systemctl enable crond
# systemctl start crond

3. Login as a deny user and run the crontab -l, you should get permission deny error
# su - john
$ crontab -e

Truss command

There was issue with DHCP server, to find the root cause of the issue and find the resolution, we had to do following,

1. Run truss command
# truss -f -v all -r all -w all -o /var/tmp/dhcp.out -p $ALL_QIP_PIDs

2. List qip processes
# ps -ef|grep qip

3. Run snoop
# snoop -o /var/tmp/snoop.cap not port 22

4. reproduce the problem
5. kill both truss and snoop
6. restore the services

List files not owned by a particular user


Listing files that are not owned by Oracle user.

# cd /opt/oracle
# find . ! -user oracle -ls | more

for aix
# find . -type f -size +40960 -print | xargs ls -l | sort -nk 5 | tail -50




Script: Find files without group read permission and give read permission to group

#!/bin/bash
# find files without group read permission and assign group read permission
#
S_PATH=/tools/archive/data_archive/MHRD

# condition check the search path
if [ ! -d ${S_PATH} ]; then
echo "Error " Please check the search path. ${S_PATH} dir does not exist"
exit 1
fi

# search command
/usr/bin/find ${S_PATH} -type f ! -perm -040 -exec /usr/bin/chmod g+r {} \;
# EOF

Tuesday, September 1, 2015