LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to set default file permissions to 755? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-set-default-file-permissions-to-755-a-4175452806/)

yrc 03-05-2013 11:10 AM

how to set default file permissions to 755?
 
how can i set default file permissions to 755?
i know umask can help but umask give me only 666 and not 755

can someone help?

pingu 03-05-2013 11:22 AM

I don't understand?
Setting umask to 022 chould give permissions 755, does it not work?
Is it defined and if so where?

yrc 03-05-2013 11:30 AM

Quote:

Originally Posted by pingu (Post 4905235)
I don't understand?
Setting umask to 022 chould give permissions 755, does it not work?
Is it defined and if so where?



yeah...it gives 755 for a folder...but i should get 755 for a file

pingu 03-05-2013 11:35 AM

No, for a file you should get 644.
A file is never executable by default, you have to set that manually (and this is the difference between 755 & 644).
A directory, OTOH, must be 'executable' or you can't descend into it.
But you wrote you get 666 or was that a typo?

shivaa 03-05-2013 11:36 AM

Better set umask to 011 or 001, so you will get permission of 655 (i.e. rw-r-xr-x) or 665 (i.e. rw-rw-r-x). In that case file will be executable for all.

knudfl 03-05-2013 11:39 AM

*

chmod 0644 <file>

chmod calculator http://www.onlineconversion.com/html...calculator.htm

yrc 03-05-2013 11:44 AM

Quote:

Originally Posted by pingu (Post 4905243)
No, for a file you should get 644.
A file is never executable by default, you have to set that manually (and this is the difference between 755 & 644).
A directory, OTOH, must be 'executable' or you can't descend into it.
But you wrote you get 666 or was that a typo?


ok - so, there is no other way to set file permission to 755? like umask? something that we can setup in the profile?
i get 666(rw-rw-rw) for a file if my umask is "umask 000"

pingu 03-05-2013 11:47 AM

I don't really understand why you want that?
Why would you want every file to be executable - and for everybody!
That is definitely not good practice, but maybe you have special needs. Can you please tell why you want this?

yrc 03-05-2013 11:53 AM

Quote:

Originally Posted by pingu (Post 4905252)
I don't really understand why you want that?
Why would you want every file to be executable - and for everybody!
That is definitely not good practice, but maybe you have special needs. Can you please tell why you want this?

yeah, not for all definitely.

I would need 750 for sure, for a file.

shivaa 03-05-2013 12:04 PM

One workaround is to set permission after file creation, instead of depending upon umask, as:
Code:

~$ chmod 755 file1 file2 file3...
~$ chmod -R 755 /path/to/dir


yrc 03-05-2013 12:08 PM

Quote:

Originally Posted by shivaa (Post 4905261)
One workaround is to set permission after file creation, instead of depending upon umask, as:
Code:

~$ chmod 755 file1 file2 file3...
~$ chmod -R 755 /path/to/dir


yeah...I know chmod would work but that would be manual change after the file is created rt?

i would need something in the profile file that makes files created with "rwxr-x---"

shivaa 03-05-2013 12:16 PM

Then why not you set umask to 026? Even if there's no execute permission for owner, but he's will be able to execute the file, because he'll be in group of the file and group has already execute permission...

pingu 03-05-2013 12:17 PM

But why do you want *every* file you create executable?
Think about it, if every document, picture, html-page, whatever you create will be executable, then one day you might find ththa you accidentally executed code when you just wanted to read a document.
Just one example, but there is a reason for why exec must be set explicitly.
If you're writing scripts, you most likely put them in one directory, then it's not really a big hassle to make them executable using chmod?
One thing you could do, if you write your scripts with a specific program you cold write a small shell script that makes the files executable.
Like this:

my_wrapper_file:
Code:

#!/bin/bash
touch $1
chmod ug+x $1
kate $1

Then you start it with
my_wrapper_file script_file_name
And script_file_name will be executable.

yrc 03-05-2013 01:54 PM

Quote:

Originally Posted by pingu (Post 4905273)
But why do you want *every* file you create executable?
Think about it, if every document, picture, html-page, whatever you create will be executable, then one day you might find ththa you accidentally executed code when you just wanted to read a document.
Just one example, but there is a reason for why exec must be set explicitly.
If you're writing scripts, you most likely put them in one directory, then it's not really a big hassle to make them executable using chmod?
One thing you could do, if you write your scripts with a specific program you cold write a small shell script that makes the files executable.
Like this:

my_wrapper_file:
Code:

#!/bin/bash
touch $1
chmod ug+x $1
kate $1

Then you start it with
my_wrapper_file script_file_name
And script_file_name will be executable.

ok - here my situation..
we have a application that moves files from source to destination.
after moving to destination the files are getting "rw-rw---"
in order to use the files in the destination it should have executable for user and group(i.e rwxr-x---)


do you understand my point? :)

pingu 03-05-2013 02:04 PM

Aha, I see the situation now!
Now this depends a bit on exactly how the files are copied or moved, also I believe it matters to & from what media.
Like for instance if the application runs a simple bash script, then you could modify that script to keep permissions.
So, what app, from where, to where?


All times are GMT -5. The time now is 07:23 PM.