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

No comments:

Post a Comment