Monday, March 20, 2006

Exit Status Code of a Program on Unix / Linux

Depending on the shell you are using, you can find the exit status code of a program on Unix/Linux using

in bash

$?


or in csh,

$status



A non-zero exit code states that the program terminated with an error whereas an exit code of zero states that the program /script terminated normally.

Friday, March 10, 2006

CSS two column layout

Here is a CSS two column layout for you to enjoy


<div style="background:#ffffcc;">
Top heading

<div>
<div style="float:left;width:66%;background:#ffff00;">
<div class="content">left</div>
</div>
<div style="width:34%;float:left;background:#ffff00;">
<div class="content">right</div>
</div>
</div>

<div style="clear:both;">
Footer
</div>


</div>

Saturday, March 04, 2006

Automatically check for /var/log/secure for intruders: Auto Spell for Directories

Here's what I like to keep in my .bash_profile to automatically tell me about intruders upon login

echo -e "*************************\nSystem Security Messages" >> /designerz/security/log/frankly.messages;
echo "Current Users " >> /designerz/security/log/frankly.messages;
who >> /designerz/security/log/frankly.messages
#who | uniq | sort
echo "Last Users | Unique " >> /designerz/security/log/frankly.messages;
#last -30 | uniq | sort | cut -d " " -f 1 | sort | uniq >> /designerz/security/log/frankly.messages
last -30 | uniq | sort >> /designerz/security/log/frankly.messages

#last | uniq | sort | cut -d " " -f 1
#last | uniq | sort | cut -d " " -f 1 | sort | uniq
echo "Faillog";
faillog
faillog >> /designerz/security/log/frankly.messages
echo "Unique 'who' Connected";
who | uniq | sort | awk '{print $6}' | sort | uniq
who | uniq | sort | awk '{print $1}' | sort | uniq
echo "Last";
last | uniq | sort | awk '{print $1}' | sort | uniq

search="Failed .*"; logile="/var/log/secure"; cat $logile | grep "$search" | awk -F: '{ print $7 }' | awk '{count[$1]++} END { for( i in count ) { if ( count[i] >= 5 ){print i "Total Failed Attempts: " count[i] ""} }}';
echo "End of Security Report. (/designerz/security/log/intruder.ssh.log, /designerz/security/log/frankly.messages) ";
#cat /designerz/security/log/frankly.messages
#tail -10 /designerz/security/log/intruder.ssh.log;

alias rm='rm -i'
alias cp='cp -i'



Today I came across Blog O’ Matty which has some good tips.

For instance, you may not know that using cdspell can come to your rescue if you have problem spelling your directories.

[root@srv30 frankly]# grep cdspell .bash_profile
[root@srv30 frankly]# man cdspell
No manual entry for cdspell
[root@srv30 frankly]# cdspell
-bash: cdspell: command not found
[root@srv30 frankly]# shopt -s cdspell
[root@srv30 frankly]# cd /hme
/home
[root@srv30 home]#



Enjoy

Thursday, March 02, 2006

Linux commands: The funny linux commands

Hope you enjoy these funny Linux commands as much as I did:


% cat "food in cans"
cat: can't open food in cans

% nice man woman
No manual entry for woman.

% "How would you rate Quayle's incompetence?
Unmatched ".

% Unmatched ".
Unmatched ".

% [Where is Jimmy Hoffa?
Missing ].

% ^How did the sex change operation go?^
Modifier failed.

% If I had a ( for every $ the Congress spent, what would I have?
Too many ('s.

% make love
Make: Don't know how to make love. Stop.

% sleep with me
bad character

% got a light?
No match.

% man: why did you get a divorce?
man:: Too many arguments.

% !:say, what is saccharine?
Bad substitute.

% %blow
%blow: No such job.

% \(-
(-: Command not found.

$ PATH=pretending! /usr/ucb/which sense
no sense in pretending!

$ drink matter
matter: cannot create