vi is the most widely available text editor in Unix. You have to learn a few commands, but then it becomes pretty efficient. It can be run from almost any terminal window and does not require an X11 session. Type vi filename at the prompt to get started. Type ESC :q (one key at a time, in order) to quit.
emacs is a very powerful editor that has great features, such as automatic formatting (tabbing, and useful text colors) for particular document types (e.g.
matlab script, Fortran code, latex file). Type emacs at the prompt, and read the emacs tutorial for thorough instructions on commands to use.
nano is a basic editor that is probably the easiest text-only editor to use of any (only on linux).
gedit or kedit – a basic GUI-based editor with an easy mouse-based interface
To view a file but not edit it, you can use more or less.
cat filename lists the contents of a file on the screen.
Killing a job
If an application freezes for some reason, you can kill it from another terminal window. First you will need to see what processes are running, then find the job ID number, then kill the job.
At the prompt, type
ps -ef | grep username
with your username so you can see what processes are being run under your username. You can also just type
“ps -ef” but that will show all jobs being run, not just yours.
If you are looking for a specific job, e.g. netscape (one of the first web browsers!), you would type
ps -ef | grep netscape
Which would return:
katopod 106302 116600 0 12:41:35 pts/12 0:00 grep netscape
katopod 106465 112940 0 12:36:05 pts/10 0:00 /bin/sh /usr/bin/X11/netscape
katopod 106757 106465 0 12:36:06 pts/10 0:18 netscape
To kill a job, you will need the job ID number, which is the first number listed by ps.
Then check to see if the job has been killed by running the same command:
ps -ef | grep netscape
If for some reason the job is still there, do a super kill:
kill -9 106465
If someone else’s job is hanging up your system, you will have to ask a system administrator to kill their job for you.
Compiling and viewing a LaTeX file
A couple of ways you can get started: 1) American Meteorological Society LaTeX package, 2) Overleaf.com
This is the old way to do this:
save your document as filename.tex
% latex filename
convert the dvi file to postscript:
%dvips filename -o
view the postscript file using ghostview:
% gv filename.ps
Check out pdflatex too – it’s a bit easier to work with.
Useful Unix commands
Look at the man pages for all of these commands for more detailed and accurate information!
For basic unix commands, see http://info.ee.surrey.ac.uk/Teaching/Unix/
|cp -r||copy directories and subdirectories (recursive)|
|echo “string” >> filt.txt||append string to a file|
|cat foot.txt | grep “\f” | sort||find lines with ‘f’ in foo.txt and sort|
|grep “string” *||search all files in directory for string|
|cat foo.txt | grep flowers||display line with “flowers” in foo.txt|
|jobs||displays jobs running in background|
|fg job_number||pull job to foreground|
|bg||put job in background|
|stop job_number||suspends job|
|kill job_number||kills job|
|kill -9 job_number||totally kills job|
|comp||compares text of two files|
|diff||displays differences in files|
|hostname||display current host|
|from||list of messages in mail|
|script||starts a transcript of the terminal session|
|stty||set terminal options|
|tty||get terminal name|
|whereis||shows location of command|
|locate file.txt||finds the location of a file (search)|
|man command||opens man (manual) page for ‘command’, e.g. man pwd|
|mail email@example.com < notes.txt||attach notes.txt to email and send|