Next Previous Contents

11. The Remaining 1%

Much more than 1%, actually...

11.1 Running DOS/Windows Apps

Yes, you can to some extent run DOS and Windows applications under Linux! There are two emulators that are quite good: Dosemu ( http://www.dosemu.org) and Wine ( http://www.winehq.com). The latter is getting better release after release, and the list of runnable applications is getting larger. It even runs Word and Excel!

11.2 Using tar and gzip

Under UNIX there are some widely used applications to archive and compress files. tar is used to make archives---it's like PKZIP or Winzipbut 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 xvf <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:

$ compress -d <file.Z>
$ gzip -d <file.gz>

RMP.

There are also the unarj, zip and unzip (PK??ZIP compatible) utilities. 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:

$ tar ztf <file.tar.gz> | less

11.3 Installing Applications

First of all: installing packages is root's work. Most Linux applications are distributed as a .tar.gz archive, which typically will contain a directory aptly named containing files and/or subdirectories. A good rule is to install these packages from /usr/local with the command

# tar zxf <archive.tar.gz>

reading then the README or INSTALL file. In most cases, the application is distributed in source, which you'll have to compile; often, typing make then make install will suffice. If the archive contains a configure script, run it first. Obviously, you'll need the gcc or g++ compiler.

Other archives have to be unpacked from /; this is the case with Slackware's .tgz archives. Other archives contain the files but not a subdirectory - careful not to mess things up! Always list the contents of the archive before installing it.

Debian and Red Hat have their own archive format; respectively, .deb and .rpm. The latter is widely used by many distributions; to install an rpm package, type

# rpm -i package.rpm

11.4 Tips You Can't Do Without

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 it, 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: if you installed gpm, a mouse driver for the console, you can 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. The command dmesg is also handy.

11.5 Where to Find Applications

If you're wondering whether you can replace your old and trusted DOS/Win application with a Linux one, I suggest that you browse the main Linux software repository: ftp://metalab.unc.edu/pub/Linux. Other good starting places are the ``Linux Applications and Utilities Page'' http://www.xnet.com/~blatura/linapps.shtml, the ``official'' Linux page http://www.linux.org, and http://freshmeat.net.

11.6 A Few Things You Couldn't Do

Linux can do an awful lot of things that were cumbersome, difficult or impossible do to with DOS/Windows. Here's a short list that may whet your appetite:

  • at allows you to run programs at a specified time;
  • awk is a simple yet powerful language to manipulate data files (and not only). For example, being data.dat your multi field 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''.
  • cron is useful to perform tasks periodically, at specified date and time. Type man 5 crontab.
  • file <filename> tells you what filename is (ASCII text, executable, archive, etc.);
  • find (see also Section Directories: Translating Commands) 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.
  • 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;
  • regular expressions are a complex but darn powerful way of performing search operations on text. For example, ^a[^a-m]X{4,}txt$ matches a line that starts with `a', followed by any character except those in the interval a-m, followed by 4 or more `X', and ends in `txt'. You use regular expressions with advanced editors, less, and many other applications. man grep for an introduction.
  • script <script_file> dumps the screen contents on script_file 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 browsing and piping gzipped files without decompressing them. For example:
    $ zless textfile.gz
    $ zcat textfile.gz | lpr
    
  • The following commands often come in handy: 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.

11.7 Practicing UNIX under DOS/Win

Believe it or not, there are fine tools that provide a UNIX-like environment under DOS/Windows! One is the Djgpp suite ( http://www.delorie.com/djgpp/) for DOS, while Cygwin ( http://www.cygnus.com/cygwin) is a more complex port for Win32. Both include the same GNU development tools and utilities as Linux; you won't get the same stability and performance, though.

If you'd like to have a taste of Linux, try out Djgpp. Download and install the following files (as of this writing, the latest version is 2.02): djdev202.zip, bnu281b.zip, bsh1147b.zip, fil316b.zip, find41b.zip, grep22b.zip, gwk303b.zip, lss332b.zip, shl112b.zip.. Installation instructions are provided, and you can find assistance on news:comp.os.msdos.djgpp.

In particular, using bash under DOS/Win is a whiff of fresh air. To configure it properly, edit the supplied file BOOT.BAT to reflect your installation, then put these files in your home directory (in the Windows partition) instead of those provided:

# this is _bashrc

LS_OPTIONS="-F -s --color=yes"
alias cp='cp -i'
alias d='ls -l'
alias l=less
alias ls="ls $LS_OPTIONS"
alias mv='mv -i'
alias rm='rm -i'
alias u='cd ..'

# this is _bprof
if [ -f ~/_bashrc ]; then
  . ~/_bashrc
fi
PS1='\w\$ '
PS2='> '
CDPATH="$CDPATH:~"
# stuff for less(1)
LESS="-M-Q"                     # long prompt, silent
LESSEDIT="%E ?lt+%lt. %f"       # edit top line
VISUAL="jed"                    # editor
LESSCHARSET=latin1              # visualise accented letters
export PS1 PS2 CDPATH LS_OPTIONS LESS LESSEDIT LESSOPEN VISUAL LESSCHARSET

11.8 Common Extensions and Related Programs

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. Read them with groff -Tascii -man <file.1>.
  • arj: archive made with arj.
  • dvi: output file produced by TeX (see below). xdvi to visualise it; dvips to turn it into a PostScript .ps file.
  • gz: archive made with gzip.
  • info: info file (sort of alternative to man pages). Get info.
  • lsm: Linux Software Map file. It's a plain ASCII file containing the description of a package.
  • ps: PostScript file. To visualise or print it get gs and, optionally, ghostview or gv.
  • rpm: Red Hat package. You can install it on any system using the package manager rpm.
  • taz, tar.Z: archive made with tar and compressed with compress.
  • tgz, tar.gz: archive made with tar and compressed with gzip.
  • tex: text file to submit to TeX, a powerful typesetting system. Get the package tex, available in many distributions.
  • texi: texinfo file, can produce both TeX and info files (cp. info). Get texinfo.
  • xbm, xpm, xwd: graphic file.
  • Z: archive made with compress.

11.9 Converting Files

If you need to exchange text files between DOS/Win and Linux, be aware of the ``end of line'' problem. Under DOS, each line of text ends with CR/LF (that is, ASCII 13 + ASCII 10), with LF under Linux. If you edit a DOS text file under Linux, each line will likely end with a strange--looking `M' character; a Linux text file under DOS will appear as a kilometric single line with no paragraphs. There are a couple of tools, dos2unix and unix2dos, to convert the files.

If your text--only files contain accented characters, make sure they are made under Windows (with Notepad) and not under plain DOS; otherwise, all accented characters will be screwed up.

11.10 Free Office Suites

Yes, you can have for free what would otherwise cost a lot of money!

StarOffice ( http://www.sun.com/staroffice.) is currently the only choice, though Koffice is down the pipeline ( http://www.koffice.org). StarOffice is big and slow, but very good anyway: it offers a lot of functionality not found in Microsoft Office. It can also read and write Word and Excel files, although the conversion isn't always perfect.

Another good package is Corel WordPerfect, a free edition of which is available for download. Need I say more? Go fetch it: http://www.corel.com.


Next Previous Contents
Copyright © 2010-2024 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout