Wednesday, September 1, 2010

Unix file system : Permissions

The file /etc/passwd is the password file. It contains all the login information about each user. We can discover each users id and group id by looking name in /etc/passwd.

$grep name /etc/passwd

The fields in the password file looks like 'login-id:encrypted password:uid:group-id:miscellany:login-directory:shell'. The -l option of ls command prints the permissions.

$ls -l

We can find a string like '-rw-r--r--' . The first - means that it is an ordinary file. If it is a directory there prints a 'd'. The next three field is the permissions of the owner followed by the next three field is the permissions of the group and the next is the others permissions. We cannot edit the passwd file . But the super user can do it.


The 'chmod' command changes the permissions of a file. 'permissions' may occupy octal numbers. The '+' sign is for 'ON' permission modes and to OFF the '-' sign is using. The '-w' option is for turn off the write permisssion for all incliding the owner. '+x' allows every one to execute the following command.

$ chmod permissions filename
$ chmod -w filename
$ chmod +x command
$ chmod -w .
$ chmod 775 filename //Restores the permission.

The '-w .' means removing the write permission of all files in that directory.

No comments:

Post a Comment