LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-05-2013, 11:10 AM   #1
yrc
LQ Newbie
 
Registered: Mar 2013
Posts: 11

Rep: Reputation: Disabled
Smile 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?
 
Old 03-05-2013, 11:22 AM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
I don't understand?
Setting umask to 022 chould give permissions 755, does it not work?
Is it defined and if so where?
 
Old 03-05-2013, 11:30 AM   #3
yrc
LQ Newbie
 
Registered: Mar 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pingu View Post
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
 
Old 03-05-2013, 11:35 AM   #4
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
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?
 
Old 03-05-2013, 11:36 AM   #5
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
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.
 
Old 03-05-2013, 11:39 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
*

chmod 0644 <file>

chmod calculator http://www.onlineconversion.com/html...calculator.htm
 
Old 03-05-2013, 11:44 AM   #7
yrc
LQ Newbie
 
Registered: Mar 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pingu View Post
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"
 
Old 03-05-2013, 11:47 AM   #8
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
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?
 
Old 03-05-2013, 11:53 AM   #9
yrc
LQ Newbie
 
Registered: Mar 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by pingu View Post
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.
 
Old 03-05-2013, 12:04 PM   #10
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
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
 
Old 03-05-2013, 12:08 PM   #11
yrc
LQ Newbie
 
Registered: Mar 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by shivaa View Post
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---"
 
Old 03-05-2013, 12:16 PM   #12
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
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...
 
Old 03-05-2013, 12:17 PM   #13
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
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.
 
Old 03-05-2013, 01:54 PM   #14
yrc
LQ Newbie
 
Registered: Mar 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by pingu View Post
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?
 
Old 03-05-2013, 02:04 PM   #15
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to set a group with default read & write permissions Blackninja Linux - General 3 06-16-2011 08:18 PM
Set default file/directory permissions replica88 Linux - Newbie 2 04-04-2010 10:12 AM
Set default permissions for new files and folders jmkelm08 Linux - General 1 09-11-2006 08:26 PM
File write permissions of 777 and 755 wissyweb Linux - Security 2 01-24-2006 08:12 AM
Where to set default file permissions (umask)? tredegar Linux - Newbie 14 01-27-2004 05:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration