Debian GNU/Linux: Guide to Installation and Usage - John Goerzen and Ossama Othman (top fiction books of all time .txt) 📗
- Author: John Goerzen and Ossama Othman
- Performer: -
Book online «Debian GNU/Linux: Guide to Installation and Usage - John Goerzen and Ossama Othman (top fiction books of all time .txt) 📗». Author John Goerzen and Ossama Othman
Say you end your .xsession with the line exec fvwm. This means that the fvwm window manager will be run when X starts. When you quit the fvwm window manager, your X session will end, and all other clients will be shut down. You do not have to use a window manager here; you could exec xterm, in which case typing exit in that particular xterm would cause the entire X session to end.
If you want to run other clients before you use exec, you will need to run them in the background. Otherwise .xsession will pause until each client exits and then continue to the next line. See the previous section on running jobs in the background (basically you want to put an ampersand at the end, as in xterm &).
You can take advantage of this behavior, though. If you want to run commands at the end of your X session, you can have your .xsession run a window manager or the like and wait for it to finish. That is, leave off the exec and the &; just enter fvwm by itself. Then put the commands of your choice after fvwm.
It would probably help to look at a few sample .xsession files. In all the examples, replace fvwm with the window manager of your choice.
The simplest .xsession just runs a window manager: exec fvwm
This will run fvwm, and the X session will end when fvwm exits. If you do it without the exec, everything will appear to behave the same way, but behind the scenes .xsession will hang around waiting for fvwm, and .xsession will exit after fvwm does. Using exec is slightly better because fvwm replaces .xsession instead of leaving it waiting. You can use the ps or top command to verify this.
A more useful .xsession runs a few clients before starting the window manager. For example, you might want some xterms and an xclock whenever you start X. No problem; just enter xterm & xterm & xclock & exec fvwm.
Two xterms and an xclock start up in the background, and then the window manager is launched. When you quit the window manager, you’ll also quit X.
You might try it without the backgrounding just to see what happens. Enter this command: xterm xclock exec fvwm. xterm will start, and wait for you to exit it. Then xclock will start; you’ll have to exit xclock before fvwm will start. The commands are run in sequence, since the script waits for each one to exit.
You can use sequential execution to your advantage. Perhaps you want to keep track of when you stop working every day: xterm &
xclock &
fvwm
date >> ~/logout-time
This will fork off an xterm and an xclock and then run fvwm and wait for it to finish. When you exit fvwm, it will move on to the last line, which appends the current date and time to the file ~/logout-time.
Finally, you can have a program other than the window manager determine when X exits:
xclock &
fvwm &
exec xterm
This script will run xclock and fvwm in the background and then replace itself with xterm. When you exit the xterm, your X session will end.
The best way to learn how to use .xsession is to try some of these things out. Again, be sure you use chmod to make it executable; failure to do so is a common error.
Filesystems A Debian system uses a filesystem to store and manage your data. This chapter introduces you to the filesystem, describes how to add and remove filesystems, and shows you how to back up your system.
Concepts
It’s probably a good idea to explain a little theory before discussing the mechanics of using disks. In particular, you must understand the concept of a filesystem. This can be a bit confusing because it has several meanings.
The filesystem refers to the whole directory tree, starting with the root directory /, as described in earlier chapters.
A filesystem in general means any organization of files and directories on a particular physical device. “Organization” means the hierarchical directory structure and any other information about files one might want to keep track of: their size, who has permission to change them, etc. So you might have one filesystem on your hard disk, and another one on each floppy disk.
“Filesystem” is also used to mean a type of filesystem. For example, MS-DOS and Windows 3.1 organize files in a particular way, with particular rules: Filenames can have only eight characters, for example, and no permission information is stored. Linux calls this the msdos filesystem.
Linux also has its own filesystem, called the ext2 filesystem (version two of the ext filesystem). You’ll use the ext2 filesystem most of the time unless you’re accessing files from another operating system or have other special needs.
Any physical device you wish to use for storing files must have at least one filesystem on it. This means a filesystem in the second sense - a hierarchy of files and directories, along with information about them. Of course, any filesystem has a type, so the third sense will come into play as well. If you have more than one filesystem on a single device, each filesystem can have a different type - for example, you might have both a DOS partition and a Linux partition on your hard disk.
mount and etcfstab This section describes how to mount a floppy or Zip disk, discusses the /dev directory, and addresses distributing the directory tree over multiple physical devices or partitions.
Mounting a Filesystem
On a GNU/Linux system there’s no necessary correspondence between directories and physical devices as there is in Windows, in which each drive has its own directory tree beginning with a letter (such as C:).
Instead, each physical device such as a hard disk or floppy disk has one or more filesystems on it. In order to make a filesystem accessible, it’s assigned to a particular directory in another filesystem. To avoid circularity, the root filesystem (which contains the root directory /) is not stored within any other filesystem. You have access to it automatically when you boot Debian.
A directory in one filesystem that contains another filesystem is known as a mount point. A mount point is a directory in a first filesystem on one device (such as your hard disk) that “contains” a second filesystem, perhaps on another device (such as a floppy disk). To access a filesystem, you must mount it at some mount point.
So, for example, you might mount a CD at the mount point /cdrom. This means that if you look in the directory cdrom, you’ll see the contents of the CD. The cdrom directory itself is actually on your hard disk. For all practical purposes, the contents of the CD become a part of the root filesystem, and when you type commands and use programs, it doesn’t make any difference what the actual physical location of the files is. You could have created a directory on your hard disk called /cdrom and put some files in it, and everything would behave in exactly the same way.
Once you mount a filesystem, there’s no need to pay any attention to physical devices.
However, before you can mount a filesystem or actually create a filesystem on a disk that doesn’t have one yet, it’s necessary to refer to the devices themselves. All devices have names, which are located in the /dev directory. If you type ls /dev now, you’ll see a pretty lengthy list of every possible device you could have on your Debian system. For a summary of some devices, see Table 2.1 on page [*]. A more thorough list can be found on your system in the file usrsrc/linux/Documentation/devices.txt.
To mount a filesystem, we want to tell Linux to associate whatever filesystem it finds on a particular device with a particular mount point.
In the process, we might have to tell Linux what kind of filesystem to look for.
Example: Mounting a CD-ROM
As a simple demonstration, we’ll go through mounting a CD-ROM, such as the one you may have used to install Debian. You’ll need to be root to do this, so be careful; whenever you’re root, you have the power to manipulate the whole system, not just your own files. Also, these commands assume there’s a CD in your drive; you should put one in the drive now.
Then start with the following command:
su
If you haven’t already, you need to either log in as root or gain root privileges with the su (super user) command. If you use su, enter the root password when prompted.
ls /cdrom
Use this command to see what’s in the /cdrom directory before you start.
If you don’t have a cdrom directory, you may have to make one using mkdir cdrom.
mount
Simply typing mount with no arguments lists the currently mounted filesystems.
mount -t iso9660 CD-device /cdrom
For this command, you should substitute the name of your CD-ROM device for CD-device in the above command line. If you aren’t sure, devcdrom is a good guess because the install process should have created this symbolic link on the system. If that fails, try the different IDE devices: devhdc, etc. You should see a message like this: mount: block device devhdc is write-protected, mounting read-only.
The -t option specifies the type of the filesystem, in this case iso9660.
Most CDs are iso9660. The next argument is the name of the device to mount, and the final argument is the mount point. There are many other arguments for mount; see the manual page for details.
Once a CD is mounted, you may find that your drive tray will not open. You must unmount the CD before removing it.
ls /cdrom
Confirms that /cdrom now contains whatever is on the CD in your drive.
mount
Displays the list of filesystems again; notice that your CD drive is now mounted.
umount /cdrom
This unmounts the CD. It’s now safe to remove the CD from the drive.
Notice that the command is umount with no “n,” even though it’s used to unmount the filesystem.
exit
Don’t leave yourself logged on as root. Log out immediately, just to be safe.
etcfstab: Automating the Mount Process
The file etcfstab (it stands for “filesystem table”) contains descriptions of filesystems that you mount often. These filesystems can then be mounted with a shorter command, such as mount /cdrom. You can also configure filesystems to mount automatically when the system boots. You’ll probably want to mount all of your hard disk filesystems when you boot, so Debian automatically adds entries to fstab to do this for you.
Look at this file now by typing more etcfstab. It will have two or more entries that were configured automatically when you installed the system.
It probably looks something like this:
# etcfstab: static file system information.
#
# <file system> <mount point> <type> <options> #<dump > <pass>
devhda1 / ext2 defaults 0 1
devhda3 none swap sw 0 0
proc /proc proc defaults 0 0
devhda5 /tmp ext2 defaults 0 2
devhda6 /home ext2 defaults 0 2
devhda7 /usr ext2 defaults 0 2
devhdc /cdrom iso9660 ro,noauto 0 0
devfd0 /floppy
Comments (0)