#!/usr/bin/ksh
## This is a simple script to check if the file exists in a dir or not
## Created by : Arvind Reddy
## This will prompt for
echo " file name please : "
read FILENAME;
export dataDir=/u01/app/oracle/dpump; ## change this to directory you want check the file
sourceFile=SCOTT.dmp; ## Filename you want to check for
cd /u01/app/oracle/dpump;
echo `pwd`
##Did we get a file?
if [ -e ${dataDir}/${sourceFile} ];then
echo "Found file !! "
else
echo " No file found !!! "
fi
“Knowing others is intelligence; knowing yourself is true wisdom. Mastering others is strength; mastering yourself is true power.” Arvind Toorpu
Sunday, April 17, 2016
copying files from host OS to guest OS on Virtual Machine
On virtual box Guest OS click on devices and select shared folder as bellow screen
Then select the folder on your Host machine's directory that you want to share between host
and guest OS.
Once you have selected the right directory make it read-only if you want to just read files from that directory. Also select auto-mount so you can have this folder always mounted when you restart/start you guest OS.
Friday, April 15, 2016
adding user and groups in Linux
Create the new groups and user .
groupadd ggowner ## Adding new group ggowner
useradd -g ggowner -G dba,oper gguser ## Adding new user gguser & add to groups default ggowner additional dba,oper,oinstall
WE CAN QUERY THESE NEW USERS IN LINUX:
[root@Linux03 Desktop]# cat /etc/passwd |grep gguser
gguser:x:501:501:golden gate user:/home/gguser:/bin/bash
gguser1:x:502:54331::/home/gguser1:/bin/bash
LOGIN AS NEW USER :
[root@Linux03 Desktop]# su gguser
CHECK THE GROUPS GGUSER IS PART OF :
[gguser@Linux03 Desktop]$ id
uid=501(gguser) gid=501(gguser) groups=501(gguser),54321(oinstall),54322(dba),54330(ggowner) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c102
groupadd ggowner ## Adding new group ggowner
useradd -g ggowner -G dba,oper gguser ## Adding new user gguser & add to groups default ggowner additional dba,oper,oinstall
WE CAN QUERY THESE NEW USERS IN LINUX:
[root@Linux03 Desktop]# cat /etc/passwd |grep gguser
gguser:x:501:501:golden gate user:/home/gguser:/bin/bash
gguser1:x:502:54331::/home/gguser1:/bin/bash
LOGIN AS NEW USER :
[root@Linux03 Desktop]# su gguser
CHECK THE GROUPS GGUSER IS PART OF :
[gguser@Linux03 Desktop]$ id
uid=501(gguser) gid=501(gguser) groups=501(gguser),54321(oinstall),54322(dba),54330(ggowner) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c102
Thursday, March 24, 2016
Open Linux ports on firewall
One important firewall setting that every NIX admin should learn is about the ports and firewall security. As these are the heart of any server. An invalid or miss-configuration can lead to many threats to organizations data.
It is a good practice to close enable firewall settings on. Always open only those ports in firewall that are required for access. Close unnecessarily open ports immediately when not needed.
You can only set/see these settings when logged in as root user. Once logged in as root, firewall settings are part of administration under system. Clicking on firewall will give you below screen.
In this below screen i wan to open up port 1521 for my oracle database to be accessed from other machines. Clicking on Other ports >> Add >> user defined.
Will give you ability to allow this port via firewall settings. This is just a high level config. You can also set advanced settings selecting other options but that's out of scope for this tutorial. That's it port 1521 is available for outside world now on your host IP.
Tuesday, March 15, 2016
Uppercase to lowercase or vice versa in BASH
Uppercase to lowercase or vice versa
The bash version 4.x+ got some interesting new features. Type the following commands to convert $VAR into uppercase:
VAR="All THIS will be in UppER Case"
echo "${VAR^^}"
Sample outputs:
ALL THIS WILL BE IN UPPER CASE
Type the following commands to convert $VAR into lowercase:
VAR="All THIS will be in lOWer Case"
echo "${VAR,,}"
Sample outputs:
all this will be in lower case
The bash version 4.x+ got some interesting new features. Type the following commands to convert $VAR into uppercase:
VAR="All THIS will be in UppER Case"
echo "${VAR^^}"
Sample outputs:
ALL THIS WILL BE IN UPPER CASE
Type the following commands to convert $VAR into lowercase:
VAR="All THIS will be in lOWer Case"
echo "${VAR,,}"
Sample outputs:
all this will be in lower case
Script to Check log file for errors and alert
#!/bin/bash
# Purpose: Detecting ORACLE Errors from any log file and send email
# Author: Arvind Toorpu
# Note : The script must run as a cron-job.
# Last updated on : 15-Feb-2016
## edit FILE to log file u want to check for errors
# -----------------------------------------------
# Store path to commands
FILE=/u01/app/oracle/admin/bin/test_error.txt
# Store email settings
AEMAIL="abcd@anyorg.com"
SUBJ="ORACLE Error - $(hostname)"
AMESS="Warning - ORACLE errors found on $(hostname) @ $(date). See log file for the details /u01/app/oracle/admin/bin/test_error.txt"
OK_MESS="OK: NO ORACLE Error Found."
WARN_MESS="ERROR: ORACLE Error Found."
# Check if $FILE exists or not
if test ! -f "$FILE"
then
echo "Error - $FILE not found or mcelog is not configured for 64 bit Linux systems."
exit 1
fi
# okay search for errors in file
error_log=$(grep -c -i "ORACLE error" $FILE)
# error found or not?
if [ $error_log -gt 0 ]
then # yes error(s) found, let send an email
echo "$AMESS" | mailx -s "$SUBJ" $AEMAIL <<-EOF
### Below line can be removed if you dont want to receive last few lines of that alert log
`tail -n -50 /u01/app/oracle/admin/bin/test_error.txt`
EOF
else # naa, everything looks okay
echo "$OK_MESS"
fi
# Purpose: Detecting ORACLE Errors from any log file and send email
# Author: Arvind Toorpu
# Note : The script must run as a cron-job.
# Last updated on : 15-Feb-2016
## edit FILE to log file u want to check for errors
# -----------------------------------------------
# Store path to commands
FILE=/u01/app/oracle/admin/bin/test_error.txt
# Store email settings
AEMAIL="abcd@anyorg.com"
SUBJ="ORACLE Error - $(hostname)"
AMESS="Warning - ORACLE errors found on $(hostname) @ $(date). See log file for the details /u01/app/oracle/admin/bin/test_error.txt"
OK_MESS="OK: NO ORACLE Error Found."
WARN_MESS="ERROR: ORACLE Error Found."
# Check if $FILE exists or not
if test ! -f "$FILE"
then
echo "Error - $FILE not found or mcelog is not configured for 64 bit Linux systems."
exit 1
fi
# okay search for errors in file
error_log=$(grep -c -i "ORACLE error" $FILE)
# error found or not?
if [ $error_log -gt 0 ]
then # yes error(s) found, let send an email
echo "$AMESS" | mailx -s "$SUBJ" $AEMAIL <<-EOF
### Below line can be removed if you dont want to receive last few lines of that alert log
`tail -n -50 /u01/app/oracle/admin/bin/test_error.txt`
EOF
else # naa, everything looks okay
echo "$OK_MESS"
fi
change hostname on a linux machine -centos
I want to change my Linux hostname from Linux01 to Linux03
[root@Linux01 Desktop]# vi /etc/sysconfig/network
[root@Linux01 Desktop]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=Linux03
RESTART THE SERVER NOW. AFTER REBOOT
[oracle@Linux03 Desktop]$ hostname
Linux03
[oracle@Linux03 Desktop]$
[root@Linux01 Desktop]# vi /etc/sysconfig/network
[root@Linux01 Desktop]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=Linux03
RESTART THE SERVER NOW. AFTER REBOOT
[oracle@Linux03 Desktop]$ hostname
Linux03
[oracle@Linux03 Desktop]$
Subscribe to:
Posts (Atom)