cat /etc/oratab | grep -e "^[\a-Az-Z0-9\]\{0,8\}\:*/[[:graph:]]*"
Hints:-
Always use caret "^" and "$" without escape "\" like "^[[:digit:]]" or "$[[:digit:]]" .
To include forward search use "\+" or "*" like "^[[:graph:]]\+" or "^[[:digit:]]*" .
cat /etc/oratab | grep -e "^[\a-Az-Z0-9\]\{0,8\}\:*/[[:graph:]]*"
Hints:-
Always use caret "^" and "$" without escape "\" like "^[[:digit:]]" or "$[[:digit:]]" .
To include forward search use "\+" or "*" like "^[[:graph:]]\+" or "^[[:digit:]]*" .
unzip -o /path/to/source_zip_file.zip -d /path/to/destination
-o :- source_directory
-d :- destination_directory
unzip
-o /u01/software/LINUX.X64_19300_GRID_HOME.zip
-d /u01/app/grid
Opatch :-
a java based utility enables the application and rollback patches oracle software.
location:- $ORACLE_HOME/OPatch/
----------------------------------------------------------------------------------------------------------------
Opatchauto :-
orchestration tool generates patching instruction specific to your target configuration then uses opatch to perform patching without user intervention.
location:- $GRID_HOME/OPatch/opatchauto
Stop DB
sudo -iu oracle
default :- srvctl stop database -d PUNEDB ---------> will stop database on all nodes
srvctl stop database -d PUNEDB -o normal
srvctl stop database -d PUNEDB -o immediate
srvctl stop database -d PUNEDB -o transactional
srvctl stop database -d PUNEDB -o abort
START DB
sudo -iu oracle
default :- srvctl start database -d PUNEDB ----------------> will start database on all nodes
srvctl start database -d PUNEDB -o nomount
srvctl start database -d PUNEDB -o mount --------> for standby db, backup task
srvctl start database -d PUNEDB -o open ---------> default behaviour
STOP / START INSTANCE
sudo -iu oracle
srvctl stop instance -d PUNEDB -i PUNE1
srvctl start instance -d PUNEDB -i PUNE2
To Stop CLUSTERWARE / CRS :-
sudo -iu root
ps -ef | grep -i d.bin
cd ~/bin
~/bin # ./crsctl disable crs
~/bin # ./crsctl stop crs -f
To Start CLUSTERWARE /CRS :-
sudo -iu root
ps -ef | grep -i d.bin
cd ~/bin
~/bin # ./crsctl enable crs
~/bin # ./crsctl start crs
Stop log apply service (MRP) on standby :-
alter database recover managed standby database cancel;
shutdown immediate;
stop log shipping from primary and shutdown primary database:-
Note:- Run this on primary--> to get log_archive_dest location for standby db's please use below query:-
then :-
show parameter log_archive_dest_state_&n; ------> n is number from above query
alter system set log_archive_dest_state_&n='DEFER';
shutdown immediate;
To start primary database & enable log shipping use below steps:-
steps to be performed on PRIMARY DB:-
startup;
alter system set log_archive_dest_state_&n='ENABLE';
steps to be performed on STANDBY DB:-
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session;
--------- to check status of mrp on standby and (lgwr or lns) on Primary -----
on standby:-
SQL > ! ps -ef | grep -e "pmon\|tnslsnr\|crs\|PARAM\|mrp" | grep -v grep
or
$ ps -ef | grep -e "pmon\|tnslsnr\|crs\|PARAM\|mrp" | grep -v grep
SQL>
-------------------------- Final all in one query for MRP DR ARCHIVE LOG GAP --------------
----------------------------------------------------------------------------------------------------
For Listener must start at reboot automatically:-
alter system switch logfile;
switch the logfile in the current instance so log sequence move to another
number by executing the command without waiting to full the logfile and
archiving it. forcing it also switches checkpoint.
alter system archive log current;
this forces all redo log files to get archived.
It performs the switch and archiving both.
RAC DB it forces global switch and archiving both in all instances.
for only a thread : since one db instances can contain only one thread....
alter system archive log current thread 1;
alter system checkpoint;
it makes change in checkpoint but not switch redo log file.
it makes current active redo log to inactive so that we can drop the redo log sequence.
alter system checkpoint;
LOG SWITCH "alter system switch logfile (STANDALONE) / alter system archive log current (RAC DB) ------> triggers checkpoint
CHECKPOINT "alter system checkpoint" ----------------> does not trigger LOG SWITCH
select first_time,first_change#,sequence#,status from v$log;
select checkpoint_change#,checkpoint_time from v$datafile_header;
alter system switch logfile;
alter system checkpoint;
alter system archive log current;
ALTER SYSTEM SWITCH LOGFILE;: Manually switches the current redo log file to the next available log file.ALTER SYSTEM CHECKPOINT;: Forces a checkpoint, ensuring modified data in the buffer cache is written to data files.ALTER SYSTEM ARCHIVE LOG CURRENT;: Manually archives the current redo log file, making it available for backup and recovery.sysdate - interval '2' hour;
sysdate - interval '2' day;
sysdate - interval '2' month;
sysdate - interval '2' minute;
sysdate - interval '2' second;
---- to enable and disable history on SQLPLUS
history;
show history;
hist clear;
hist;
set history off;
set history on;
--- fetch or rownum ---
fetch next n rows;
fetch first n rows;
fetch next n rows only;
fetch first n percent rows only;
offset n rows fetch next n rows only;
you can use gv_$view_name instead of gv$view_name
--Note : Make sure to logged in as "root" user for using usermod,useradd,userdel, groupadd,groupmod,groupdel on Linux otherwise commands will not run.
To pass the password with command to sudo :-
echo "password" | sudo -S -u username linux_command
to run command with another user:- su -c "command" username
echo "k" | sudo -S -u king whoami
--------------------------------------------------------------------------------
## to change home directory/Login directory of a user in Linux
usermod -d /path/to/new_home_directory -m username
option:
-d : for new path home directory
-m : moving all files from old home directory to new home directory
---------------------------------------------------------------------------------------
to add user:- useradd -m name_of_user
usermod -aG sudo username ----------> to assign admin access to user
sudo su - username
userdel -f username -------------------> to delete user forcefully
groupadd group_name --------------> to add group
groupdel -f group_name ------------> to force delete a group
gpasswd -A user -M user,user,user groupname ----> adding users to a group
gpasswd -d username groupname -----> removing a user from a group groupmod -n newgroup oldgroup ------> renaming a group
add user to secondary group:- useradd -G group1,group2,group3 username
add user to primary group :- useradd -g group1,group2,group3 username
add exiting user to secondary group :- usermod -a -G group_name username
add existing user to primary group :- usermod -g group_name username
to view passwd:- cat /etc/passwd
to view group:- cat /etc/groups
to view all user details:- id username
to view shells:- cat /etc/shells or echo $SHELL
=========================================
Rename User in Linux
1. Ensure the user is logged out
ps -u <old_username> pkill -u <old_username>
2. Rename the User
usermod -l <new_username> <old_username>
ex. usermod -l doe john
3. Update the Home Directory
usermod -d /home/<new_username> -m <new_username>
usermod -d /home/doe -m doe
4. Rename the Group
groupmod -d <new_groupname> <old_groupname>
groupmod -d doe john
5. verfiy changes
cat /etc/passwd; cat /etc/shadow; cat /etc/group
grep <new_username> /etc/passwd
grep <new_username> /etc/group
=====================================
To Lock the user on Linux:
sudo usermod -L <username>
This locks the account by prefixing the password hash with ! in /etc/shadow.
To Unlock the user on Linux:
sudo usermod -U <username>
===================================
To change shell of a user in Linux:
usermod -s /path/new_shell <username>
ex. usermod -s /bin/zsh puneverfiy changes in grep -i /etc/passwd "pune" or sudo chsk -s /path/new_shell <username>sudo chsh -s /bin/sh puneverify changes in grep -i /etc/passwd "pune" ==============================================
Step 1: Install OpenSSH Server You can do this via PowerShell (run as Administrator ): Check if it's already available: Get-WindowsCapab...