Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

14 June 2017

Difference between softlink and HardLink in Linux with example

HardLink: it is like mirror copy of original file. These links share the same inodes. Changes made to the original or hard linked file will reflect in the other. When you delete Hard Link nothing will happen to the other file. Hard links can't cross file systems.

SoftLink: contain link to original file. These links will have different inode value. SoftLink points to original file so if original file is deleted the softlink do not work.






10 January 2013

How to Analyze AIX core using dbx command?

Command to run after copying binary and core onto AIX machine from terminal:
dbx program core
Ex: dbx myengine core.myengine_wedNov20123456

Some more use full commands you can run from (dbx) as below:
thread         List or change the current thread
func           List or change the current function
dump           Print all variables local to a procedure
where          Print the call stack
frame          List or change the current stack frame number
next           Step one source line (stepping over calls)
quit           Exit dbx

(dbx) thread
 thread  state-k     wchan    state-u    k-tid   mode held scope function
 $t1     run                  blocked              u   no   pro  _usched_swtch    
 $t2     run                  blocked              u   no   pro  _usched_swtch    
 $t3     run                  blocked              u   no   pro  _usched_swtch    
 $t4     run                  blocked              u   no   pro  _usched_swtch    
 $t5     run                  blocked    29943     u   no   pro  _pthread_ksleep  
...
>$t74    run                  running    30979     k   no   pro  p__9SemaphoreFv  


(dbx) func
p__9SemaphoreFv

(dbx) dump
p__9SemaphoreFv(0x170) at 0xd10f2100

(dbx)where
p__9SemaphoreFv(0x170) at 0xd10f2100
incrData__18TransActionCounterF9countType() at 0xd1130880
connect__12MachineQueueFv(0x3178d3f8) at 0xd10ff8a8
attemptConnection__12MachineQueueFv(0x3178d3f8) at 0xd10fe14c
attemptConnection__9LlMachineFPCci10SocketTypeT2() at 0xd1152478
.() at 0x10017fc4
.() at 0x10018300
runThread__13IntervalTimerFv() at 0xd115a14c
startup__6ThreadFPv(0x315252e8) at 0xd10ed684
_pthread_body(??) at 0xd00081f8


(dbx)quit

References:
http://web.utk.edu/~prdaves/Computerhelp/dbx_commands.htm

28 February 2010

Linux commands

To display all permissions..of all files on current directory.
>ls -al

clear screen:
>clear
To traverse root to root directory
>cd ../../

to delete the folder recursively.
>rm -R pictures

to delete focibly a filename
>rm -f abc.txt

to copy a file to local current directory
>cp /home/abc/*.* .

to set an environment variable like TOP to ~/BA/SOL/test
>setenv TOP ~/BA/SOL/test

To set an environment variable in bash like TOP to ~/BA/SOL/top
>export TOP=~/BA/SOL/top

To check the value of environment variable like TOP
>echo $TOP

to flush DNS cache on Linux:
- To restart the nscd daemon, type 
/etc/rc.d/init.d/nscd restart 
in your terminal
- Once you run the command your linux DNS cache will flush.
to rename a file
>mv abc.c abc

>find /opt/CA -name "m_replace" -print

similar to explorer . in windows we can use "nautilus ." without double quotes.

to share files we can go to /mnt/httpd and open it


command to know suse verion on suse linux:
cat /etc/SuSE-release

How to check physical memory in solaris:
/usr/sbin/prtconf -v |grep Memory

Command to Know processid:
pidof processname
example:>pidof abserver
>23434

command to kill a process:
you can try:
>kill processID
>pkill processname
Forcible kill after trying kill with -1 and -2 is
>kill -9 processID
killing multiple instances of same process
>killall processName
>killall -9 processName

To list all processes running along with mem and cpu usage:
>ps aux
example:
>ps aux | grep uniserver
reference link: http://www.linfo.org/ps.html
How to create core file in Linux:
>ulimit -c unlimited
now core file will be generated like core.12345 where 12345 is pid of process. created in the location where process binary exist.
(or )
>gcore process-ID

How to get callstack of running process:
pstack processId
example:
>pstack 21345
This will give same output as gcore command coredump, analyzing it via gdb command
using gdb to get callstack:
>gdb programname core-file
> where //to get call stack
>bt    //to get callstack
>quit   //to come out of gdb

Viewing the contents of JAR file
jar tf jar-file
t --- indicates you want to view the table of contents of jar file
f --- jar file whose contents are to  be viewed
Example:
$jar tf TicTacToe.jar
This command displays the contents of the JAR file to stdout:

META-INF/MANIFEST.MF
TicTacToe.class
audio/
audio/beep.au
audio/ding.au
audio/return.au

The JAR tool will display additional information if you use the v option:

$jar tvf TicTacToe.jar
the verbose output for the TicTacToe JAR file would look similar to this:
    68 Thu Nov 01 20:00:40 PDT 2012 META-INF/MANIFEST.MF
   553 Mon Sep 24 21:57:48 PDT 2012 TicTacToe.class

  3708 Mon Sep 24 21:57:48 PDT 2012 TicTacToe.class

Command to know host name using ip address within a intranet network
Ex: 
nbtstat -a 10.176.165.136
Here 10.176.165.136 is ip address of remote host in same network, run from command prompt.


Useful Linux Commands in log review:
(i) command to move to end of file after we open any file in unix terminal using vi editor is shift+g
(ii) to list files in a directory in the ascending order of timestamp:(this will help to see latest updated file in a directory like tomcat logs)
$ls -larth

Tomcat Server:
Suppose server ip is : 100.81.20.172

Check the status of Tomcat Server running on dev machine with IP 100.81.20.172 and port 8080
http://100.81.20.172:8080/manager/html

Log File Location on Tomcat Server:
/opt/tomcat/logs/catalina.out