-->
Page 320
The preceding example used the -c option to check the disk for any bad blocks, and the -L option to give the floppy a name. In order to see what's going on, it also used the -v (verbose mode) option. The mke2fs command will automatically determine the size of your floppy, check it using the badblocks command, found under the /sbin directory, and then create your Linux filesystem. You might also want to use the -m option with a value of 0 to have the most room available, and specify the high-density floppy device (by default, mke2fs will reserve five percent of the filesystem for the root operator), as follows:
# mke2fs -m 0 /dev/fd0H1440 1440
As a final step, you can mount the floppy, using the mount command, and then check the floppy's size, for example:
# mount -t ext2 /dev/fd0 /mnt/floppy # df /dev/fd0 Filesystem 1024-blocks Used Available Capacity Mounted on /dev/fd0 1390 13 1377 1% /mnt/floppy
Knowing how to format floppy drives is important. If you're only interested in DOS floppies, you'll want to explore the mtools package, discussed next.
The mtools package is a set of programs you can use in just about any operation on MS-DOS floppies. These utilities include
Page 321
This hour doesn't cover all these utilities, but from the list, you should be able to see that the most often used will be the mformat, mdir, mcopy, and mdel commands. The mformat command will format nearly any type of floppy device. One nice feature of this package of software is that you don't have to remember the specific names of floppy devices, such as
/dev/fd0, and can use the (possibly) familiar A: or B: drive designators. For example, to format a floppy in your drive A:, you would use
# mformat a:
This will automatically format your disk. After the mformat command has finished, you can copy files to and from the disk with the mcopy command, for example:
# mcopy *.txt a:
This will copy all files ending in .txt to your disk. To copy files from your disk, just reverse the arguments (in DOS form) to the mcopy command:
# mcopy a:*.txt
This will copy all files ending in .txt to the current directory, or a directory you specify. To see what is on the disk, use the mdir command, for example:
# mdir a:x*.* Volume in drive A has no label Directory for A:/ xena msg 8708 11-21-1997 12:14p xena.msg xgames msg 2798 11-21-1997 12:14p xgames.msg xrpm msg 3624 11-21-1997 12:14p xrpm.msg 3 file(s) 15 130 bytes 1 067 008 bytes free
To label the disk, you can use the mlabel command, for example:
# mlabel a: Volume has no label Enter the new volume label : LINUX
Page 322
To delete files on your disk, use the mdel command:
# mdel a:*.txt
This will delete all files ending in .txt on the disk in the a: drive. You've learned the basic operations, but you can also mount your disk. For details, see the mmount manual page, along with the mount command manual page. Now that you know how to manage different filesystems, the next section covers how to manage your files.
Managing files in Linux means more than moving files around the file system or keeping
files grouped by similar behavior or topic. You can change which user or group owns a file or directory, and whether or not you, your group, or others can read, write, or execute (run) your files.
The chmod (change access permissions) command, found under the /bin directory, is used to give or take away permission of groups or others to your files. Before you can begin to use the chmod program, you should understand Linux files and how Linux handles file permissions. In Hour 4, "Reading and Navigation Commands," you learned how to get a long-format directory listing using the -l option with the ls (list) command. This option shows the mode and permissions flags of files, for example:
# ls -l book/*doc -rw-r--r-- 1 bball bball 78073 Nov 16 19:58 book/24hr06or.doc -rw-r--r-- 1 bball bball 52287 Nov 16 19:57 book/24hr11or.doc
The mode and permissions flags for directories and files is listed in the first column, and consists of a sequence of 10 letters. The first letter tells you the type of file.
There are at least eight file types in Linux, but these are the four most common ones:
You'll usually find block and character devices under the /dev directory. Your modem or printer port on your PC will probably be a character device, whereas your floppy drive is a block device, for example:
# ls -l /dev/lp0 /dev/cua1 /dev/fd0 crw-rw---- 1 root uucp 5, 65 Dec 31 1979 /dev/cua1 brw-rw---- 1 root disk 2, 0 Sep 15 23:48 /dev/fd0