Why umask 555 is setting the file mods to “222” instead of “111”?
I know that:
- A file default mod is
666
umask
value will be removed from default mods.
So why when I set the "umask" to 555
it doesn't set newly created file's permissions to 111
? instead it's setting them to 222
command-line permissions umask
add a comment |
I know that:
- A file default mod is
666
umask
value will be removed from default mods.
So why when I set the "umask" to 555
it doesn't set newly created file's permissions to 111
? instead it's setting them to 222
command-line permissions umask
You cannot normally create an executable file using umask; you can only change a file's permissions to make it executable. The only exceptions to this rule are when creating a directory or compiling a program to create an executable binary.
– S.Duygun
Jan 22 at 15:40
add a comment |
I know that:
- A file default mod is
666
umask
value will be removed from default mods.
So why when I set the "umask" to 555
it doesn't set newly created file's permissions to 111
? instead it's setting them to 222
command-line permissions umask
I know that:
- A file default mod is
666
umask
value will be removed from default mods.
So why when I set the "umask" to 555
it doesn't set newly created file's permissions to 111
? instead it's setting them to 222
command-line permissions umask
command-line permissions umask
asked Aug 13 '17 at 5:47
RavexinaRavexina
32.7k1487113
32.7k1487113
You cannot normally create an executable file using umask; you can only change a file's permissions to make it executable. The only exceptions to this rule are when creating a directory or compiling a program to create an executable binary.
– S.Duygun
Jan 22 at 15:40
add a comment |
You cannot normally create an executable file using umask; you can only change a file's permissions to make it executable. The only exceptions to this rule are when creating a directory or compiling a program to create an executable binary.
– S.Duygun
Jan 22 at 15:40
You cannot normally create an executable file using umask; you can only change a file's permissions to make it executable. The only exceptions to this rule are when creating a directory or compiling a program to create an executable binary.
– S.Duygun
Jan 22 at 15:40
You cannot normally create an executable file using umask; you can only change a file's permissions to make it executable. The only exceptions to this rule are when creating a directory or compiling a program to create an executable binary.
– S.Duygun
Jan 22 at 15:40
add a comment |
2 Answers
2
active
oldest
votes
Short answer:
Because with a 5
you are removing the read (4)
and executable (1)
bit, so you end up with only write (2)
.
Explanation:
With 555
you are not setting default executable bit on.
It's wrong => (6 - 5 = 1)
We got these mods:
- 4 = Read
- 2 = Write
- 1 = Executable
The only way that I can create a 5
is from 4 + 1
, so 5
actually means:
4 (Read) + 1 (Executable) = 5
It means "remove" executable and read mods if they're are being set.
In other words, with umask 555
you are removing the read ( 4 ) and executable ( 1 ) bit from default file mode ( 6 ) which brings us to the ( 2 ), because in a 6 we only have a 4 and 2 to remove (not any 1):
6 = 4 + 2
You removal only effects the 4, so the file ends up with 222
.
In binary
Think of it in binary:
1 -> 001
2 -> 010
3 -> 011
4 -> 100
5 -> 101
6 -> 110
7 -> 111
File default mode is 666 (110 110 110), and our umask
value is 555
(101 101 101):
Decimal title -> 421 421 421
666 in binary -> 110 110 110
- 555 in binary -> - 101 101 101
_____________
010 010 010
2 2 2
-w- -w- -w-
See? we ended up to the -w-w-w-, or 222
.
1
good explanation as always....
– solfish
Aug 13 '17 at 6:59
add a comment |
The result umask value is mask & 0777 (bit wise and)
When mask is 0555
Than 0555 & 0777 result with 0222
nixCraft understanding-linux-unix-umask-value-usage
Task: Calculating The Final Permission For FILES
You can simply subtract the umask from the base permissions to
determine the final permission for file as follows:
666 – 022 = 644
File base permissions : 666
umask value : 022
subtract to get permissions of new file (666-022) : 644 (rw-r–r–)
Task: Calculating The Final Permission For DIRECTORIES
You can simply subtract the umask from the base permissions to
determine the final permission for directory as follows:
777 – 022 = 755
Directory base permissions : 777
umask value : 022
Subtract to get permissions of new directory (777-022) : 755 (rwxr-xr-x)
The source of the difference between touch file
and mkdir dir
:
Note: as specify in this Unix Q&A
how the permission bits are hard-coded into the standard utilities.
Here are some relevant lines from two files in thecoreutils
package
that contains the source code for bothtouch(1)
andmkdir(1)
,
among others:
mkdir.c
:
if (specified_mode)
{
struct mode_change *change = mode_compile (specified_mode);
if (!change)
error (EXIT_FAILURE, 0, _("invalid mode %s"),
quote (specified_mode));
options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change,
&options.mode_bits);
free (change);
}
else
options.mode = S_IRWXUGO & ~umask_value;
}
In other words, if the mode is not specified, set it to
S_IRWXUGO
(read: 0777) modified by theumask_value
.
touch.c
is even clearer:
int default_permissions =
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
That is, give read and write permissions to everyone (read: 0666),
which will be modified by the processumask
on file creation, of
course.
You may be able to get around this programmatically only: i.e. while
creating files from within either a C program, where you make the
system calls directly or from within a language that allows you to
make a low-level syscall (see for example Perl'ssysopen
under
perldoc -f sysopen
).
man umask
umask() sets the calling process's file mode creation mask (umask) to
mask & 0777 (i.e., only the file permission bits of mask are used),
and returns the previous value of the mask.
For the files it's not 777, it's 666 ...strace touch a |& grep open
outputs:open("a", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
, and for directories:strace mkdir a1 |& grep 777
>mkdir("a1", 0777)
.
– Ravexina
Aug 13 '17 at 6:00
@Ravexina - as mentioned in the Unix & Linux Q&A which I added to my answer,touch
uses default0666
mask, which added inbit wise and
with theumask_value
. Whilemkdir
uses a default0777
mask which added inbit wise and
with theumask_value
.
– Yaron
Aug 13 '17 at 6:38
Yeah, the default mod depends on the program, alsoumask
itself can be ignored by the programs like compilers,chmod
, etc.
– Ravexina
Aug 13 '17 at 6:40
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f945782%2fwhy-umask-555-is-setting-the-file-mods-to-222-instead-of-111%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Short answer:
Because with a 5
you are removing the read (4)
and executable (1)
bit, so you end up with only write (2)
.
Explanation:
With 555
you are not setting default executable bit on.
It's wrong => (6 - 5 = 1)
We got these mods:
- 4 = Read
- 2 = Write
- 1 = Executable
The only way that I can create a 5
is from 4 + 1
, so 5
actually means:
4 (Read) + 1 (Executable) = 5
It means "remove" executable and read mods if they're are being set.
In other words, with umask 555
you are removing the read ( 4 ) and executable ( 1 ) bit from default file mode ( 6 ) which brings us to the ( 2 ), because in a 6 we only have a 4 and 2 to remove (not any 1):
6 = 4 + 2
You removal only effects the 4, so the file ends up with 222
.
In binary
Think of it in binary:
1 -> 001
2 -> 010
3 -> 011
4 -> 100
5 -> 101
6 -> 110
7 -> 111
File default mode is 666 (110 110 110), and our umask
value is 555
(101 101 101):
Decimal title -> 421 421 421
666 in binary -> 110 110 110
- 555 in binary -> - 101 101 101
_____________
010 010 010
2 2 2
-w- -w- -w-
See? we ended up to the -w-w-w-, or 222
.
1
good explanation as always....
– solfish
Aug 13 '17 at 6:59
add a comment |
Short answer:
Because with a 5
you are removing the read (4)
and executable (1)
bit, so you end up with only write (2)
.
Explanation:
With 555
you are not setting default executable bit on.
It's wrong => (6 - 5 = 1)
We got these mods:
- 4 = Read
- 2 = Write
- 1 = Executable
The only way that I can create a 5
is from 4 + 1
, so 5
actually means:
4 (Read) + 1 (Executable) = 5
It means "remove" executable and read mods if they're are being set.
In other words, with umask 555
you are removing the read ( 4 ) and executable ( 1 ) bit from default file mode ( 6 ) which brings us to the ( 2 ), because in a 6 we only have a 4 and 2 to remove (not any 1):
6 = 4 + 2
You removal only effects the 4, so the file ends up with 222
.
In binary
Think of it in binary:
1 -> 001
2 -> 010
3 -> 011
4 -> 100
5 -> 101
6 -> 110
7 -> 111
File default mode is 666 (110 110 110), and our umask
value is 555
(101 101 101):
Decimal title -> 421 421 421
666 in binary -> 110 110 110
- 555 in binary -> - 101 101 101
_____________
010 010 010
2 2 2
-w- -w- -w-
See? we ended up to the -w-w-w-, or 222
.
1
good explanation as always....
– solfish
Aug 13 '17 at 6:59
add a comment |
Short answer:
Because with a 5
you are removing the read (4)
and executable (1)
bit, so you end up with only write (2)
.
Explanation:
With 555
you are not setting default executable bit on.
It's wrong => (6 - 5 = 1)
We got these mods:
- 4 = Read
- 2 = Write
- 1 = Executable
The only way that I can create a 5
is from 4 + 1
, so 5
actually means:
4 (Read) + 1 (Executable) = 5
It means "remove" executable and read mods if they're are being set.
In other words, with umask 555
you are removing the read ( 4 ) and executable ( 1 ) bit from default file mode ( 6 ) which brings us to the ( 2 ), because in a 6 we only have a 4 and 2 to remove (not any 1):
6 = 4 + 2
You removal only effects the 4, so the file ends up with 222
.
In binary
Think of it in binary:
1 -> 001
2 -> 010
3 -> 011
4 -> 100
5 -> 101
6 -> 110
7 -> 111
File default mode is 666 (110 110 110), and our umask
value is 555
(101 101 101):
Decimal title -> 421 421 421
666 in binary -> 110 110 110
- 555 in binary -> - 101 101 101
_____________
010 010 010
2 2 2
-w- -w- -w-
See? we ended up to the -w-w-w-, or 222
.
Short answer:
Because with a 5
you are removing the read (4)
and executable (1)
bit, so you end up with only write (2)
.
Explanation:
With 555
you are not setting default executable bit on.
It's wrong => (6 - 5 = 1)
We got these mods:
- 4 = Read
- 2 = Write
- 1 = Executable
The only way that I can create a 5
is from 4 + 1
, so 5
actually means:
4 (Read) + 1 (Executable) = 5
It means "remove" executable and read mods if they're are being set.
In other words, with umask 555
you are removing the read ( 4 ) and executable ( 1 ) bit from default file mode ( 6 ) which brings us to the ( 2 ), because in a 6 we only have a 4 and 2 to remove (not any 1):
6 = 4 + 2
You removal only effects the 4, so the file ends up with 222
.
In binary
Think of it in binary:
1 -> 001
2 -> 010
3 -> 011
4 -> 100
5 -> 101
6 -> 110
7 -> 111
File default mode is 666 (110 110 110), and our umask
value is 555
(101 101 101):
Decimal title -> 421 421 421
666 in binary -> 110 110 110
- 555 in binary -> - 101 101 101
_____________
010 010 010
2 2 2
-w- -w- -w-
See? we ended up to the -w-w-w-, or 222
.
answered Aug 13 '17 at 5:47
RavexinaRavexina
32.7k1487113
32.7k1487113
1
good explanation as always....
– solfish
Aug 13 '17 at 6:59
add a comment |
1
good explanation as always....
– solfish
Aug 13 '17 at 6:59
1
1
good explanation as always....
– solfish
Aug 13 '17 at 6:59
good explanation as always....
– solfish
Aug 13 '17 at 6:59
add a comment |
The result umask value is mask & 0777 (bit wise and)
When mask is 0555
Than 0555 & 0777 result with 0222
nixCraft understanding-linux-unix-umask-value-usage
Task: Calculating The Final Permission For FILES
You can simply subtract the umask from the base permissions to
determine the final permission for file as follows:
666 – 022 = 644
File base permissions : 666
umask value : 022
subtract to get permissions of new file (666-022) : 644 (rw-r–r–)
Task: Calculating The Final Permission For DIRECTORIES
You can simply subtract the umask from the base permissions to
determine the final permission for directory as follows:
777 – 022 = 755
Directory base permissions : 777
umask value : 022
Subtract to get permissions of new directory (777-022) : 755 (rwxr-xr-x)
The source of the difference between touch file
and mkdir dir
:
Note: as specify in this Unix Q&A
how the permission bits are hard-coded into the standard utilities.
Here are some relevant lines from two files in thecoreutils
package
that contains the source code for bothtouch(1)
andmkdir(1)
,
among others:
mkdir.c
:
if (specified_mode)
{
struct mode_change *change = mode_compile (specified_mode);
if (!change)
error (EXIT_FAILURE, 0, _("invalid mode %s"),
quote (specified_mode));
options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change,
&options.mode_bits);
free (change);
}
else
options.mode = S_IRWXUGO & ~umask_value;
}
In other words, if the mode is not specified, set it to
S_IRWXUGO
(read: 0777) modified by theumask_value
.
touch.c
is even clearer:
int default_permissions =
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
That is, give read and write permissions to everyone (read: 0666),
which will be modified by the processumask
on file creation, of
course.
You may be able to get around this programmatically only: i.e. while
creating files from within either a C program, where you make the
system calls directly or from within a language that allows you to
make a low-level syscall (see for example Perl'ssysopen
under
perldoc -f sysopen
).
man umask
umask() sets the calling process's file mode creation mask (umask) to
mask & 0777 (i.e., only the file permission bits of mask are used),
and returns the previous value of the mask.
For the files it's not 777, it's 666 ...strace touch a |& grep open
outputs:open("a", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
, and for directories:strace mkdir a1 |& grep 777
>mkdir("a1", 0777)
.
– Ravexina
Aug 13 '17 at 6:00
@Ravexina - as mentioned in the Unix & Linux Q&A which I added to my answer,touch
uses default0666
mask, which added inbit wise and
with theumask_value
. Whilemkdir
uses a default0777
mask which added inbit wise and
with theumask_value
.
– Yaron
Aug 13 '17 at 6:38
Yeah, the default mod depends on the program, alsoumask
itself can be ignored by the programs like compilers,chmod
, etc.
– Ravexina
Aug 13 '17 at 6:40
add a comment |
The result umask value is mask & 0777 (bit wise and)
When mask is 0555
Than 0555 & 0777 result with 0222
nixCraft understanding-linux-unix-umask-value-usage
Task: Calculating The Final Permission For FILES
You can simply subtract the umask from the base permissions to
determine the final permission for file as follows:
666 – 022 = 644
File base permissions : 666
umask value : 022
subtract to get permissions of new file (666-022) : 644 (rw-r–r–)
Task: Calculating The Final Permission For DIRECTORIES
You can simply subtract the umask from the base permissions to
determine the final permission for directory as follows:
777 – 022 = 755
Directory base permissions : 777
umask value : 022
Subtract to get permissions of new directory (777-022) : 755 (rwxr-xr-x)
The source of the difference between touch file
and mkdir dir
:
Note: as specify in this Unix Q&A
how the permission bits are hard-coded into the standard utilities.
Here are some relevant lines from two files in thecoreutils
package
that contains the source code for bothtouch(1)
andmkdir(1)
,
among others:
mkdir.c
:
if (specified_mode)
{
struct mode_change *change = mode_compile (specified_mode);
if (!change)
error (EXIT_FAILURE, 0, _("invalid mode %s"),
quote (specified_mode));
options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change,
&options.mode_bits);
free (change);
}
else
options.mode = S_IRWXUGO & ~umask_value;
}
In other words, if the mode is not specified, set it to
S_IRWXUGO
(read: 0777) modified by theumask_value
.
touch.c
is even clearer:
int default_permissions =
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
That is, give read and write permissions to everyone (read: 0666),
which will be modified by the processumask
on file creation, of
course.
You may be able to get around this programmatically only: i.e. while
creating files from within either a C program, where you make the
system calls directly or from within a language that allows you to
make a low-level syscall (see for example Perl'ssysopen
under
perldoc -f sysopen
).
man umask
umask() sets the calling process's file mode creation mask (umask) to
mask & 0777 (i.e., only the file permission bits of mask are used),
and returns the previous value of the mask.
For the files it's not 777, it's 666 ...strace touch a |& grep open
outputs:open("a", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
, and for directories:strace mkdir a1 |& grep 777
>mkdir("a1", 0777)
.
– Ravexina
Aug 13 '17 at 6:00
@Ravexina - as mentioned in the Unix & Linux Q&A which I added to my answer,touch
uses default0666
mask, which added inbit wise and
with theumask_value
. Whilemkdir
uses a default0777
mask which added inbit wise and
with theumask_value
.
– Yaron
Aug 13 '17 at 6:38
Yeah, the default mod depends on the program, alsoumask
itself can be ignored by the programs like compilers,chmod
, etc.
– Ravexina
Aug 13 '17 at 6:40
add a comment |
The result umask value is mask & 0777 (bit wise and)
When mask is 0555
Than 0555 & 0777 result with 0222
nixCraft understanding-linux-unix-umask-value-usage
Task: Calculating The Final Permission For FILES
You can simply subtract the umask from the base permissions to
determine the final permission for file as follows:
666 – 022 = 644
File base permissions : 666
umask value : 022
subtract to get permissions of new file (666-022) : 644 (rw-r–r–)
Task: Calculating The Final Permission For DIRECTORIES
You can simply subtract the umask from the base permissions to
determine the final permission for directory as follows:
777 – 022 = 755
Directory base permissions : 777
umask value : 022
Subtract to get permissions of new directory (777-022) : 755 (rwxr-xr-x)
The source of the difference between touch file
and mkdir dir
:
Note: as specify in this Unix Q&A
how the permission bits are hard-coded into the standard utilities.
Here are some relevant lines from two files in thecoreutils
package
that contains the source code for bothtouch(1)
andmkdir(1)
,
among others:
mkdir.c
:
if (specified_mode)
{
struct mode_change *change = mode_compile (specified_mode);
if (!change)
error (EXIT_FAILURE, 0, _("invalid mode %s"),
quote (specified_mode));
options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change,
&options.mode_bits);
free (change);
}
else
options.mode = S_IRWXUGO & ~umask_value;
}
In other words, if the mode is not specified, set it to
S_IRWXUGO
(read: 0777) modified by theumask_value
.
touch.c
is even clearer:
int default_permissions =
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
That is, give read and write permissions to everyone (read: 0666),
which will be modified by the processumask
on file creation, of
course.
You may be able to get around this programmatically only: i.e. while
creating files from within either a C program, where you make the
system calls directly or from within a language that allows you to
make a low-level syscall (see for example Perl'ssysopen
under
perldoc -f sysopen
).
man umask
umask() sets the calling process's file mode creation mask (umask) to
mask & 0777 (i.e., only the file permission bits of mask are used),
and returns the previous value of the mask.
The result umask value is mask & 0777 (bit wise and)
When mask is 0555
Than 0555 & 0777 result with 0222
nixCraft understanding-linux-unix-umask-value-usage
Task: Calculating The Final Permission For FILES
You can simply subtract the umask from the base permissions to
determine the final permission for file as follows:
666 – 022 = 644
File base permissions : 666
umask value : 022
subtract to get permissions of new file (666-022) : 644 (rw-r–r–)
Task: Calculating The Final Permission For DIRECTORIES
You can simply subtract the umask from the base permissions to
determine the final permission for directory as follows:
777 – 022 = 755
Directory base permissions : 777
umask value : 022
Subtract to get permissions of new directory (777-022) : 755 (rwxr-xr-x)
The source of the difference between touch file
and mkdir dir
:
Note: as specify in this Unix Q&A
how the permission bits are hard-coded into the standard utilities.
Here are some relevant lines from two files in thecoreutils
package
that contains the source code for bothtouch(1)
andmkdir(1)
,
among others:
mkdir.c
:
if (specified_mode)
{
struct mode_change *change = mode_compile (specified_mode);
if (!change)
error (EXIT_FAILURE, 0, _("invalid mode %s"),
quote (specified_mode));
options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change,
&options.mode_bits);
free (change);
}
else
options.mode = S_IRWXUGO & ~umask_value;
}
In other words, if the mode is not specified, set it to
S_IRWXUGO
(read: 0777) modified by theumask_value
.
touch.c
is even clearer:
int default_permissions =
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
That is, give read and write permissions to everyone (read: 0666),
which will be modified by the processumask
on file creation, of
course.
You may be able to get around this programmatically only: i.e. while
creating files from within either a C program, where you make the
system calls directly or from within a language that allows you to
make a low-level syscall (see for example Perl'ssysopen
under
perldoc -f sysopen
).
man umask
umask() sets the calling process's file mode creation mask (umask) to
mask & 0777 (i.e., only the file permission bits of mask are used),
and returns the previous value of the mask.
edited Aug 13 '17 at 6:13
answered Aug 13 '17 at 5:55
YaronYaron
9,17871940
9,17871940
For the files it's not 777, it's 666 ...strace touch a |& grep open
outputs:open("a", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
, and for directories:strace mkdir a1 |& grep 777
>mkdir("a1", 0777)
.
– Ravexina
Aug 13 '17 at 6:00
@Ravexina - as mentioned in the Unix & Linux Q&A which I added to my answer,touch
uses default0666
mask, which added inbit wise and
with theumask_value
. Whilemkdir
uses a default0777
mask which added inbit wise and
with theumask_value
.
– Yaron
Aug 13 '17 at 6:38
Yeah, the default mod depends on the program, alsoumask
itself can be ignored by the programs like compilers,chmod
, etc.
– Ravexina
Aug 13 '17 at 6:40
add a comment |
For the files it's not 777, it's 666 ...strace touch a |& grep open
outputs:open("a", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
, and for directories:strace mkdir a1 |& grep 777
>mkdir("a1", 0777)
.
– Ravexina
Aug 13 '17 at 6:00
@Ravexina - as mentioned in the Unix & Linux Q&A which I added to my answer,touch
uses default0666
mask, which added inbit wise and
with theumask_value
. Whilemkdir
uses a default0777
mask which added inbit wise and
with theumask_value
.
– Yaron
Aug 13 '17 at 6:38
Yeah, the default mod depends on the program, alsoumask
itself can be ignored by the programs like compilers,chmod
, etc.
– Ravexina
Aug 13 '17 at 6:40
For the files it's not 777, it's 666 ...
strace touch a |& grep open
outputs: open("a", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
, and for directories: strace mkdir a1 |& grep 777
> mkdir("a1", 0777)
.– Ravexina
Aug 13 '17 at 6:00
For the files it's not 777, it's 666 ...
strace touch a |& grep open
outputs: open("a", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
, and for directories: strace mkdir a1 |& grep 777
> mkdir("a1", 0777)
.– Ravexina
Aug 13 '17 at 6:00
@Ravexina - as mentioned in the Unix & Linux Q&A which I added to my answer,
touch
uses default 0666
mask, which added in bit wise and
with the umask_value
. While mkdir
uses a default 0777
mask which added in bit wise and
with the umask_value
.– Yaron
Aug 13 '17 at 6:38
@Ravexina - as mentioned in the Unix & Linux Q&A which I added to my answer,
touch
uses default 0666
mask, which added in bit wise and
with the umask_value
. While mkdir
uses a default 0777
mask which added in bit wise and
with the umask_value
.– Yaron
Aug 13 '17 at 6:38
Yeah, the default mod depends on the program, also
umask
itself can be ignored by the programs like compilers, chmod
, etc.– Ravexina
Aug 13 '17 at 6:40
Yeah, the default mod depends on the program, also
umask
itself can be ignored by the programs like compilers, chmod
, etc.– Ravexina
Aug 13 '17 at 6:40
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f945782%2fwhy-umask-555-is-setting-the-file-mods-to-222-instead-of-111%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You cannot normally create an executable file using umask; you can only change a file's permissions to make it executable. The only exceptions to this rule are when creating a directory or compiling a program to create an executable binary.
– S.Duygun
Jan 22 at 15:40