Changing File Permissions and Adding a Zip Drive

Files and directories under Linux have access permissions for the individual owner of the file or directory, any members of a group that might own the file or directory, and everyone else who might want to read or write it. There are three types of access permission: read, write, and execute. Read allows you to look at a file's contents. Write allows you to change or delete the file. Execute allows you to run the file as a program. Running ls -l at a command-line prompt will list the file and directory attributes in the current directory. A sample file entry would look like Listing One.

Can you do something on file permissions for newbies? I have searched for an easy way of remembering/using chmod. Specifically, remembering what the different number codes mean (i.e., 777, 570, etc.).

The GUI Way: In addition to the command line, permissions can also be set through a file manager.

Files and directories under Linux have access permissions for the individual owner of the file or directory, any members of a group that might own the file or directory, and everyone else who might want to read or write it. There are three types of access permission: read, write, and execute. Read allows you to look at a file’s contents. Write allows you to change or delete the file. Execute allows you to run the file as a program. Running ls -l at a command-line prompt will list the file and directory attributes in the current directory. A sample file entry would look like Listing One.

The string of 10 characters to the far left (-rwxr-xr-x) are what we are interested in. The - in the first position means that this is a normal file. An l would indicate that this file is really a link to another file and a d would indicate that the file is a directory. The next nine characters represent the read (r), write (w), and execute (x) permissions allotted to each type of user (the file’s owner, group members, and everyone else).

For example, the next three positions (rwx) indicate the owner’s permissions; in this case, the owner has read, write, and execute permissions. The three positions following that (r-x) indicate group members’ permissions; in this case, group members can only read and execute. The - in the write field indicates the absence of the write permission. The last three positions (r-x) indicate everyone else’s permissions for that file.

When you want to change a file’s permissions, you use the chmod (which stands for “change mode”) command. If you want to add a particular permission globally (that is, to owner, group, and everyone else) to a file, you could use the + sign with chmod. For example, to add the write permission globally, you would type chmod +w [filename]. Similarly, if you want to remove a permission globally from a file, you would use the - sign. So, to globally deny the write permission, you would type chmod -w [filename]. If you want to set a file’s permissions specifically at each level, things get a little trickier.

There are actually many ways to do this (try typing man chmod to see them all), but probably the easiest way is to use a three-digit number to represent a file’s permissions. Each digit represents a level of permission (i.e., the first digit represents the owner’s permission, the second digit represents the group’s permissions, and the third digit represents everyone else’s permissions). The value of the digit represents which permissions are assigned; read has a value of 4, write has a value of 2, execute has a value of 1, and 0 means no permissions. If a particular level has more than one permission, just add the values of the different permissions.

In the above example, a three-digit representation of that file’s permissions (rwxr-xr-x) would be 755. The first number (7) indicates the owner’s permissions — read (4), write (2), and execute (1) (4 + 2 + 1 = 7). The second number (5) indicates the group’s permissions — read (4) and execute (1). The third number (5) indicates everyone else’s permissions — read (4) and execute (1). To set a file’s permissions to reflect this, you would type chmod755[filename].

I hope this answered your question.

I am adding an external Zip drive and need to know how to configure it. Can you give some tips?

I can definitely give you the information you need to get this working properly. For our purposes, I will assume that you are using either a Zip100 or Zip100plus drive. I will also assume that you have a parallel-port model.

If I am correct, the first thing we need to identify is if you have the appropriate kernel modules compiled into your system. First off, we need to make sure that the imm.o module is in your /lib/modules/2.2.x/scsi/ directory. If it’s there, then you are on your way. The next step is to create a temporary mount point for the mounting of the device once it boots. I usually use the /mnt directory for this function. In that directory, simply type mkdir /mnt/zip at a command-line prompt. You will now have to load the kernel modules into the system.

I recommend the modprobe command. I like to use the verbose switch (-v) so that I can see what’s happening when I load it up. Issuing /sbin/modprobe -v imm will create output similar to Listing Two.

Now with the /sbinlsmod/ command, you can list the modules that are currently loaded. You should see the imm.o module and the scsi_ mod.o already loaded and ready to go. Now you will need to know what device the module is being recognized as. If you type dmesg, you should see something to the effect of: imm: Version 2.03 (for Linux2.0.0) scsi:1hosts. /dev/ sda. All you are concerned with is the /dev/sda line after the driver is loaded. This is what is going to be used to mount the device against the mount point that was created earlier.

Next, mount the Zip disk to the filesystem using the mount command. The format of the Zip disk will determine exactly what type of filesystem to use following the -t switch in mount -t [filesystem]/dev/sda/mnt/ zip. There are a few filesystem options to specify, but the common ones are usually vfat, ext2, and msdos.

Now you should have the Zip recognized and mounted up. The next time you reboot and need to get the drive mounted, all you have to do is type su – modprobe -v imm mount -t [filesystem ]/dev/ sda /mnt/zip. That’s it.

App Tips

Monitoring Your System: XOS view shows your system stats in realtime.

I have been working with a bunch of monitoring tools this month, and some of them are really worth talking about. I hope you try them out.

* GkrellM This is a Gtk- and Imlib-based stacked monitor program that monitors SMP CPUs, disk, load, active net interfaces, and network connections. It also has monitors that watch memory and swap space usage along with some other filesystem meters that show disk capacity and freespace. It is highly configurable and has a very slick GUI monitoring program. http://web.wt.net/~billw/gkrellm/gkrellm.html

* Big Brother This is a neat monitoring tool that collects information about each machine it is monitoring and then broadcasts that information to a central point. This makes it easy to set up network monitoring on a small workgroup or on departmental clusters. http://bb4.com/

Gaylen Brown is a senior consultant at Linuxcare, Inc. He can be reached at tech@linux-mag.com.