Here are some tips for the novice in our newest column designed for the newcomer to Linux.
By Mike List
Welcome to installment 3 of Clueless at the Prompt. Thanks for the encouraging e-mail. In response to several requests, here is a little information to help you get your feet wet.
If you are familiar with that other windowing system, you may be aware of the concept of multitasking. Using a single computer to do several applications at once is a highly desirable trait for an operating system (OS).
It's fairly obvious how to accomplish this in a windowing environment, but not so obvious at the shell prompt. Here are some of the details.
When you start a program at the shell prompt, you can stop it by typing:
Ctrl-Zwhich returns you to the shell prompt. Then type:
bgand the program or job is restarted in the (b)ack(g)round. A job can also be put in the background from the beginning by typing an ampersand (&) at the end of the command, e.g., make filename&. Running your job in the background allows you to run another job at the same time without changing to a different virtual console (VC). The job can be brought back to the (f)ore(g)round by typing: fg, if its the only background job, or fg jobno, if there is more than one.
You can change to a different VC by using the Alt-F2 (through F6) command. Each one of these can also be used in the manner that I have described, to the extent that you can easily run out of resources in a fit of deep-hack-mode euphoria, if you aren't careful. If you get really exuberant, you could even forget which jobs you have running. Relax, you can ``remember'' them by typing:
jobsThis command lists all jobs running in the background, much like the ps command lists all processes that are currently using up your precious memory and CPU.
When you boot up Linux, your file system or rather your hard drive must be mounted, so that the file system can be read and acted on. Your floppy drive, tape backup or CD-ROM cannot be automatically mounted, so you may need the mount utility. For example:
mount -t ext2 /dev/fd0 /mntor:
mount -t msdos /dev/fd0 /mntmounts your floppy drive (called a: by DOS) to a directory called /mnt from which you can access files on floppy disks. In the first example, the /mnt directory can be read into the ext2 file system, while the second reads floppies written in MS-DOS format. To read the contents of the floppy drive, which is now /mnt you can type:
cd /mntthen, ls or less filename.
In a similar manner, you can mount your other floppy drives, tape drives, CD-ROMs or other read/write devices. These devices can be unmounted using the command:
umount /dev/fd0or umount /dev/whateveryoumounted<\n>.
Here are a few tips that can make your Linux life a little easier.
Suppose you make a typo in your command that you don't catch until after you press enter. If the environment variable FCEDIT is set to emacs (default for the bash shell), you can correct it without retyping the whole command by tapping the up arrow key to bring back the previous command for editing with emacs. In fact, you can use the up arrow key to go up through the history file and the down arrow to come back down if you go too far. If FCEDIT is set to vi (default for the ksh shell), press ESC (escape key) then use k to go up the history file and j to go down, and of course, use vi to edit the faulty command.
To change back to a directory you have just left or to scan subdirectories, use:
c -in the following manner. Change from your /home directory to the main trunk directory:
cd /then, to look at the top level of each directory, for instance, type:
cd usrthen ls. If you didn't find what you were looking for, type:
cd -
and you will find yourself at the trunk / again. Unfortunately, you can only go one layer deep, but it is still useful when you install a source package and want to check out the contents of each of the subdirectories.
Sometimes, at least at first, you may not know how to stop a program or process that's running, but you are unwilling to let it slowly eat up your memory or CPU overhead. To get rid of it, first find its pid (process identification) number by typing:
ps -ato get a list of all running processes. Make note of the pid number and type:
killThere is another way to do this that is actually easier. Browse through the LSM (Linux Software Map) for a utility, actually a nicety, called die-1.1. You can unpack this utility into a directory or use installpkg dopkg or whatever your single package installation utility is. Then look for the /die-1.1 and cd to it. This directory contains a couple of files: a source file called die11.c and a documentation file called die.doc.
Assuming that you have installed the GCC compiler, just type:
gcc -o die die11.chit ENTER, and presto, you've compiled the die utility. Just mv it to a directory in your path, and if you like, mv the die .doc to /usr/doc or somewhere it can be with other help text friends (but not man pages, they'll pick on it unmercifully). Now, next time you're in a quandary about how to gun down a process just type:
dieand it will do the deed without having to look up the pid number. To find out more about die just type:
diewith no argument and it will give you a summary of the commands you can try the up arrow keys on.
You have probably noticed that this column is shorter than the previous two, presumably since Linux is really an easy OS to learn so my curve isn't as steep; or maybe it's the fact that I have gone half crazy trying to install a DECvt220 to a serial port and it refuses to cooperate.
Next Time--let me know what you would like to see in this column, and I'll try to oblige. Just e-mail (troll@net-link.net) me and ask; otherwise, I'll just write about what has given me trouble and how I got past it.
Mike List is a father of four teenagers, musician, printer (not laser jet), and recently reformed technophobe, who has been into computers since April,1996, and Linux since July. He can be reached via e-mail at troll@net-link.net.