Sunday, January 8, 2023

Some important OS Command

 Copy xauthority from home directory.

xauth add $DISPLAY . hexkey

*********************************
DB commands to alter user

ALTER USER sidney IDENTIFIED BY second_2nd_pwd DEFAULT TABLESPACE example;
ALTER USER sh PROFILE new_profile;
ALTER USER sh DEFAULT ROLE ALL EXCEPT dw_manager;
ALTER USER app_user1 IDENTIFIED GLOBALLY AS 'CN=tom,O=oracle,C=US';

**********************************************
DB commands to create/grant roles to users

select * from dba_users where username like '%PATHEESH%';
create user PATHEESH identified by xxxx profile userprofile default tablespace psdefault temporary tablespace pstemp;
grant create session to PATHEESH;
select * from dba_role_privs where GRANTEE='PBHASKARAN';


select NAME,PASSWORD from user$   -- To encrypt oracle  database password


***************************
DB commands to create/delete/verify database links

select * from dba_db_links;
DROP PUBLIC DATABASE LINK FINLINK.ggg.ORG;
CREATE PUBLIC DATABASE LINK FINLINK.ggg.ORG CONNECT TO username IDENTIFIED BY password USING 'FINUPGT';
select * from dual@FINLINK.ggg.ORG;
select * from psdbowner@FINLINK.ggg.ORG;
*****************************

Unix commands

find . -type f -size +100000000c -exec ls -l {} \; - command to list files larger than 100MB. The dot(.) after find represents current working directory. It can be changed to any path.


find . -type f -size +100000000c -exec gzip {} \; - command to compress/zip files larger than 100MB. The dot(.) after find represents current working directory. It can be changed to any path.


find . -type f -size +100000000c -exec rm {} \; - command to delete files larger than 100MB. The dot(.) after find represents current working directory. It can be changed to any path.

find . -type f -mtime +30 -exec ls -l {} \; - command to list files older than 10 days. The dot(.) after find represents current working directory. It can be changed to any path.


find . -type f -mtime +10 -exec gzip {} \; - command to compress/zip files older than 10 days. The dot(.) after find represents current working directory. It can be changed to any path.


find . -type f -mtime +30 -exec rm {} \; - command to delete files older than 10 days. The dot(.) after find represents current working directory. It can be changed to any path.


find . -type d -ctime +30 -exec rm -rf {} \;


find . -type f -exec grep 'String' {} + - command to list all the files that contains a String/String pattern

tar -cvf folder_name.tar folder_name - command to create a tar archive

tar -xvf folder_name.tar - command to de-archive a tar file

gzip file_name - command to zip a file. In unix/linux a folder cannot be zipped directly. A tar file needs to be created for the folder and then the tar file can be zipped.

gunzip file_name.gz - command to unzip a file

free -m - command to find current memory usage

free | grep Mem | awk '{print $3/$2 * 100.0}' - command to find what percentage of memory is in use

free | grep Mem | awk '{print $4/$2 * 100.0}' - command to find what percentage of memory is free

ps -ef - command to list all the processes that are running on the server

ps -ef | grep domain_name - command to list all applicaiton server, process scheduler and web server process running with the domain_name

ps -ef | grep domain_name | grep java - command to list only web server process running with the domain_name

ps -ef | grep domain_name | grep PIA - command to list only PIA process running with the domain_name



Port Ping Test :

nc -v fdev.dfd.org 23093

lsof -i | grep 23093
lsof -i -P |grep http
netstat -na |grep 55555

Change file permissions :


chmod -R g+rwxs /apps/hr/srce
chmod -R g+rwxs /apps/hr/hris_sr
chgrp -R hrdv /apps/hr/srce
chgrp -R hrdv /apps/hr/hris_sr

To find the large files :


du -a /apps/pstools  | sort -n -r | head -n 20
du -a  /apps/ | sort -n -r | head -n 20

du -a  /home  | sort -n -r | head -n 20


du -a  /apps/pstools/hr/appserv/hr/LOGS | sort -n -r | head -n 20



Find and delete the older files /logs :


find /apps/pstools/finpatch/appserv/prcs/finpatch/LOGS -type f -name '*.LOG' -mtime +30 -exec ls -ltr {} \;


find /apps/pstools/finpatch/appserv/prcs/finpatch/LOGS -type f -name '*.LOG' -mtime +30 -exec rm {} \;



find /apps/pstools/hcmtst02/appserv/hcmtst02/LOGS -type f -name '*.LOG' -mtime +30 -exec rm {} \;


find /apps/pstools/hrdev/appserv/prcs/hrdev/LOGS -type f -name '*.LOG' -mtime +30 -exec rm {} \;


find /apps/hrprod/psreports/hrprod -type f -name '*patdupst_*'

find /apps  -type f -name '*finupgt.ggg.org_*'

finesupgt.ddd.org


To Find the CPU utilization :

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

du -a  /apps/pstools/finprd/appserv/prcs/finprd/LOGS | sort -n -r | head -n 20


To Find the memory utilization :

ps -o pid,user,%mem,command ax | sort -b -k3 -r


To Setup Password Less Connection :


findv@adfdeed:[/home/findv] > /usr/bin/ssh\-copy\-id -i .ssh/id_rsa.pub hrdv@hrdv.tty.org


To delete old logs files :


find /apps/hrprod/psreports/hrprod -type f -name 'patdupst*' -mtime +30 -exec ls -ltr {} \;

find /apps/hrprod/psreports/hrprod -type f -name 'patdupst_*.PDF'  -exec ls -ltr {} \ ;


find /apps/pstools/finprod/appserv/prcs/finprod/LOGS  -type f -name '*.LOG*' -mtime +120 -exec ls -ltr {} \;


find /apps/pstools/hcmtst02/appserv/hcmtst02/LOGS -type f -name '*.LOG' -mtime +30 -exec rm {} \;


Soft Link Sample :


ln [-sf] [source] [destination]

    By default, the ln command creates a hard link.
    Use the -s option to create a soft (symbolic) link.
    The -f option will force the command to overwrite a file that already exists.
    Source is the file or directory being linked to.
    Destination is the location to save the link – if this is left blank, the symlink is stored in the current working directory.

For example, create a symbolic link with:

ln -s test_file.txt link_file.txt

This creates a symbolic link (link_file.txt) that points to the test_file.txt.

To verify whether the symlink has been created, use the ls command:

ls -l link_file.txt

No comments:

Post a Comment