Linux - 013 Linux Bash Tips
0xa Linux Bash Commands which helps me most in my daily work.1. cd -, swaps take you to the last cd last location
2. cd, Change to home directory
3. pushd, pushes the current directory path into stack and later you can use popd to go back to that location, use dirs to display the stack
4. fg, mainly for programmers who are editing and compiling the from command line. Eg. Start vim make some changes to the file use :w to save the contents press Ctrl-Z that process will get stopped. Now compile the code then use fg to bring back that to foreground.. Use jobs to see all stopped process and use bg to run those in background.
5. Ctrl-L, to clear the screen.
6. Ctrl-R to reverse search the previous commands
7. !xyz will execute the last xyz command with all the previous arguments.
8. Ctrl-A to go to the beginning for the line, Ctrl-E to the end of the line,
9. Ctrl-U erase all characters backward, Ctrl-W erase a word backward
10. shopt -s cdspell, will correct minor errors in cd command.
Labels: Linux
Posted by - at 11:12 am | 0 comments read on
C C++ Programming - Useful Tracing and Profiling Tools
I have been searching for few tracing and profiling tools these days. Tracing tools are my fav because we will be able to debug it while it is running and can get an overview of what is happening inside a.out. esp while learning the flow of a prog.I found the given below tools and links very useful...
- Linux
- gprof
- callgrind
- ltrace/strace/mtrace
- These are low level system calls, library calls and memory tracers
- Overview
- Systemtap
- Solaris
- dtrace - my fav
- DTrace Review - Really Cool Video - A must see one!
- IBM - AIX
- truss/trace
- i haven't personally used these, still has to do some more research on these
- Probevue
- HPUX
- if lucky you will find some here
Labels: AIX, C, C++, HP-UX, Linux, Solaris, Unix
Posted by - at 12:02 am | 1 comments read on
Shell Script - Memory Watch for UNIX Platforms
Simple memory profile script for UNIX/LINUX platforms.
#!bin/sh
PROCCHECKDELAY=1
RUNCHECKDELAY=2
PAGEROWS=80
PROCNAME=$1
PROCID=
if [ $# -ne 1 ]
then
echo give program name to watch;
exit 1;
fi
stat_process()
{
PROCID=
_mypid=
while [ true ]
do
_mypid=`ps -e 2>/dev/null|grep $1|head -n1|awk '{ print $1 }'`;
if [ -z "$_mypid" ]
then
echo "$1 is not running"
else
break;
fi
echo "recheck after $RUNCHECKDELAY seconds";
sleep $RUNCHECKDELAY;
done
PROCID=$_mypid;
}
i=$PAGEROWS;
while true;
do
stat_process $PROCNAME;
if [ $i -eq $PAGEROWS ] ;
then
i=0;
UNIX95= ps -p $PROCID -o vsz,pid,ruser,args 2>/dev/null
else
UNIX95= ps -p $PROCID -o vsz,pid,ruser,args 2>/dev/null|tail +2
fi
if [ ! -z "$PROCID" ]
then
i=`expr $i + 1`;
fi
sleep $PROCCHECKDELAY;
done;
please post your valuable comments and suggestions.
Labels: AIX, HP-UX, Linux, Script, Solaris, Unix
Posted by - at 3:17 pm | 0 comments read on