File Permissions

Hi,

How to give a read permission to a particular file for a non-root user?

Ex:

The below file owner is oracle but how can i add\remove permission for another user.

-rw-r--r-- 1 oracle dba 1540330 Dec 21 2005 ojdbc14.jar

~Vinodh' Kumar

cannot understand exactly what you mean.

for giving permission to other user, you can use

chmod o+r filename

also, your file has read permission for others already.

References: Understanding UNIX permissions and chmod ( google search )..

see the following command:

it will give the read and write permission to the user and others will have only read permission.

chmod 644 file-name

If I understand you correctly, the only way to do this is with ACLs. If your filesystem is Posix ACL capable you can do:

# setfacl -m mask:rw- ojdbc14.jar
# setfacl -m user:someone:rw- ojdbc14.jar
# setfacl -m group::r-- ojdbc14.jar
# ls -l ojdbc14.jar
-rw-r--r--+ 1 oracle dba 1540330 Dec 21 2005 ojdbc14.jar
# ls -V ojdbc14.jar
-rw-r--r--+ 1 oracle dba 1540330 Dec 21 2005 ojdbc14.jar
     0:user::rw-
     1:user:someone:rw-         #effective:rw-
     2:group::r--               #effective:r--
     3:mask:rw-
     4:other:r--

(Output puzzled together from your output and mine).
The first command changes the ACL mask to "rw" to allow users to have rw-access. The second adds the second username "someone" to the ACL. The third command corrects the fact, that the group got rw-access by changing the ACL mask. Example shown for solaris. The commands may differ on other OS.

Using chmod command we can achieve this.

There are two ways.

symbolic mode:
---------------------
In this the permissions are represented by symbols.
to give read permissions we need to give r.
to give write permissions we need to give w.
to give execute permissions we need to give x.
For giving these permissions to the owner(user) of the file we will give u.
For giving permissions we will use +.
For revoking permissions we will use -.

So u+x will give execute permissions to the user.
u-w will remove the write permission from the user

Example : chmod u-r file_name

Octal mode:

In this mode the permissions are represented by octal number
read permission -> 4
write permission -> 2
execute permission -> 1

So chmod 751 file_name
This will give 7(4+2+1) to the user (so the user will have all the read,write.execute) permissions
The group will have 5(4+1) read and execute permission. So they wont have write permission and so on