File system Structure -II


We have already discussed the directory structure in Linux/Unix. You are able to find files and directories that you need. But there is more to the filesystem than just the directory structure.

Linux/Unix is a multiuser operating system. Every aspect of the system is multiuser, even the filesystem. The system stores information like who owns a file and who can read it. There are other unique parts about the filesystems, such as links and NFS mounts. This section explains these, as well as the multiuser aspects of the filesystem.

In Linux/Unix, all files are protected under some access control mechanism, so that the owner of a file can deny access of his files to other users. The first column of the long directory list shows the access characteristics of a file, in te form of 10 flags, e.g. drwxr-xr-x.

drwxr-xr-x  18 gaurav gaurav    784 2005-04-14 08:31 .


The meanings of the flags are shown below:

Position 1       file type: d (directory) 
- (ordinary file)
l (symbolic link)

Position 2-4 permissions for the owner: r (read)
w (write)
x (execute)

Position 5-7 permissions for other users in the same group

Position 8-10 permissions for all other users

Note that a hyphen (`-') denotes lack of the given permission type. For example, r-x would mean that read and execute permission are granted, but not write permission.

In order to remove a file, you must have write permission for it.

In order to view the contents of a directory, i.e. see what files are there, you need read permission for that directory. In order to actually access a file (read from it, write to it, or execute it) in the directory, you need execute permission for the directory.

Ownership

The filesystem stores ownership information for each file and directory on the system. This includes what owner and group own a particular file. The easiest way to see this information is with the ls command:


$ ls -l /usr/bin/wc
-rwxr-xr-x 1 root bin 7368 Jul 30 1999 /usr/bin/wc

We are interested in the third and fourth columns. These contain the username and group name that owns this file. We see that the user “root” and the group “bin” own this file.

We can easily change the file owners with the chown(1) (which means “change owner”) and chgrp(1) (which means “change group”) commands. To change the file owner to “daemon”, we would use chown:


# chown daemon /usr/bin/wc

To change the group owner to “root”, we would use chgrp:


# chgrp root /usr/bin/wc

We can also use chown to specify the user and group owners for a file:

# chown daemon.root /usr/bin/wc

File ownership is a very important part of using a Linux system, even if you are the only user. You sometimes need to fix ownerships on files and device nodes.



References:
http://slackware.com
http://heather.cs.ucdavis.edu/~matloff/UnixAndC/Unix/FileSyst.html



http://www.linux-iips.tk