Linux: Useful Scripts & Commands

Whenever I need some commands or scripts, I had to search to find out where it is. I alway forgot to organize my required script and now trying to put everything here so at least I will know where to look into.

These are mostly simple staff, just putting here for reference.

-- Run OS commands in loop
 # while true; do free -m; sleep 2; done;
 # while true; do ls -ltr | wc -l; du -sk .; echo '-----------'; sleep 5; done;


-- Working with user lockdown
 (root)# chage -l oracle
 (root)# pam_tally2
 (root)# pam_tally2 -u oracle -r


-- Convert SSL Certificates

Root-CA.crt: Root certificate.
Sub-CA.crt: Intermediate certificate
hostname.cer: User certificate
 # openssl x509 -in Root-CA.crt -inform der -outform pem -out root.txt
 # openssl x509 -in Sub-CA.crt -inform der -outform pem -out intermediate.txt
 # openssl x509 -in hostname.cer -outform der -out user.der
 # openssl x509 -in user.der -inform der -outform pem -out user.txt


-- tune2fs - adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
 -i " interval-between-checks[d|m|w]": Adjust the maximal time between two filesystem checks.
 (root)# tune2fs -i 0 /dev/VGExaDb/LVDbSys1
 (root)# tune2fs -i 0 /dev/VGExaDb/LVDbOra1
 -c max-mount-counts: Adjust the number of mounts after which the filesystem will be checked by e2fsck.
 (root)# tune2fs -c -1 /dev/mapper/VGExaDb-LVDbOra1
 (root)# tune2fs -c -1 /dev/mapper/VGExaDb-LVDbSys1


-- Find command: example
 # find /dbfs/dbfs_fs/ -name '.fuse_hidden*' -type f -print | wc -l
 # find /dbfs/dbfs_fs/ -name '.fuse_hidden*' -type f -print
 # find /dbfs/dbfs_fs/ -name '.fuse_hidden*' -type f -delete
 # find /u02/WORLD/conntrace.1/ -name '*.trc' -type f -print | wc -l
 # find /u02/WORLD/conntrace.1/ -name '*.trc' -type f -delete


-- Oracle Server: Change iLOM Settings (IP, NTP, DNS)
 -- Change NTP
 (root)# ipmitool sunoem cli "show /SP/clients/ntp/server/1"
 (root)# ipmitool sunoem cli "show /SP/clients/ntp/server/2"
 (root)# ipmitool sunoem cli "set /SP/clients/ntp/server/1 address=10.10.74.1"
 (root)# ipmitool sunoem cli "set /SP/clients/ntp/server/2 address=10.10.74.2"
 (root)# ipmitool sunoem cli "show /SP/clients/ntp/server/1"
 (root)# ipmitool sunoem cli "show /SP/clients/ntp/server/2"
 -- Change DNS
 (root)# ipmitool sunoem cli "show /SP/clients/dns"
 (root)# ipmitool sunoem cli "set /SP/clients/dns auto_dns=enabled
 (root)# ipmitool sunoem cli "set /SP/clients/dns nameserver=none
 (root)# ipmitool sunoem cli "set /SP/clients/dns retries=1
 (root)# ipmitool sunoem cli "set /SP/clients/dns searchpath=example.com
 (root)# ipmitool sunoem cli "set /SP/clients/dns timeout=5
 (root)# ipmitool sunoem cli "show /SP/clients/dns"
 -- Change Hostname  
 (root)# ipmitool sunoem cli "show /SP hostname"  
 (root)# ipmitool sunoem cli "set /SP hostname=*****"  
 (root)# ipmitool sunoem cli "show /SP hostname"  
 -- Change System Identifier  
 (root)# ipmitool sunoem cli "show /SP system_identifier"  
 (root)# ipmitool sunoem cli "set /SP system_identifier=*****"  
 (root)# ipmitool sunoem cli "show /SP system_identifier"  
 -- Change iLOM IP address  
 (root)# ipmitool sunoem cli "show /SP/network"  
 (root)# ipmitool sunoem cli "set /SP/network pendingipaddress=10.10.74.203 pendingipgateway=10.10.74.251 pendingipnetmask=255.255.254.0 commitpending=true"  
 (root)# ipmitool sunoem cli "show /SP/network"  
Note: Verify that ILOM is accessible. The ILOM network changes should be immediate (once commitpending=true is sent through).


-- Exadata: ExaWatcher Report Collection
 (root)# cd /opt/oracle.ExaWatcher  
 (root)# ./GetExaWatcherResults.sh --from 06/26/2015_13:00:00 --to 06/26/2015_15:00:00  
 (root)# ./GetExaWatcherResults.sh --from 09/22/2015_03:00:00 --to 09/22/2015_07:00:00  
 Output Directory: /opt/oracle.ExaWatcher/archive/ExtractedResults  


-- .bash_profile
 umask 022  
 ulimit -c unlimited  
 PS1='\u@\h($ORACLE_SID):`pwd`# '; export PS1;  
 alias sql+="sqlplus '/ as sysdba'"  
 alias sql++="sqlplus '/ as sysasm'"  



-- Exadata/Linux: Create new File System
 -- Check for free space left on the logical group using the "lvm vgdisplay -s" on VG Name  "VGExaDb"  
 # lvm vgdisplay -s VGExaDb  
 -- Create a LVM to hold "/backup" using  
 # lvcreate -L 250G -n /dev/VGExaDb/LVBackup  
 -- Create a new file system on the new partition  
 # mkfs.ext(3/4) /dev/VGExaDb/LVBackup  
 -- Then Create a target directory on which to mount the new file system, mount it and check it using df  
 # e2label /dev/VGExaDb/LVBackup DBORA_2  
 # mkdir -p /backup  
 # mount /dev/VGExaDb/LVBackup /backup  
 Note: Add the new /backup filesystem to the /etc/fstab to make sure that it gets mounted at boot  
 -- Final Checks  
 # lvm vgdisplay VGExaDb -s  
 # lvm lvscan  

No comments:

Post a Comment