Operating System - HP-UX
1834297 Members
2136 Online
110066 Solutions
New Discussion

Re: how to add 'x' privilege by default when create a new file?

 
SOLVED
Go to solution
常有慈悲心
Regular Advisor

how to add 'x' privilege by default when create a new file?

one user want to create everyfile with default privilege with 777(rwxrwxrwx)

how can i deal that?

umask 000 only useful with directory
6 REPLIES 6
Pete Randall
Outstanding Contributor
Solution

Re: how to add 'x' privilege by default when create a new file?

Sorry, it can't be done.


Pete

Pete
Patrick Wallek
Honored Contributor

Re: how to add 'x' privilege by default when create a new file?

You can't!

On a regular file a umask of 000 will give you permissions of 666 (-rw-rw-rw-).

The key question is WHY does the user want 777 permissions? The 'x' bit is only useful for executable things like programs and shell scripts. The 'x' bit does not give you any thing more than than '666' permissions other than being able to do a ./filename to execute something.

If that file isn't a program or shell script or something very similar the 'x' permission bit is useless.
Steven E. Protter
Exalted Contributor

Re: how to add 'x' privilege by default when create a new file?

A fundamental principle of Unix is that someone, as in a human being needs to decide whether a file is executable.

A human can program a script to do this for him, but Unix security believes that default executable creation is an enormous security risk.

You'll have to write a script to change the permissions after the fact. cron can run it for you.

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
Sanjay_6
Honored Contributor

Re: how to add 'x' privilege by default when create a new file?

Hi,

It cannot be done. Files are created with r & w permissions by default. The x has to be added manually.

Hope this helps.

Regds
Victor BERRIDGE
Honored Contributor

Re: how to add 'x' privilege by default when create a new file?

In my early life I tried..
.. And gave up.

But there is nothing stopping you to create an alias like cm7='chmod 777 '

then try cm7


All the best
Victor
Michael D. Zorn
Regular Advisor

Re: how to add 'x' privilege by default when create a new file?

I agree with Steven - it's a bad idea. Why would he want to create text files (other than scripts) executable?

And even more of a bad idea, to make them world-executable!

It sounds suspicious to me.

I have an alias:

alias go='chmod u+x '

that I use all the time for scripts (go myscript.sh).

If he wants to put all his executables in a directory, he could do
chmod 770 *

(I'd still question the need for world-executable permission. If there are things the world needs to run, put them in something like /usr/local/bin)

It's possible he doesn't know that he doesn't need 777, that 770 is fine (everybody in the group can execute) or even 700 (just him).