Operating System - HP-UX
1833861 Members
2032 Online
110063 Solutions
New Discussion

Re: File Permission problem

 
SOLVED
Go to solution
M. Tariq Ayub
Regular Advisor

File Permission problem

Hi,

I have crearted a user with umask 022. it should get -wxr-xr-x bu deafault. but when he creats a file it has -rw-r--r-- and this is also true for ftp.

Can any one help me regarding this.
12 REPLIES 12
Bill Hassell
Honored Contributor

Re: File Permission problem

The man page for umask explains this. Files *always* start with the permission 666 while directories start with 777. The execute bit is a special case and should not be the norm for plain files since they may not be executable at all. Turning on the execute bit should be an explicit task requiring a decision by the creator of the file, not the default.


Bill Hassell, sysadmin
Patrick Wallek
Honored Contributor

Re: File Permission problem

Bill H. has hit the nail on the head! (When does he not?) The behavior you are seeing is absolutely normal.

No there is no way to have the execute bit automagically set. As Bill said, you must explicitly set the e(x)ecute bit if, and only if, it is needed.
T G Manikandan
Honored Contributor

Re: File Permission problem

By default the permission of files are like

directories and exe's 777 -rwxrwxrwx
other files 666 rw-rw-rw-

i.e.the umask being 000.

When you have umask as 022 then you have

directories as 755 and files as 644

(subtracting 022 from 777 and 666)
M. Tariq Ayub
Regular Advisor

Re: File Permission problem

Hi,

but it should have rw permission from group with umask 022.

i am not getting that.
M. Tariq Ayub
Regular Advisor

Re: File Permission problem

Hi,

i want to set -rwxrw---- for a user. what should i do. what will be the umask
Umapathy S
Honored Contributor

Re: File Permission problem

Tariq,
As said, the umask is substracted from 777 and 666 for dir and files respectively.
r - 4
w - 2
x - 1

So for the files with umask 022 the value is 644 which leads to rw-r--r--

Hope I understood your problem correctly.

HTH,
Umapathy

Arise Awake and Stop NOT till the goal is Reached!
Steven E. Protter
Exalted Contributor

Re: File Permission problem

022

produces
-rw-r--r--

i want to set -rwxrw---- for a user. what should i do. what will be the umask

007

will produce -rw-rw-r--

Executable permission isn't done automatically because its a security hazard. The user needs to make files excutable themselves.

SEP

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Umapathy S
Honored Contributor

Re: File Permission problem

Tariq,
The umask will be 006. After creating the file, set the executable bit for the file like

chmod u+x a

HTH,
Umapathy

Arise Awake and Stop NOT till the goal is Reached!
T G Manikandan
Honored Contributor

Re: File Permission problem

umask 017 then
for directories & exe's it would be

rwxrw----

for files

rw-rw----

M. Tariq Ayub
Regular Advisor

Re: File Permission problem

Hi,

After setting umask 006 i get -rw-rw---- while i create a file. It is ok. but when i use ftp from another machine to put file the permission again changes to -rw-r--r--.

I need -rw-rw---- when i ftp from another server.

what should be the umask
T G Manikandan
Honored Contributor
Solution

Re: File Permission problem

If you want to do this for ftp

change in your /etc/inetd.conf file as

ftp stream tcp nowait root /usr/lbin/ftpd ftpd -l
to

ftp stream tcp nowait root /usr/lbin/ftpd ftpd -l -u017

Then do a

inetd -c

This will effect for all the users for the ftp.

If you are just trying for some sessions you can just do a

umask 017 from the ftp

ftp <>hostname>
ftp>umask 017
ftp>mput

Revert
M. Tariq Ayub
Regular Advisor

Re: File Permission problem

i cahnged on inetd,conf and it works perfectly.

Can i do it for a specific user.

if i set 017 then is not owner will get rwx permission.