tag:blogger.com,1999:blog-189024042024-03-08T01:45:55.791+05:30//* Unix Blog *//"The only constant in this world is change "Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.comBlogger257125tag:blogger.com,1999:blog-18902404.post-76096507897725825412014-09-11T21:27:00.001+05:302014-09-11T21:27:12.506+05:30AWS EC2 Commandd Lines
1) **** Script to get a list of hosts from AWS for a Particular Region
#!/bin/bashsource /Users/name/ec2/bashrc_prod_east ec2-describe-instances |grep Name |grep -v aws:autoscaling:groupName |awk '{print $5}'$count='wc -l';echo "Total $count hosts found on Prod East"
2) Launch an Instance :
bash$ ec2-run-instances ami-76817c1e -k sunfod-dev-us-east-1-general --instance-type Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-68983248424689338842014-04-23T23:24:00.000+05:302014-04-23T23:24:10.776+05:30While loop to run command multiple times
while true; do ls ; done
Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-66463793630947059432009-04-30T17:47:00.000+05:302009-04-30T17:53:46.412+05:30How TO - Multiple grep Search Pattern bash-2.03$ cat benchmark.out |egrep -e "SOLARIS26SPARC" P4D/SOLARIS26SPARC/2006.1/109255 (2006/10/17) P4/SOLARIS26SPARC/2006.1/104454 (2006/08/11)bash-2.03$ cat benchmark.out |egrep -e "SOLARIS26SPARC" |egrep -e "17" P4D/SOLARIS26SPARC/2006.1/109255 (2006/10/17)bash-2.03$ Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com1tag:blogger.com,1999:blog-18902404.post-80485424588747355862009-04-21T19:50:00.001+05:302009-04-21T19:50:28.310+05:30 An abbreviated description of the Linux Boot up process The LILO boot loader starts the kernel The Linux kernel configured by lilo or rdev decompresses and must find and mount the root filesystem. If LILO or the kernel were not configured properly there can be a problem here.The kernel after loading the root filesystem, starts the "init" program which may be located in /sbin/init. Reads /Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-44966712145995353372009-04-01T16:31:00.001+05:302009-04-01T16:31:15.190+05:30Sending a HTML file inline with Subject using Sendmail command ! echo "Subject: Testing" | cat - file.html-old| /usr/lib/sendmail your-mail@mailid.comSriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-54606252646159322712009-04-01T15:27:00.001+05:302009-04-01T15:27:56.522+05:30Nawk to convert CSV file in HTML column/row format /usr/bin/awk has a limit for the printf string of 398 characters./usr/xpg4/bin/nawk has no limit.Nawk to convert CSV file in HTML column/row formatnawk 'BEGIN{FS=","print "MIME-Version: 1.0"print "Content-Type: text/html"print "Content-Disposition: inline"print "<HTML>""<TABLE border="1"><TH>SA TEAM</TH><TH>Host Name</TH><Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-5501331312958365522009-04-01T14:10:00.001+05:302009-04-01T14:10:14.289+05:30Sending HTML Mail by way of report !!! Sending HTML Mail by way of report !!! I wanted to do below : Step 1) Convert .csv comma seperated file to .html file Step 2) Sending the HTML file as inline mail (had to use sendmail command , mailx wont support sending mail by way of HTML inline): Step 1) Convert .csv comma seperated file to .html fileCSV file :test.csv: (This need to convert to .html)EQADM,Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-4105906191676129372008-09-13T14:43:00.003+05:302008-09-13T14:57:17.753+05:30Configuring Apache to run perlConfiguring Apache to run perl :I have below RPM installed: (Default Fedora 9 Sulphur)----------------------------------httpd-2.2.8-3.i386mod_perl-2.0.3-21.i386In Fedora 9 perl specification :===============================$cat /etc/httpd/conf.d/perl.conf*)LoadModule perl_module modules/mod_perl.so*)Alias /perl /var/www/perl< Directory /var/www/perl >SetHandler perl-scriptAddHandler cgi-script .Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-81326623772600095472008-09-07T22:35:00.004+05:302008-09-08T10:49:45.522+05:30rename file extentions ...I wanted to rename all .txt file extensions as .html$rename s/\.html/.txt/ *.htmlOh, also, this isn't a "standard Unix(TM) command, but it does come with most Perl installations that I know of and Perl is on most Unix machines that I know of.Also i tried for loop :for i in *.txt; do mv "$i" `basename $i`.htmlBut this renames a file file1.txt as file1.txt.html anyone know how get avoid .html addedSriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-31574625905140918972008-09-07T20:26:00.002+05:302008-09-07T20:32:35.737+05:30Exit Status - Shell scriptWhenever a shell script is executed it checks the exit statusof command to verify if it executed sucessfully.True = 0False = Non Zero ValueYou can check exit status value as below:Eg:#!/bin/bashecho helloecho $? # Exit status 0 returned because command executed successfully.lskdfUnrecognized command.echo $? # Non-zero exit status returned because command failed to execute.$./script.shhello0.Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-48908031630551109712008-09-07T15:16:00.003+05:302008-09-07T15:20:09.566+05:30Shell script if statementShell script using if statement to check if process is running:================================================================#!/bin/bashsendmail=`(ps -ef |grep -v grep |grep sendmail)`if [ -z "$sendmail" ];thenecho "Sendmail is not running"elseecho "Sendmail is running"fiWHat each line means:---------------------1) #!/bin/bashThis generates a Process ID for shell2) PROCESS=`(ps -ef |grep -v Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-52435293455678549062008-06-22T19:59:00.004+05:302008-06-22T20:33:28.293+05:30while running df command it says read only filesystemTaking further from my previous post,I was not able to run df -k command :It says , no filesystems processed:Solution:To remount root filesystem with read-write :$mount -o remount,rw /This will make a entry in /etc/mtab for read,write access to root filesystemSriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-87922494973162246702008-06-22T01:45:00.005+05:302008-06-22T18:05:57.327+05:30Using Linux RescueWhile trying to install Fedora core 8 on my Virtualbox(VM)It got hanged after installation was done ...Here's what I did:1) Boot through Fedora core 8 CD2) Select rescue installed system.3) You will be asked to select the language, which defaults to English. Select the appropriate language and press OK to continue.4)You will be asked to select the keyboard type, which defaults to us (USA). SelectSriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-24518970497365382502008-05-27T09:10:00.004+05:302008-05-27T09:15:21.110+05:30Check OS Script ...I had to check all hosts in a list , if its windows or unix.Here's what helps identify whether it is Unix or Windows,Note: Our Windows systems did not have ssh daemon running,bash-2.03$ cat checkos.sh#!/bin/shfor host in `cat list_of_host`doif version=`(sleep 1 ; echo "") | telnet $host 22 | grep -i SSH` then echo "$host $version" >> HOSt-SSH-Running else echo "$host" >> HOST-SSH-Not-running Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-13746402133480562102008-05-25T11:11:00.003+05:302008-05-25T11:21:04.551+05:30Finding Common Occurence in Files and Writing to a New file !I wanted to compare lines in 2 files and write things which are common in a different file.Eg,File1 (has line like below)===========================host1host2host3etc.....File2 (has line like below)===========================host2host3host4host5etc ...Which ever is common among file1 and file 2 should be written to file3Grep does it :grep -f file1 file2 > file3file3 will have host2, host3 from Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-65047778622755147712008-05-20T17:05:00.003+05:302008-05-20T17:17:37.721+05:30Shell Script Comparing files ...I have a file (file1) which is likehost1host2host3host4the list goes on............Now I want the above lines in files to be compared with files under/opt/new/*File names under /opt/new are as below:DevProdQAAnd suppose host1 from file1 is found under Dev(file under /opt/new)than it should write under a seperate file New-list as host1-DEVAns:while read line; do echo ${line}-$(grep -l $line /opt/Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-28028962058454618532008-04-08T19:28:00.000+05:302008-04-08T19:33:02.919+05:30echo CommandUse echo command to display text or value of variable.echo [options] [string, variables...]Displays text or variables value on screen.Options-n Do not output the trailing new line.-e Enable interpretation of the following backslash escaped characters in the strings:\a alert (bell)\b backspace\c suppress trailing new line\n new line\r carriage return\t horizontal tab\\ backslashSriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-10028724401668744542008-03-27T17:18:00.003+05:302008-03-29T12:42:04.786+05:30Identify Zombie Process in Solaris and Clean it :bash-2.03$ ps -ef |grep defunct (The one marked in dark below is Parent Process) zasshr 8134 24291 0 0:00 <defunct> .............................It will show u a list.........................bash-2.03$ ptree 2429124291 /opt/VRTSvcs/bin/CitiEquity/CitiEquityAgent -type CitiEquit 8134 <defunct> 8205 <Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-86887841098596396232007-12-13T18:55:00.000+05:302007-12-13T18:59:31.197+05:30Solaris FaqWhat is the command to do an interactive boot from the ok promt?boot -iHow can i disable STOP+A utility on SUN machines,which brings system into OK> prompt???.In /etc/system set abort_enable=0 will disable STOP-AWhere are the templates stored that are copied into the user's home directories for their personal customizations?/etc/skelWhat SPARC emergency keyboard sequence will takethe system to Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com2tag:blogger.com,1999:blog-18902404.post-72735243241131944402007-12-09T22:27:00.000+05:302007-12-09T22:33:24.734+05:30Listing USB devices on Fedora 7lsusb command can list all usb devices found, I had Fedora core 7(moonshine) installed and i did not find the command,I had to install usbutils which brings the command:[root@linuxbox ~]# yum -y install usbutilsInstalled: usbutils.i386 0:0.71-2.1Complete![root@linuxbox ~]# lsusbBus 004 Device 001: ID 0000:0000 Bus 003 Device 001: ID 0000:0000 Bus 002 Device 001: ID 0000:0000 Bus 001 Device 001: Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-61807955196392368322007-12-09T11:41:00.000+05:302007-12-09T11:51:58.592+05:30SSH TipsPointing to some SSH tips given in Linux Magazine:$ssh -T user@hostnameIf you connect to a host this way, it will disable pseudo-tty allocationand a command like w will not show your connection. Better add`bash -i' , as below.$ssh -T user@hostname /bin/bash -iWith the below command the IP address of the system you connect to wont belogged into known_hosts file, usually its in /root/.ssh/Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-64838769962789940762007-11-19T17:17:00.001+05:302007-12-07T18:33:49.252+05:30Linux keyboard shortcuts. Linux has many keyboard shortcuts. Knowing them makes using Linux much easier. Console/terminal -- - shuts down computer - (, , ,…) - switch to n-th console - or - - switch to next/previous virtual terminal - locks terminal input/output - allows to read console contents when output is going too fast. To unlock, press Scroll Lock once again.Alternatively, Scroll Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-25359164902849067092007-10-21T22:45:00.000+05:302007-10-21T22:48:29.770+05:30Oracle Database 11g on Linux now available !!!Oracle Database 11g Release 1 (11.1.0.6.0) - Standard Edition,Standard Edition One, and Enterprise Edition - became avialablefor download from OTN.You can download it from this link - a 1.7GB single zip file.Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-54029193688572706342007-08-16T00:33:00.000+05:302007-08-16T00:37:44.497+05:30Execute shell commands from a C programHeres a C Program that use system() function to execute shell commands:See man system for more information:[root@linuxbox C_Programs]# cat test.c #include main(){printf ("Files More than 10 MB !!\n");system("find . -size +10000k");return 0;}[root@linuxbox C_Programs]# gcc test.c[root@linuxbox C_Programs]# ./a.out Files More than 10 MB !!./xemacs-packages-extra-20061221-1.fc7.noarch.rpmSriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0tag:blogger.com,1999:blog-18902404.post-20024504453759887052007-08-15T23:11:00.000+05:302007-08-15T23:15:56.442+05:30Programming C under UnixWriting a test Program in C (Unix):====================================[root@linuxbox C_Programs]# cat test.c#include main(){printf ("Hello Sriram!!\n");return 0;}Executing the above :=====================[root@linuxbox C_Programs]# gcc test.c [root@linuxbox C_Programs]# lsa.out test.c[root@linuxbox C_Programs]# ./a.out Hello Sriram!!Sriram Shttp://www.blogger.com/profile/09617003634255043653noreply@blogger.com0