File Permissions Changing

File Permissions Changing


Firstly, normal users can only change the permissions of a file (or directory) if they own it. The owner of a file can be found by again using the "ls -l" command as shown below.

ls -al output showing file owner

Changing a files permissions is done by using the "chmod" (change mode) command. This command is used in two ways, either using numbers or letters.

Using letters (symbolic codes)

First you have do decide what section of the permissions to set, this is done by specifying the first letter of the section, eg. "g" for group permissions. More than one section can given in a single command eg. typing "ug" will set the permissions for the files owner and all users thier group. Not specifying a section will be that all sections permissions will be changed.

Next you need to give the actual permissions you want to set. using a "+" in front of a permission bit will set it and using a "-" will unset it. For example "+w" will grant write access to the file. More than one permission bit can be given in a command along with different signs.

Here are some examples, that show make things clearer:

Current permissionsCommand issuedNew permissions
-rw-r--r--chmod +x filename-rwxr-xr-x
-rw-r--r--chmod u+x filename-rwxr--r--
-rwxrwxrwxchmod go-wx filename-rwxr--r--

Using numbers (octal)

Most UNIX users find this method the quickest. All you need to do is refer to the first table on this page and look at the numbers for each permission bit. Then add together the values for the permissions you want the file to have. For example:

Start at 0 as old permissions get overwritten.
Add 400 for read access to the files owner (you).
Add 200 for write access to the files owner.
Add 40 for read access to all other users in the owners group
Add 4 for read access to everyone else.
Total = 0644 (it is best to always use four digits).
This number is then used in the "chmod" command like this; "ls 0644 filename". This file will will then have the permissions of "-rw-r--r--" under the "ls -l" output.

download file now

Unknown

About Unknown

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :