Although Linux can in theory run with only 2 megs of RAM, the more you have, the more you can do. X Window System won't run unless you have at least 8 megs. To create an additional 8 megs of virtual memory, type as root:
# dd if=/dev/zero of=/swapfile bs=1024 count=8192
# mkswap /swapfile 8192
# sync
# swapon /swapfile
Add the last line in /etc/rc.d/rc.local
to make the swapfile
available the next time you boot, or add this line in /etc/fstab
:
/swapfile swap swap defaults
Under Unix there are some widely used applications to archive and
compress files. tar
is used to make archives---it's like
PKZIP
but it doesn't compress, it only archives. To make a new archive:
$ tar -cvf <archive_name.tar> <file> [file...]
To extract files from an archive:
$ tar -xpvf <archive_name.tar> [file...]
To list the contents of an archive:
$ tar -tf <archive_name.tar> | less
You can compress files using compress
, which is obsolete and
shouldn't be used any more, or gzip
:
$ compress <file>
$ gzip <file>
that creates a compressed file with extension .Z (compress
) or .gz
(gzip
). These programs can compress only one file at a time. To
decompress, use:
$ compress -d <file.Z>
$ gzip -d <file.gz>
RMP.
The unarj
, zip
and unzip
(PK??ZIP compatible) utilities
are also available. Files with extension .tar.gz
or .tgz
(archived with tar
, then compressed with gzip
) are as common
in the Unix world as .ZIP files are under DOS. Here's how to list the
contents of a .tar.gz
archive:
$ gzip -dc <file.tar.gz> | tar tf - | less
First of all: installing packages is root's work. Some Linux applications
are distributed as .tar.gz
or .tgz
archives, specifically prepared
so that they can be decompressed from / typing the following command:
# gzip -dc <file.tar.gz> | tar xvf -
The files will be decompressed in the right directory, which will be
created on the fly. Users of the Slackware distribution have a
user-friendly pkgtool
program; another is rpm
, which is
available on all distributions thanks to Red Hat.
Other packages shouldn't be installed from /; typically, the archive
will contain a directory called pkgname/
and a lot of files
and/or subdirectories under pkgname/
. A good rule is to install
those packages from /usr/local
. Besides, some packages are
distributed as C or C++ source files, which you'll have to compile
to create the binaries. In most cases, all you have to do is issue
make
. Obviously, you'll need the gcc
compiler.
Command completion: pressing <TAB> when issuing a command
will complete the command line for you. Example: you have to type
gcc this_is_a_long_name.c
; typing in gcc thi<TAB>
will suffice. (If you have other files that start with the same
characters, supply enough characters to resolve any ambiguity.)
Backscrolling: pressing SHIFT + PAG UP (the grey key) allows you to backscroll a few pages, depending on how much video memory you have.
Resetting the screen: if you happen to more
or cat
a binary file, your screen may end up full of garbage. To fix things,
blind type reset
or this sequence of characters:
echo CTRL-V ESC c RETURN
.
Pasting text: in console, see below; in X, click and drag to select
the text in an xterm
window, then click the middle button (or the two
buttons together if you have a two-button mouse) to paste. There is also
xclipboard
(alas, only for text); don't get confused by its very slow
response.
Using the mouse: install gpm
, a mouse driver for the console.
Click and drag to select text, then right click to paste the selected text.
It works across different VCs.
Messages from the kernel: have a look at /var/adm/messages
or /var/log/messages
as root to see what the kernel has to tell
you, including bootup messages.
This list reflects my personal preferences and needs, of course.
First of all, where to find them. Since you all know how to surf
the Net and how to use archie
and ftp
, I'll just give you three
of the most important addresses for Linux:
sunsite.unc.edu
,
tsx-11.mit.edu
, and
nic.funet.fi
. Please use your nearest mirror.
at
allows you to run programs at a specified date and time;
awk
is a simple yet powerful language to manipulate data files
(and not only). For example, being data.dat
your multifield data file,
$ awk '$2 ~ "abc" {print $1, "\t", $4}' data.dat
prints out fields 1 and 4 of every line in data.dat
whose second field
contains ``abc''.
delete-undelete
do what their name means;
df
gives you info about the mounted disk(s);
dosemu
allows you to run several (not all) DOS
programs---including Windows 3.x, with a bit of hacking;
file <filename>
tells you what filename
is
(ASCII text, executable, archive, etc.);
find
(see also Section
dir)
is one of the most powerful and useful commands. It's used to find
files that match several characteristics and perform actions on
them. General use of find
is:
$ find <directory> <expression>
where <expression> includes search criteria and actions. Examples:
$ find . -type l -exec ls -l {} \;
finds all the files that are symbolic links and shows what they
point to.
$ find / -name "*.old" -ok rm {} \;
finds all the files matching the pattern and deletes them, asking
for your permission first.
$ find . -perm +111
finds all the files whose permissions match 111 (executable).
$ find . -user root
finds all the files that belong to root. Lots of possibilities here---RMP.
gnuplot
is a brilliant program for scientific plotting;
grep
finds text patterns in files. For example,
$ grep -l "geology" *.tex
lists the files *.tex that contain the word ``geology''. The variant
zgrep
works on gzipped files. RMP;
gzexe
compresses executable binaries keeping them executable;
joe
is an excellent editor. Invoking it by typing jstar
you'll get the same key bindings as WordStar and its offspring, including
DOS and Borland's Turbo languages editors;
less
is probably the best text browser, and if properly
configured lets you browse gzipped, tarred, and zipped files as well;
lpr
<file> prints a file in background. To check the
status of the printing queue, use lpq
; to remove a file from the
printing queue, use lprm
;
mc
is a great file manager;
pine
is a nice e-mailing program;
script <script_file>
copies to script_file
what appears on screen until you issue the command exit
. Useful
for debugging;
sudo
allows users to perform some of root's tasks (e.g.
formatting and mounting disks; RMP);
uname -a
gives you info about your system;
zcat
and zless
are useful for viewing gzipped text files
without ungzipping them. Possible use:
$ zless textfile.gz
$ zcat textfile.gz | lpr
bc, cal, chsh, cmp, cut, fmt, head, hexdump, nl, passwd, printf, sort, split, strings, tac, tail, tee, touch, uniq, w, wall, wc, whereis, write, xargs, znew.
RMP.
You may come across scores of file extensions. Excluding the more exotic ones (i.e. fonts, etc.), here's a list of who's what:
.1 ... .8
: man pages. Get man
.
.arj
: archive made with arj
. unarj
to unpack.
.dvi
: output file produced by TeX (see below). xdvi
to
visualize it; dvips
to turn it into a postscript .ps file.
.gif
: graphic file. Get seejpeg
or xpaint
.
.gz
: archive made with gzip
.
.info
: info file (sort of alternative to man pages). Get
info
.
.jpg, .jpeg
: graphic file. Get seejpeg
.
.lsm
: Linux Software Map file. It's a plain ASCII file
containing the description of a package.
.ps
: postscript file. To visualize or print it get gs
and,
optionally, ghostview
.
.tgz, .tar.gz
: archive made with tar
and compressed with
gzip
.
.tex
: text file to submit to TeX, a powerful typesetting program.
Get the package tex
, available in many distributions; but beware of
NTeX, which has corrupted fonts and is part of Slackware until
version 96.
.texi
: texinfo file (cp. .info
). Get texinfo
.
.xbm, .xpm, .xwd
: graphic file. Get xpaint
.
.Z
: archive made with compress
.
.zip
: archive made with zip
. Get zip
and unzip
.