###Unix commands###
# Unix is somewhat abrupt in its phrasing
files and directories
cp x y # copy file x to y, leaves x
mv x y # move file x to y, x is gone!
mkdir x # makes new directory x
rmdir x # removes a directory
pwd # shows current directory
cd x # goes into folder x
rm x # remove file x
ln -s x y # makes a soft link between real file x and local pointer y
ls # lists documents in current directory
cat x # list the whole file
more x # types x in chunks, "space" goes to next chunk
less x # similar to more
head x # types the first N lines
tail x # types the last N lines
find * # list all of the files in this directory and below
Process management
CTL-Z # pause the current process and return to console
bg # allow the process you just paused to run in background
jobs # shows what you're running
ps # shows processes
com > file # output of command com goes to file x
com >& file # errors from command com goes to file x
com >> file # appends output of com onto end of x
com >>& file # appends error of com onto end of x
Help
man com # help on command com
com -h # sometimes has help this way as well
com --help # or this
special startup/config files
.login or .profile # runs on login
.shrc or .cshrc # runs when you invoke a script
editing and strings
sed s/a/b/ x > y # replaces a with b in file x and outputs to y
grep a b # print out all lines in b which contain string a
sort a # sort the file a
diff a b # print out the difference between a and b
emacs a # edit the file a
environmentals
environmentals are shortcuts the system will expand for you
very useful if you want to do the same thing with different inputs
In the bash shells use
export X=y # will make $X refer to y
export PATH=y:${PATH} # will append y to $PATH
In the c-shells csh and tcsh
setenv X y # is the same thing as export X=y
env # will list all environmentals you have set
echo $ENV # will print the value of $ENV to the terminal
important environmentals are:
$HOST
$USER
$HOME # your home area
$PWD # the current directory
$PATH # where unix looks for code to execute
$PYTHONPATH # where unix looks for python modules to import
$LD_LIBRARY_PATH # where unix looks for shared libraries
you normally want to append to the PATH. Just setting doing export PATH=x
wipes out all the other stuff it was already set to.
export PATH=$FIRST:$SECOND
running scripts
source a # will just run the commands in file a as if you were typing them
sh a # will run the commands but any environment set up within a is gone when it ends
other useful commands - use man or google to see the arguments!!
history # replays commands you have typed
clear # clear the screen
arp, netstat, ifconfing, host, ping, trace route # give you information about your network connections
# alias renames a command to something more convenient
examples from an expert postdoc
alias h="history"
alias hless="history | less"
alias htail="history | tail"
alias ls="ls -Fh"
alias ll="ls -l"
alias llt="ls -lrt"
alias dir="ls -l"
alias la="ls -a"
alias lsa="ls -al"
alias llh="ll -h"
alias cls="clear; ls"
alias rmd="rm *~" # removes backup files left by some editors
About Professor X
I'm a high energy physicist at a major research university.
Looks good! ^_^