Useful commands Phil taught me

By Daniel Price

Once upon a time, in a happy land called the IoA, there was a PhD student called Phil. He was a very grumpy PhD student, but he had a heart of gold. Often would be heard, echoing around the walls of H27, the plainted cries of: `read the ****ing man page', `its in the b****y user guide' (although never the unutterable statement of despair `ask helpdesk'). As his memory fades into legend, we pause to remember him and I pass on this, his legacy, of useful commands he taught me.

Variations on ls

ls -l lists in long format (useful to alias this as ll)
ls -l $\vert$ sort -n -k5 list everything in order of increasing size
find . -type d list everything of type directory in current and sub directories
find . ! -name '*.' find all files with no extension
find . -name '*.bib' find all the .bib files in current and sub directories
find . -perm -0001 find all files with the +x permission

Unix stuff

man -s1 gets the *real* man page for a command, not the fortran/c library routine, if there are two things by the same name
docrap $>$& file put *all* the output from program docrap (including error messages) into file.
ssh -C turns on compression when using ssh (much faster)

Printing etc

lp -d hp4 print on printer hp4
lpq -Php4 lists things you have sent to the print queue of hp4
lprm -Php4 11123 deletes the job 11123 from the print queue
mpage -2 -Php4 print with 2 pages per A4 page (to print pdf files like this, use `print to file' which produces a postscript, then use mpage on the postscript. If mpage tells you a ridiculous number of pages, *cancel* the print job (using lprm) as this means it has hacked up
psnup -2 $\vert$ lp -d hp4 same as previous command (use when mpage has hacked up)
a2ps crap.txt `pretty print' a text file (try it)

LaTex etc

dvips -p 1 -l 4 crap.dvi convert the file crap.dvi to a postscript, but only pages 1 to 4
ps2pdf create a pdf file crap.pdf from a postscript (use with caution, often gets things wrong)
detex $\vert$ wc count the number of words in a latex file (nb: thesis $<$ 60000)

Things about you and other users

jobs list all the jobs running from the current shell
kill %1 kill job number 1
kill -9 %1 axe murderer kill, die, destroy job number 1
top lists all things hogging your cpu
kill 11123 kill job with PID 11123 (PID from top or ps -fu)
ps -fu dprice lists all the processes being run by dprice on your machine
finger dprice tells you what dprice is up to
finger @cass77 tells you who is logged onto cass77
last $\vert$ head list the last few logins to your machine
prtdiag tells you diagnostics about your machine

Things to do with files

diff file1 file2 tells you the differences between two files
gdiff -u file1 file2 same
grep crap *.f list all the times the word crap appears in all .f files
tail -100 crap.output list the last 100 lines from crap.output
tail -f crap.output list continually any new data written to crap.output

How to check whether you have enough disk space

quota -v tells you your disk quotas and usage. Often broken.
du -s -k * tells you space occupied by everything (including subdirectories) in current directory

Fortran compiler switches (although Phil would never teach such things)

f77 -C finds all those subscript out of range errors
-O4 optimises your code
-ftrap=overflow catches floating point overflow errors (try man f77 ftrap for more)
-xtypemap=real:64,double:64,integer:32 compile in double precision

The most wonderful commands of all

yes Daniel is a legend just try it
fortune print a quote
fortune -m thesis print all quotes containing the word `thesis'
banner hello print hello as a banner ( gives a much better version)

Some useful aliases

The format of the alias commands here is for tcsh (something else Phil would never use - try man alias for bash/sh versions).

alias rm rm -i `safe' rm. To stop it doing this type `unalias rm'
alias rmtex 'rm *.dvi *.aux *.log *.blg' get rid of useless LateX files
alias xdvi xdvi -s 14 so xdvi opens with a reasonable size window
alias ls ls -F  
alias ks ls -F common typo
alias ll 'ls -l'  
alias lstree 'find . -type d' list all sub- and sub-sub- etc directories
alias lsd 'ls -F $\vert$ grep '/' ' list all subdirectories
alias lsdir 'ls -l -F $\vert$ grep '/' ' same but in long format
alias f90pg 'f90 -o $\backslash$!* $\backslash$!*$\backslash$.f -lpgplot -lX11 -lF77' compile using PGPLOT
alias f77pg 'f77 -o $\backslash$!* $\backslash$!*$\backslash$.f -lpgplot -lX11' same but for f77
alias vol '/usr/dt/bin/sdtaudiocontrol' turn the volume down
alias ss xlock -mode random screen saver
alias xt 'xterm +ls -sb -geometry 80x48 -title crap -n crap' better xterm
alias lbtex 'latex $\backslash$!*; bibtex $\backslash$!*; latex $\backslash$!*; latex $\backslash$!*' when using bibtex

About this document ...

Useful commands Phil taught me

This document was generated using the LaTeX2HTML translator Version 2008 (1.71)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -split 0 -font_size 10pt -no_navigation philcommands.tex

The translation was initiated by Jeremy Sanders on 2011-10-02

Jeremy Sanders 2011-10-02