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

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
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
awk ‘{print $2}’ kill –9 pids

Shows which processes are using which port numbers

Command: netstat –a