Sorting sorting is the arrangement of data/information in increasing (ascending) or decreasing(descending) pattern. #sort <options> filename Options: -r -reverse order -n -numeric order -t -as field separator, delimiter -k position -u unique sort #sort /etc/passwd #sort -r /etc/passwd #cut -d:-f7 /etc/passwd|sort -u
Vi & String Processing Introduction to string processing Introduction to string Processing Head/Tail Head and tail command are used to view the first and last few lines of a file respectively. By default these commands generate 10 numbers of lines. # head /etc/passwd (shows first 10 lines) # tail /etc/passwd (shows last 10 lines) One very handful
Shell Scripting Reading an Input From File Reading an input from a file: Command <file> #tr ‘a-z’ ‘A-Z <file (Translates all the lowercase characters to uppercase). Note: if you want to print the output of existing file to new file Use this command #tr `a-z’ `A-Z'<oldfilename>newfilename
Input Output Pipes and Redirection Input, Output and pipes: Standard output-Terminal screen is default Standard error -Terminal screen is default Standard input = Keyboard is default Redirectional operators: Command > file1 (writes the standard output from command to file1) Command >> file1 (Appends the output from command to file1) Command 2>file2 (Writes the
Systems Administrator Archiving and Compression Archiving and compression at the time: Syntax: tar <option> files/dir Options: Z (if we are using gzip compression) j (if we are using bzip2) x (Extracts) v (verbose mode) f (for archived file) t (list the content of an archived file) # tar zcvf gvn.tar.gz /etc
Shell Scripting Time Saving CLI Techniques $ echo {x,y,z} x y z $ echo a{x,y,z} ax ay az $ echo {{1,2,3},1,2,3} 1 2 3 1 2 3 $ echo {{1,2,3}1,2,3} 11 21 31 2 3 $ cp /etc/samba/smb.conf{,.bak} >CTRL + R to
Shell Scripting Simple yes no input shell script Simple shell script to get user confirmation echo “Do You wish to Continue ?<y/n>: ” read response if [ $response = “y” ];then echo “You entered yes” echo “Please Wait..Window Will Close When Done” sleep 10 ……………… echo “Done…Exiting Now” sleep 2 …………………. exit fi
Shell Scripting Disable Traps ctrl c , ctrl z in shell script Use the following line in the beginning of your shell script to disable traps like ctrl c and ctrl z in your shell script. trap “” 2 20
Systems Administrator Using Crontab CRON TABLE is used to execute tasks in unix,solaris operating systems. IT is used to execute scheduled tasks at specific times. Two files : /usr/lib/cron/cron.allow and /usr/lib/cron/cron.deny determine who can and cannot use the cron jobs. If only cron.deny file exists
DNS Master DNS Configuration in Chrooted Environment Here is a little tutorial on how to configure bind in chrooted environment. 1. First of all you need to install all the required packages. #yum install bind bind-chroot bind-libs bind-utils caching-nameserver 2. Configure RNDC.key file. This key file is required for secured communication between master and slave DNS