FranHill
asked on
how to set umask higher than default 666 for files
Is it possible to set file permission greater than the default 666 to 755 upon creation of new files and how would I make it permanent using umask. This is for a individual user with a bash shell login.
Short answer is that you can't do it with umask.
If I understand the question, I respectfully disagree with Tintin.
You can setup umask in /etc/bashrc or /etc/profile file for all users.
Steps :
-------------------------- ---------- ---------- -
Open /etc/profile (global) or ~/.bashrc file
# vi /etc/profile
OR
$ vi ~/.bashrc
Append/modify following line to setup a new umask:
umask 755
You can setup umask in /etc/bashrc or /etc/profile file for all users.
Steps :
--------------------------
Open /etc/profile (global) or ~/.bashrc file
# vi /etc/profile
OR
$ vi ~/.bashrc
Append/modify following line to setup a new umask:
umask 755
Woops,
umask 0022
umask 0022
I'll respectfully disagree with 97WideGlide :) You've misunderstood the question.
Franhill is wanting to know if it is possible to set the umask so that a newly created file will have 755 permissions. This is not possible with umask. You need to use chmod to add execute permission after the file is created.
Franhill is wanting to know if it is possible to set the umask so that a newly created file will have 755 permissions. This is not possible with umask. You need to use chmod to add execute permission after the file is created.
ASKER
Tintin
You are on the right track. So are you saying since it is a unix standard to have files created as 666 then it is not possible use the umask command to set defaults to a higher value ie 755. And that the user must chmod the file manually?
You are on the right track. So are you saying since it is a unix standard to have files created as 666 then it is not possible use the umask command to set defaults to a higher value ie 755. And that the user must chmod the file manually?
That is what I thought he meant.
The default umask value can be set in /etc/profile, or individually, in user's home directory, right ?
I'm pretty sure I've done it.
The default umask value can be set in /etc/profile, or individually, in user's home directory, right ?
I'm pretty sure I've done it.
Correct Fran.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok, I C what you R saying. But that is a completely different question ( i think ).
umask can be set to anything you want in the startup files but,
if the OP wants to set the executable bit on all created files, then the answer to the OPs question is not, "you can't do that" it's, "under what circumstances would you want to?".
umask can be set to anything you want in the startup files but,
if the OP wants to set the executable bit on all created files, then the answer to the OPs question is not, "you can't do that" it's, "under what circumstances would you want to?".
ASKER
vi filechg2
"filechg2" 4 lines, 62 characters
#!/bin/csh
foreach i(`ls`)
chmod 755 $i
I could script this but how would I eliminate any directories in the ls output?
and should I put it .bash_profile or .bashrc ?
"filechg2" 4 lines, 62 characters
#!/bin/csh
foreach i(`ls`)
chmod 755 $i
I could script this but how would I eliminate any directories in the ls output?
and should I put it .bash_profile or .bashrc ?
If you are talking about single directory, then just do
chmod +x *
assuming you don't unusual permissions on directories.
chmod +x *
assuming you don't unusual permissions on directories.
To change file mode use :
find <yourdirectory> -type f -exec chmod 755 '{}' \;
man find -- For help
find <yourdirectory> -type f -exec chmod 755 '{}' \;
man find -- For help
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I agree with Tintin and Nopius, but I would say it is the application / command / tool that creates the file which sets the file permissions and umask will moderate it. e.g. if you have umask set to 022 and you compile a program (e.g. c program with cc or gcc) then the compiler set permissions to 777 and because of the umask it is set to 755. On the other hand, vi editor set permissions to 666 which umask set it to 644
Getting back to the unanswered question, why would you want to set the execute bit on non-executable files?
ASKER
blu
It's a request from the client. Not saying setting every file to 755 is a good idea.
I just wanted to know if it was possible to do with umask which I didn't think it was
but justed wanted to be absolutley sure. So I turned to the experts!
It's a request from the client. Not saying setting every file to 755 is a good idea.
I just wanted to know if it was possible to do with umask which I didn't think it was
but justed wanted to be absolutley sure. So I turned to the experts!
> I just wanted to know if it was possible to do with umask
It is possible ONLY when application, that creates file uses 0777 mode! You cannot have more access bits then creating application assigns to the file, but you can restrict them with umask...
So in most cases - no, it is not :-)
It is possible ONLY when application, that creates file uses 0777 mode! You cannot have more access bits then creating application assigns to the file, but you can restrict them with umask...
So in most cases - no, it is not :-)
ASKER
Thanks Tintin and Nopius