Operating System - HP-UX
1752790 Members
6516 Online
108789 Solutions
New Discussion юеВ

How to get the file access permissions?

 
SOLVED
Go to solution
Enrico Venturi
Super Advisor

How to get the file access permissions?

Hello colleagues,
How can I get the file access permissions, i.e. the number to use in the chmod to change the permissions on a certain file?
I mean 775, 777, and so on ...
Does it exist a command to read it for a file?
17 REPLIES 17
MarkSyder
Honored Contributor

Re: How to get the file access permissions?

Not quite sure I understand the question, but I think you're asking what the numbers stand for.

The first number is for the owner of the file, the second is for the group the owner belongs to, and the third is for all other users.

4 = read
2 = write
1 = execute.

4 + 2 = 6 = read and write etc.

man chmod should help if you need any more information.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Roberto Polli
Trusted Contributor

Re: How to get the file access permissions?

to get file permission simply
ls -l FILENAME

Peace, R.
Nicolas Dumeige
Esteemed Contributor

Re: How to get the file access permissions?

Hello,

The transformation is the following :
r --> 4
w --> 2
x --> 1
for each level owner / group / other.

I don't know if there is any utilitie to do this automatically ?

Anyway, if you're more confortable with the letters, you can use this kind of syntax :
chmod o+x filename
to give execution permession to other on filename.

Cheere

Nicolas
All different, all Unix
Jdamian
Respected Contributor

Re: How to get the file access permissions?

Try

getaccess -n file
KapilRaj
Honored Contributor

Re: How to get the file access permissions?

It has 3 digits
i.e. chmod 777 filename

First bit is the permission of Owner i.e. 4+2+1 = 7 means r(4),w(2),x(1)
Second one is for the group
Thrid one is for others

There can be one more in the bigining and it is used for setuid , sticky and stuff like that.

i.e. chmod 1777 filename

Regds,

Kaps
Nothing is impossible
Nicolas Dumeige
Esteemed Contributor

Re: How to get the file access permissions?

Enrico,

You gave evry one 1 pts.

Is becaue it's not tricky technical stuff or because you were looking for another thing ?

Nicolas

All different, all Unix
Roberto Polli
Trusted Contributor

Re: How to get the file access permissions?

Sincerely,
what a shame to get 10pts for such a question ;-)

Peace, R.
Pete Randall
Outstanding Contributor
Solution

Re: How to get the file access permissions?

Enrico,

Here is a script (originally from Jack Mahaffey) that should give you the numeric values you're looking for. Usage notes are in the comments.


Pete

Pete
Fabio Ettore
Honored Contributor

Re: How to get the file access permissions?

Ciao Enrico,

as far as I know a specific command doesn't exist to get permissions in number of a file (if I understand well your question).
Anyway 'man chmod' has all details for combinations of permissions: e.g.

0400 (= u=r) Read by owner 0200 (= u=w) Write by owner 0100 (= u=x) Execute (search in directory) by owner
0040 (= g=r) Read by group 0020 (= g=w) Write by group 0010 (= g=x) Execute/search by group
0004 (= o=r) Read by others 0002 (= o=w) Write by others 0001 (= o=x) Execute/search by others

and many more.
Also use

# umask
or
# umask -S

to see permissions set when creating a file.
Here too: for further details how to change it 'man umask'.

Hope this helps you and definitively satisfy your question.

Best regards,
Ettore
WISH? IMPROVEMENT!