ls
: list directory (folder)
contents
mkdir name :
make a
new directory
rm file :
remove
(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 :
remove a
directory and its contents
cd name :
choose a
directory (open a directory).
cd /
: open the root directory.
cd ../ : leave the current
directory and open the directory containing
the current directory instead.
cd ../../ : move up two
directories.
cd /home/cow : open the
directory cow in the directory home which is at
the root.
cp sourcefile destinationfile
: 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.
less file :
simple way of looking through a file. Type
q to quit,
space to move down in the file.
vi 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 or
ZZ . 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, and
you wanted to copy the file
trees.nex
from the directory
/usr/bob/analyses
on
server.podunk.edu
to the directory you are currently using on another computer, you could
type
scp bob@server.podunk.edu:/usr/bob/analyses/trees.nex trees.nex.
man commandname
: open a manual (instructions) for a command.
ssh username@computername.university.edu
: connect to a remote host.
top : see which processes
(basically, programs) are running, their identifying numbers, and other
information. You can kill (force quit) processes from here.
nohup
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
down).
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
line phylogenetics:
To create batch files for PAUP, see my
page for
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
VNC 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
the VNC (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
localport:127.0.0.1:remoteport shortusername@remotecomputer .
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 jsmith@jsmithhome.dyndns.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.