Monday, October 29, 2001


Linux is a multitask Operating System, meaning that it can do many things at the same time. Well, not quite so, as the CPU will do just one thing at a time, but the OS will keep swapping processes into the CPU at high speed, and it will look to humans like the computer is doing many things at a time.

So a process, loosely speaking, is a task that the machine is doing at certain time (I will assume that the computer is doing many things, not getting into which one is actually being executed in the CPU). If you want to check processes you can use the ps command. For example, to see all processes run by you in your terminal (the place where you type your commands) you shold do


Some processes, task, programs, whatever you want to call it, are not started in the command line. What I mean is that you might have started a command with a mouse or some other method, rather than typing it in the terminal. Those processes will not show with just ps. So if you have a browser started with a mouse click, and want to see it in the processes list you have to do the following:

ps x

Ths way ps was called will show you only processes started by you. If you want to see all processes running in the system you will have to do the following:

ps ax

The ps command gives very simple output, which I will explain in some other post. If you want to see how the commands "fight" for resources you can use the top command (use the key q to quit).

All processes are competing for the system resources, as you can see in the output of top, their priorities set up by the Operating System based on a bunch of algorithms and certain hardware constrains. But you can be nice and start a process with low priority, if you are not in a hurry to get the output. That can be done with a command like the following:

nice command

where command means exactly that, the command you want to execute.

As explained in my previous post, in a Linux computer many processes can run at the same time. I wrote how to use the nice command to start a process with priority lower than usual. This simple means that the Operating System will consider that process as something that can wait for execution, in case several processes are competing for resources (memory, CPU, hard disk writing/reading, etc).

But suppose you have started a process (a command) and you want to make it run with lower priority than the current one. How do you do that? Well, first of all, why would you want to do that? One reasons could be because you want another process to finish fast, so you need to put other processes in low priority. Well, one possible way to do it is by using the top command. Start it as follows, so you see only your processes:

top -u your-use-name

Look for the name of the process you want to slow down in the last column, then type r; the computer will ask you for the PID of the process, which is the first column in the output; type it. Then the computer will ask for the priority you want to give to that process. Here you have to give a positive integer. The bigger the integer the slower the process will run.

Another way of making a process slow down is with a command as this:

renice integer process-number

Here integer is again the priority. To get the process number use ps x as explained in the previous post.

What about making processes run faster? You would think that is natural, and giving a negative integer to top or renice will do that. Unfortunately only the superuser (root account) can do that.

Saturday, October 20, 2001

Converting Files to Postscript

a2ps (Anything to PS) is a program that converts files to PostScript, the language used for graphics and understood by many printers, especially laser printers. You might want to use a2ps for example to print "text files" (like email) in both sides of the paper in a printer with duplex option. Or you can also use it to print "two pages in one," that is, reduce the size of each page by 50% and print two of them in one single sheet of paper.

Without any options you can use the command like this:

a2ps file-name

This will convert the file file-name into a PS file; the output will come to the terminal, which is not very useful unless you can either save it or process it further. To save the output in a file you can do the following:

a2ps -o output-file file-name

To print the file directly (in a printer that understands PS) you could do this:

a2ps file-name | lpr -Pprinter-name

(I have not explained yet the lpr command; I will do it in a future post).

The above option (sending the file to a printer) can be done with an option of a2ps as follows:

a2ps -P printer-name file-name

There are many different options for a2ps. Here are some useful ones.

  1. -r to print in landscape mode, -R in portrait mode
  2. -1, -2,…, -9 to have 1, 2,…, 9 pages printed in a single sheet of paper (I find -2 and -4 the most useful options).
  3. -j to print borders around columns, –borders=no for no borders
  4. -B (or –no-header) for no header information (which usually contains the file name, user, date and things like that, printed at the top of the pages).
  5. –font-size=SIZE to use fonts of certain SIZE
  6. -L NUM to scale fonts to print NUM of lines per page
  7. -l NUM to scale fonts to print NUM of colums per page
  8. -b TEXT to put TEXT as the header of the pages
  9. –left-title TITLE and –right-title TITLE to set titles at the left and right ends of the pages
  10. -c or –truncate-lines=no to cut or not long lines
  11. -i or –interpret=no to understand TABS or not
  12. –print-anyway=yes or –print-anyway=no to force or not binary printing
  13. -P printer-name to send output directly to the printer (via the printing program of your machine)
  14. -n NUM to print NUM of copies of each page

You can look at the manual page for more information. I use a2ps in two different ways:

a2ps -r -2 -j –no-header -i


a2ps -r -2 -j -i

to print with and without headers respetively, "two pages in one" in landscape mode.

Wednesday, October 03, 2001

Crytographic File System

Here I will explain how to use, cfs, the Cryptographic Filesystem. This is a filesystem (that is, a way of organizing file in the hard disk or other storage device) where all files are encrypted. I will not explain how to install cfs, since it requires a bit of background, and thus I leave it for a future post. But I will explain how to use it, assuming that is installed in your machine.

To check if cfs is installed execute the command mount. You should get some file system with the name cfs or similar. For example, in my machine I get the following among many other output lines (output is split so you can easily read it):

localhost:/var/lib/cfs/.cfsfs on /var/cfs type nfs

This means that the cfs is in the directory called /var/cfs.

To store files in the cfs you need to make a directory with a special command, for example:

cmkdir crypted

This will create a directory called crypted that you can use under cfs. You will be ask to enter (and confirm) a key that will be needed any time you want to work in that directory. The key should be at least 16 characters long (at least in my system). Warning: if you forget the key you will not be able to recover your files, not even the superuser can do it. So put a complicated key, but something you can remember.

To write or edit files in encrypted form first you need to make the directory crypted "available" to cfs. That is done as in this example:

cattach crypted directory12345

The last word should be a unique name for cfs to work on your directory. You can put some arbitrary thing, or a name based on a PID (whatever that is :-) ), etc.

Now you can save files in encrypted form under the directory /var/cfs/directory12345. Do not work on the directory crypted but in the name you gave in the attach command. Actually, the full name of the directory is also has the part where cfs "lives" as you can see in the above example: /var/cfs is the cfs parent directory (the result of mount) and directory12345 is the name you gave.

Work on files in that directory as you work on files in any other directory. When you finish saving, editing, removing your files, you have to detach the directory with a command like this:

cdetach directory12345

Then all your files in that directory will get actually saved in the crypted directory, encrypted, so your data is safe from other users’ eyes.