Skip to main content

Some Useful Unix commands

I find myself using the below comments day to day.

Enjoy!!

1. ps
2. find
3. df
4. du

ps

Display memory size of the process running sorted

1. ps -e -o vsize,command,time |sort -gr |more

for full command line (os x)

1. ps -ax -www |grep Java

find

find files that matches the filename pattern

1. find . -name "*.*"

find anything of type file

1. find . -type f

find anything of type directory

1. find . -type d

find files (and display contents) that matches the filename pattern and matches content

1. find . -name "*.*" -exec grep 'search me' {} \;

find files (and display filenames) that matches the filename pattern and matches content

1. find . -name "*.*" -exec grep -l 'search me' {} \;
2. find . -name "*.*" |xargs grep 'department'

df
display partition information in human readable format

1. df -h

du

display disk usage from the current directory in human readable format

1. du -h

display disk usage from the current directory in human readable format for only one directory deep

1. du -h -d 1 (os x)
2. du -h --max-depth 1 (linux)

Comments