Unix Commands

how to use UNIX variants

doing su (change to super user) is often helpful

If having to copy files over to server, sometimes need more access, so chown (regular id) (directory)

to give a long directory listing sorted by moddate: ls -l --sort=t

to find a file by name, start from the directory to start searching

  • find . -name "thread*"

    • to find a directory add -type "d"

to find files by contents

  • grep contentstofind *

to remove a non-empty directory rm -r (directory)

show length of file in lines: wc -l file

to show the contents of a file use cat

  • or head -count file or tail -count file

  • to copy file contents to MacOs X Clip Board: cat file | pbcopy

to print matching lines from a file: grep -F "Aii" events.log


  • use gunzip on a .tgz file

  • tar xvf (filename) for a .tar file


  • ps -A to see everything

  • ps -C java to see subset

  • kill pid to kill process with number pid

  • ps auxww to see lots of detail on specific apps running

disk utilization:

  • df -h will tell you the basic availability on the machine

  • "find -printf %s %p\n | sort -nr | head" - will tell you the 10 biggest space consumers

run things in a detached screen (which, among other things, keeps them running after you disconnect)

  • one variation: screen -dmS sessionName commands, then, to access its console while running: screen -r sessionName

  • or just screen -S sessionName, then type commands as usual, then when ready hit ctl-a d to detach


Edited:    |       |    Search Twitter for discussion