Defindit Docs and Howto Home

This page last modified: Apr 20 2007
title:Linux and emacs getting started hints
description:Linux beginner secrets explained.

Emacs minimum:

Start Emacs:
emacs filename.txt

When you are running Emacs, you need three minimal skills: move, save,

Move within a file: use your keyboard arrow keys and cursor keys,
backspace (delete back), delete (delete under the cursor).

Save a file: Press "control" and the X key together, then "control" and the S
key. We pronounce this "control x control s" and write it C-x C-s.

Exit from Emacs: C-x C-c

I suggest that you use my .emacs file which has additional features,
and which gets rid of some irritating default options. See

If you wish to learn more about Emacs, you will need to be able to
enter commands. You don't have to remember all the command names since
Emacs will auto-complete commands for you when you press the tab key. 

If you want to see all your current emacs keys (called key bindings)
you can use the describe-bindings command. Use the key combination
called Meta-x or simple M-x: press Esc (and relase) then press x. Then
enter a command and press the Enter key. To reiterate M-x, here are
the steps:
press Esc and release
press the letter x and release
type in a command
press Enter

The command will run as soon as you press Enter. If you want to cancel
any operation at any time in Emacs, use control-g which we write
C-g. You may press C-g any time, and as often as you like. It has no
effect if you aren't running a command (i.e. if you are just sitting
in a file).

Do the following commands in order to get the key bindings into a text
file that you can print:

emacs_key_bindings.txt (enter a file name and press Enter)

Here is some info about the Linux command line, and some of the
conventions we use. The shell bash is actually easier to use than
systems like MS Windows or the Apple Macintosh since bash will
auto-complete comamnds for you. However, you need a some hidden,
secret info.  (Secret info isn't limited to Linux. If you don't
believe me, just watch a Windows XP person try to use a Mac. The Mac
is quite difficult to use. If you don't believe me, try to figure out
how to drag a copy of a file to a different folder.)

"-bash-2.05b$" is technically the "prompt" or we simply say "the
shell" or "go back to the prompt" if you are in a program. This is
also the "command line" interface. There are several shells, and the
best one is called bash. The prompt means that the computer is
awaiting your command. If you press Enter without a command, you'll
just get the prompt. Entering a control-c will kill the currently
running command. You may enter control-c multiple times. Control-c
will not kill the shell. 

A typical throw-away file is tmp.txt which we pronounce "t m p dot t x
t" or "temp dot t x t" or even "temp dot text". There is an entire
shorthand way of talking about commands that is necessary since the
commands are too long to fully pronounce.

We speak "p s" for the ps command. However, we usually pronounce chmod
as "ch-mod".

Commands have options. There are short options which consist of hyphen "-"
(dash, or minus) and one letter. Some options have values. examples are:

-d"may 21, 2002"

Long options are "--" a double hypnen and a word. Some long options
have values. An examples is:


When speaking "ls -l *.txt" we say "ls minus l the t x t files". The
"*" is the wild card asterix is called "star". The file specification
"*.txt" gives all files that end in ".txt", thus all the t x t files.

Here are some examples commands and how I would speak them. (Note that
we use hyphen, dash, and minus interchangably.) Sometimes we leave off
the word "dash", "hyphen" or "minus" since it is commonly understood
as a requirement for all command line options.

Now that I read these example "sentences" I can easily see why people
who have not been tutored in the this would be confused. However, it
really is straightforward. Speaking these commands may help reveal the
intent of the command. Keep in mind that the commands are easier to
type than they are to speak.

There is some confusion when reading 1 (one) and l (ell). Everything
here is an ell unless otherwise obviously a digit.

emacs -nw file.dat
e-macs dash n w file dot dat

ls -alt *.pdf
ls dash a l t star dot p d f

ls -l *.pl
l s dash l star dot p l 
l s minus l all the perl scripts (Perl scripts end in .pl)

df -h .
d f dash h dot

chmod go+x *.pl
ch mod g o plus x star dot p l
ch mod g o plus x all the perl scripts
sha-mod the perl scripts to group other executable

cp myfile.txt myfile_1.txt
c p my file dot t x t my file underscore one dot t x t
c p my file dot t x t to my file underscore one dot t x t

grep -i "singlet" *.txt
grep dash i double quote singlet double quote star dot t x t
grep dash i quote singlet quote star dot t x t
grep dash i for the string singlet in star dot t x t
grep dash i for the double quoted string singlet in star dot t x t
(A "string" is some text surrounded by double quote characters. If
someone say "quote" they usually mean a double quote character.)

grep '>' *.fasta | wc -l
grep tick greater than tick star dot fasta pipe w c dash l
grep a single quoted string greater than in star dot fasta pipe to w
c dash l
(We often say "tick" for a single quote. The pipe character | above
the enter key is used to connect commands together.)

Here are the common command names:


That's pretty much the day-to-day list. Every command has help
available. Some of the help is a bit arcane, but most is pretty
good. For example, enter "man ls" to get help for ls.

Important note: the rm command is used to delete files. There is no
undo. For what I consider historically stupid reasons, the rm command
has a fairly dangerous set of options -fr which have been used to
delete entire hard disks. I suggest that you avoid rm -fr * until you
have lots of experience. Instead, create an archive or trash
directory, and mv files there. Most systems will alias rm to rm -i
which prompts before removing a file. If you don't have this alias, I
suggest you add it. Edit your .bashrc file and add this line:

alias rm='rm -i'

Keep backups of anything important. Use "tar" to create backups on
disk. Backup directories and files with tar before deleting,
especially before using rm -fr in any form.

Here are some example commands:

ls -l
ls -l *.txt
tail .bashrc
ls -alt | head
ps aux
cd public_html
ls -l *.html
la -alt *.html | head -n 30
cd ~/
mkdir archive
echo "stuff" > tmp.txt
mv tmp.txt archive/
ls -l archive/*.txt
pa aux > ps_list.txt
cat ps_list.txt

Less and more are used for looking at (viewing) files, usually text
files. Use the plain letter q to quit. Space-bar is page down. Less
supports the cursor keys. Control-c will not exit from less. Press h
in less will bring up some help, and there is always the less man
page, i.e. man less.

Linux is case-sensitive. Most things are lowercase. Upper case will
not work if the computer is expecting lowercase. 

Dot files (.emacs, .bashrc) are generally reserved for configuration
and options files. The leading dot is treated special by the "ls"
command. Other than that, using dot files is a convention and nothing