LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-11-2005, 01:09 AM   #1
blackzone
Member
 
Registered: Jun 2004
Posts: 256

Rep: Reputation: 30
umask chmod??


my umask shows the following:

> umask
0022


my question is when I create a file

> touch file; ls -al

the file permision is 644??

I thought the file should be permission 777-022 = 755 ??
 
Old 01-11-2005, 01:32 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
The execute permissions are only given to execute-capable files. It makes no sense to try and run a file you've only touch'ed. It's the same thing with text editors like vi, emacs, nano, etc. You're creating a text file, and it makes no sense to execute a text file. The exception would be scripts, but there's no way the text editor can know if you're writing plain text or a script. So, I suspect the decision to set file attributes is embedded in the program somewhere. If you want to see an example of what you were expecting, do this:

in file hello.c:
Code:
#include <stdio.h>

int main( int argc, char *argv[] )
{
  printf( "Hello world.\n" );
  return 0;
}
from a prompt:
Code:
gcc -o hello hello.c
ls -al
You'll see the hello binary listed with 755 permissions.
 
Old 01-11-2005, 01:35 AM   #3
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 52
now this is a good question (lke you care what i think )
traditionally standard utils like touch when they create files create them 0666
here is some code from an ancient unix V7 version of touch
Code:
 if( (fd = creat(name, 0666)) < 0)
		goto bad;
 close(fd);
from modern Linux coreutils-5.2.1
Code:
if (! no_create)
    {
      /* Try to open FILE, creating it if necessary.  */
      fd = open (file, O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY,
		 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
S_IRUSR = 00400
S_IWUSER = 00200
and you can extrapolate the rest
so it's still the same 00666 as it's always been

Last edited by foo_bar_foo; 01-11-2005 at 01:45 AM.
 
Old 01-11-2005, 01:50 AM   #4
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
default permissions are 666 for files and 777 for directories. umask is subtracted from those.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
chmod + umask for a whole dir tree Ephracis Linux - Security 2 08-15-2005 06:55 PM
What can we do if we type chmod ugo-x /bin/chmod ?????? bunny123 Linux - Software 3 02-01-2005 08:53 PM
CHMOD in shell : chmod 777 /usr/ <---is that right? cpanelskindepot Programming 5 07-16-2004 05:37 AM
chmod and umask InsaneBob Linux - Software 20 07-19-2003 11:10 PM
file perm, chgrp, chmod, and umask Martini Linux - Newbie 2 08-06-2002 08:04 PM


All times are GMT -5. The time now is 07:24 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration