Tuesday, May 17, 2011

Unix basic troubleshooting command

Troubleshooting
------------------------



Files System

How to find a name in a file/directory:

# find . –type f –exec grep –ls {} \;

Check Files Sizes

Search for the 5 largest directories (MB) on a Unix System:

Command: # du –sk *
sort –nr
head

Find the largest files on a Unix System:

Command: # du –k
sort –nr

Check the size of a directory on a Unix System:

Command: # du –sk .

Core Files

Command: File

Description: Shows which process is responsible for the core dump.

Compare file1 and file2 and put result in file3

Command: sdiff –l

Compress big files to readable format (octal dump)

Command: od –ad –t cd1

How to remove ^M out of a file

# dos2unix

Read binary files

Command: strings

Count the number of files in a directory

Command: ls –1
wc –l

How to delete a directory with too many files

When you get the message: “rm * Arguments too long.”

This means that there are too many files in the directory.

Delete all files with XXXX:

Command: # find .
grep “XXXX”
xargs rm –f

Remove all files in the directory and sub-directories:

Command: # find .
xargs rm –f



UNIX Processes

Show only the process id

Command: ps –ef
grep
nawk ‘{print $2}’

Monitor the performance of processor/server

Command: prstat

Command: top

Command: truss –wall –f –o -p

How to kill a series of processes

Export pids = ‘ps –ef
grep
nawk ‘{print $2}’ kill –9 pids

Shows which processes are using which port numbers

Command: netstat –a



Configuration

Link related commands:

Check logical channels

Command: vcstat

Get number to use for error message

Command: pad +0.

Get error message:

Command: X25diags



To determine which parameters the hme drivers support:

Command: ndd (-set)(-get) /dev/hme

Determine state of IP forwarding (quick method):

Command: ndd (-set) (-get) /dev/ip ip_forwarding

Analysing output:

0 ---> the system is not forwarding IP packets between its interfaces.

1---> the system is forwarding IP packets between its interfaces

Determine the interface speed:

Command: ndd (-set) (-get) /dev/hme link_speed

Analysing output:

0---> indicates that the interface is running at 10 MBits per second.

1---> indicates that the interface is running at 100 MBits per second

Determine if the hme interface is running in full-duplex or half-duplex mode:

Command: ndd (-set) (-get) /dev/hme link_

Analysing output:

0---> indicates that the interface is running in half-duplex mode.

1---> indicates that the interface is running in full-duplex mode.

Query if interface is up or down by using the link_status parameter:

Command: ndd (-set) (-get) /dev/hme link_status

Analysing output:

0---> the link is down

1---> the link is up

Determines if the interface supports auto-negotiation:

Command: ndd (-set) (-get) /dev/hme adv_autoneg_cap 0--->with auto negotiation

Analysing output:

0--->with auto negotiation

1--->without auto negotiation

4.3.4 Check LAN speed between two terminals

cd /var/tmp (on terminal 1)

mkfile 10M

ftp to

cd /var/tmp

bin

hash

put

No comments:

Post a Comment