Monday, January 9, 2012

Script to generate Complex password

This script can be used to generate complex password with predefined password length.

#Filename :

#Sets the length of the password the script will generate
# Holds valid password characters. I choose alpha-numeric + the shift-number keyboard keys
w e r t y u p a s d f h j k z x c v b m Q W E R T Y U P A D
F H J K L Z X C V B N M 2 3 4 7 8 ! @ $ % \# \& \* \= \- \+ \?

# Used in conjunction with modulus to keep random numbers in range of the array size

# Keeps track of the number characters in the password we have generated

while [ $pwd_len -lt $MAXSIZE ]
echo $password

Sample Execution: 
[root@sysllm01 create_password]# ./
[root@sysllm01 create_password]# ./
[root@sysllm01 create_password]#

Saturday, January 7, 2012

Find syntax to list huge-sized files and calculate total size

The disk space in one of the file-system (say /data1) is more 90% and you are asked to list out all the files which are more than 100 MB size and find the sum of total space occupied by listed files in Megabytes.

To list all the files in /data1, which are more than 100 MB size.
# find /data1 -size +102400k -exec du -sh {} \;

To find the sum of total space occupied by listed files.
In Megabytes:
# find /data1 -size +102400k -ls | awk '{sum += $7} END {printf "Total size: %8.4f MB\n", sum/1024/1024}'\;

In Gigabytes:
# find /data1 -size +102400k -ls | awk '{sum += $7} END {printf "Total size: %6.2f GB\n", sum/1024/1024/1024}'\;

Command-line to check the details of Perl modules installed on Linux

To find the path of Perl modules installed:  
# perl -e 'print join "\n", @INC'

To find the path of each individual Perl modules:
# find `perl -e 'print "@INC"'` -name '*.pm' -print

To check if a given Perl module is installed on the system:
Let say you want to check if the Perl module "File::Compare" is installed or not. The syntax would be as follows:
# perl -e 'use File::Compare; print "Installed\n"'