by Kurt Keller
Regular readers of my columns will know that I'm a Unix guy. One aspect of Unix many beginners find complicated at first, is file permissions. But even experienced users often start scratching their head over these bits and flags when it gets down to more detailed settings. I take up the challenge of explaining what all these settings mean, starting out in part 1 with some basics and related necessary information, covering the more common and easy settings in part 2 and showing advanced settings and other things to consider in part 3. Depending on how familiar you already are with Unix file permissions, you might want to skip over some of the sections. Especially the whole of part 1 is entry level, but already part 2 contains information which sometimes even advanced Unix users don't know all that well.Learning by doing is the best approach I know. If you would like to try out what is being explained but don't have a Unix system at hand, you might want to have a look at Knoppix, available from http://www.knoppix.org/. This is a complete Linux system on a bootable CD, which does not do anything to your harddisk. You put it in your CDROM drive, boot up the computer from the CD and have a fully working Linux workstation with tons of utilities right at your fingertips. All without any installation hassles and without any changes to your computer or the software installed on it.
Please note that the commands explained here might not work on all files and directories, depending on the permissions you already have on the files and on their parent directories. After you have read part 2, such cases should be clearer, though.
Please note that some Unix installations setup environments to
automatically use some options with ls, even though they are not typed.
Possibly you should first issue the command
unalias ls
to get rid of this automatism.
I think the examples in table 1
should suffice for the
moment. If you want to know all the details about the ls command, you can
always do a
man ls
on your Unix system and read what options your version of ls supports
and what the options do.
The command chgrp (change group) can
be used to make the file owned by a different group. For example
chgrp nobody myfile
changes the owning group of the file
myfile to the group called nobody. The same syntax is being used for
changing the group on a directory.
For changing the owning user of a file or directory, chown
(change ownership) is being used.
chown alice myfile
chown alice:hergroup myfile
If there is a userID alice on your system, the first command will change
the owning user of myfile to alice. If there's a group hergroup on your
system, the second command will change both, the owning user and group
of myfile; the user to alice and the group to hergroup. On some systems
you might have to use a dot (.) instead of the colon (:) to separate the
user from the group in the seccond command. chown, just like chgrp,
works on files and directories alike.
The third field of the long file listing is the owning user, also called the owner of the file. If there is a number instead of a username, this simply means the system could not find a mapping for the userID to a username. Whenever a user creates a new file in a normal directory, (s)he will be the owner of that file. For security reasons, most systems will not allow the owner to be changed to a different user, unless the superuser, which is called root on Unix, is making the change. This kind of change is called a file giveaway.
Well then, what can you do if you are in a team, working on a certain project, and all of the team members should be able to view and possibly even update the documentation and other files related to this project? All the members of the team, but not everybody else on the system? This is exactly what groups are for. Every user on the system does not only have a unique userID, but each user is also member of one or more groups. The system administrator can create a special group for your project team and add every team member to that group. You can now make the owning group of all the project files to be this special project group and everbody who is a member of this group can access these files, provided the file permissions are correctly set. In figure 1, most of the files are owned by group mygrp, but a few files are owned by group projgrp. As with file owners, most systems will not allow a normal user to change the owning group of a file to a group that particular user is not himself a member of. And also here, if the group displayed in the long file listing is a number, the system was unable to map the groupID to a groupname.
|
| Knoppix | http://www.knoppix.org/ | |
| PINBOARD | http://www.pinboard.com/ | |
| HighTechSamurai | http://kurt.www.pinboard.com/ |