Paths in unix/linux
A path is the location of a file or
directory. They can be absolute or relative. Most simply, imagine we
have the following directory structure on the server:
If we are in subdirectory3, and want to specify file3, we would simply type file3. If we are in directory2, and want to specify file3, we would simply type subdirectory3/file3. If we were in
the root directory, and want
to specify file3, we would
If we were in subdirectory3,
and wanted to specify file2,
we would type ../file2 (../ means look in the directory
containing the current directory; ../../
means move up two directories, etc.). These are all relative paths --
what we type
depends on where we are. Absolute paths start at the root directory and
so start with /. No matter
where we are, for example, /directory2/subdirectory3/file3
specifies file3; /file1 specifies file1, etc. In the following
examples, you can use the above ways of determining file locations
where you see file or name.
Minimal set of commands for navigating unix/linux
Other useful unix/linux commands for phylogenetics:
: list directory (folder)
(delete) a file. You can use paths (see info for cd) to delete a file
in another directory than the current one.
rm -r file
directory and its contents
directory (open a directory).
: open the root directory.
cp sourcefile destinationfile
cd ../ : leave the current
directory and open the directory containing
the current directory instead.
cd ../../ : move up two
cd /home/cow : open the
directory cow in the directory home which is at
: copy a file. You can copy a file from one directory to another, also
changing its name, by using paths.
mv sourcefile destinationfile
: move a file. This is also a way of changing a file's name.
simple way of looking through a file. Type q
to quit, space
to move down in the file.
or vim file
text editor (vi or vim) to create a file (if it doesn't exist already)
or edit an existing file. Press i
to enter edit mode. Press esc
to leave edit mode. To save, leave edit mode and type :w
. To save and exit, leave edit
mode and type :wq
. To exit without saving, leave
edit mode and type :q!
scp sourcefile destinationfile
: secure copy file. Good for copying files to and from a remote
cluster. For example, if your username were bob,
you wanted to copy the file trees.nex
from the directory /usr/bob/analyses
to the directory you are currently using on another computer, you could
type scp email@example.com:/usr/bob/analyses/trees.nex trees.nex
: open a manual (instructions) for a command.
: connect to a remote host.
: see which processes
(basically, programs) are running, their identifying numbers, and other
information. You can kill (force quit) processes from here.
paup -n batchfile > logfile &
: starts a paup run in
automatic mode immune to hangups (for example, your run will continue
on a cluster even if the computer you used to start it from shuts
nohup mb batchfile > logfile &
: starts a MrBayes run immune
to hangups. Note that the logfile will get very large.
To translate mac line endings to unix line endings, use tr '\015'
'\012' < mac.filename > unix.filename
To translate unix line endings to mac line endings, use tr '\012'
'\015' < unix.filename > mac.filename
Sites useful for command
To create batch files for PAUP, see my page
PAUP batch files, and also see PAUP's command reference document,
available from PAUP's downloads page.
To create batch files for MrBayes, see this page
by Rod Page.
Controlling a Mac remotely
(and for free):
In addition to using ssh to connect to a remote computer, it is
sometimes convenient to control a remote computer using its GUI, just
as if you were sitting at the screen. One way to do this is to set up
the remote computer as a VNC server and then use a VNC client to
control the remote computer. I use Mac OS X, so these instructions are
for using that operating system (I've tried both 10.2 and 10.3), though
in general works on all
popular operating systems. Also, the instructions are largely based on
a more detailed wiki at Brandeis on configuring VNC for
Mac OS X
-- I have modified them slightly and put them here for my
own reference, and as a hedge against the ephemerality of the web.
First, download OSXvnc
on the computer you want to control remotely (the "remote computer").
Put it in the Applications folder. Start OSXvnc. Under General >
Passwords, type in a VNC password. Under General, set a display number
(typically 0) and a port number (typically 5900
). Under Sharing, select
the box saying "Allow only local connections (require SSH)" -- this
will ensure that only secure (SSH) connections are allowed. Also set up
your Startup preferences -- you generally want the VNC server active
all the time, I believe. You should also remember your short user name
(if in doubt, open the program Terminal (in Applications >
Utilities) and look at the text immediately preceding the "%", such as jsmith
%) and system password
(the password you may use when logging in), which may be different than
the password you entered in OSXvnc.
On the remote Mac, go to System Preferences > Sharing > Services.
Activate "Remote Login".
Download Chicken of
(or some other VNC client) on the local computer you want
to use to access the remote computer.
Open the program Terminal (in Applications > Utilities) on the local
computer. Type ssh -Nfn -L
For example, if your shortuser name were jsmith, you wanted to
use a localport of 5901
, set up
the port in OSXvnc on the remote computer as 5900,
and knew the remote
computer IP address (easy if the IP address is static (unchanging), or
you can use a service like dyndns
to maintain a constant hostname (like jsmithhome.dyndns.org
with a constantly updated IP address), you would type ssh -Nfn -L 5901:127.0.0.1:5900 firstname.lastname@example.org
. You would
then enter your system password (the one you use on the remote computer
to log in).
Then, open Chicken of the VNC on the local computer. In the host field,
just type "localhost" [no quotes]. In the port field, type the
localport (in the example above, 5901
In password, type the password you entered in OSXvnc (not the system
password). On display number, type the local display, probably 0.
Connect, and, if all goes well, the remote computer screen will appear
in a window on your local computer. You can type, use function keys,
use the mouse, etc., normally.
Sometimes, OSXvnc seems to need to be open on the remote computer to establish a connection. If this is so, before using the ssh command above, use ssh shortusername@remotecomputer
, then, after logging in, type open /Applications/OSXvnc.app
(assuming the program is called OSXvnc and is in the Applications directory) to start it running. Then continue as above.
Finally, when you're done with the connection, close the window in Chicken of the VNC and go back to terminal, hit return a few times, and type logout
to disconnect from the remote computer.
Note that it is easier to set up this remote control (not requiring the
steps in Terminal, but requiring an additional step in Sharing
preferences) if you are willing to allow everything you send over the
internet between the computers to be insecure. The approach above
(which uses SSH tunnelling) is more secure.