Is a file creation mask setted by a given shell's umask is typically unique to the operating system entirely or just to that given shell?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
Is a file creation mask setted by a given shell's umask
is typically unique to the operating system entirely or just to that given shell?
For example, if I change the file creation mask (umask's mask/bitmask) in Bash will it change only for Bash or also for possible other existing shells in my operating system like Dash, ksh, zsh and so forth? ("a case were one shell effects others").
umask
add a comment |
up vote
2
down vote
favorite
Is a file creation mask setted by a given shell's umask
is typically unique to the operating system entirely or just to that given shell?
For example, if I change the file creation mask (umask's mask/bitmask) in Bash will it change only for Bash or also for possible other existing shells in my operating system like Dash, ksh, zsh and so forth? ("a case were one shell effects others").
umask
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Is a file creation mask setted by a given shell's umask
is typically unique to the operating system entirely or just to that given shell?
For example, if I change the file creation mask (umask's mask/bitmask) in Bash will it change only for Bash or also for possible other existing shells in my operating system like Dash, ksh, zsh and so forth? ("a case were one shell effects others").
umask
Is a file creation mask setted by a given shell's umask
is typically unique to the operating system entirely or just to that given shell?
For example, if I change the file creation mask (umask's mask/bitmask) in Bash will it change only for Bash or also for possible other existing shells in my operating system like Dash, ksh, zsh and so forth? ("a case were one shell effects others").
umask
umask
edited 4 hours ago
asked 6 hours ago
JohnDoea
55831
55831
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
To understand umask, you first need to understand the structure of processes in Unix/Linux. Which is to say, they form a tree-like structure. Each process needs to have a parent, which is the process that spawned it. (With the exception of the first process, init
). Each process may or may not spawn more processes, called children.
Each process has a mask property. This is what is queried or set using the umask command.
Processes inherit the mask of their parent. They can then change their own mask. For example, there is a umask()
C function that can change the mask of the program you are writing, without needing to call umask
from the shell.
A child process cannot affect the mask of their parent. Therefore, changing the mask of a process will not affect the entire system. It will only affect any future child processes.
Since the purpose of a shell is to be able to create and control other processes, a umask
command is built in to most shells. This isn't required for a shell, it is possible to write a basic shell that has no umask
function. But such a shell would not be considered useful as a general-purpose shell for logging in and administering a system.
You can test what I'm saying yourself, using the fact that a shell like Bash can spawn other Bash shells (or whatever other shell you like):
- Open a terminal
- Run the
umask
command to query the current value - Run
bash
(or whatever) to spawn a child shell - Run
umask
to check the value of the child's mask - Set the child's mask to something else, eg run
umask 0000
- Run
umask
to check the child's mask again - Exit from the child shell (run
exit
or pressCtrl-d
) - You are now back in the parent shell again. Run
umask
to check its mask
Useful references:
man 1 umask
man 2 umask
(This gives the reference for theumask()
C function)man bash
(and search forumask
)- https://en.wikipedia.org/wiki/Umask
Hello, I'm sad to say that I don't get an answer to my particular question. You might want to consider editing a bit to touch my question directly.
– JohnDoea
3 hours ago
This might result in upvotes...
– JohnDoea
3 hours ago
You want me to put a line at the top saying "Changing umask does not affect the whole operating system"?
– cryptarch
3 hours ago
1
Do I understand correct? --- A Bash process with mask X will inherit it to a Dash process but if we change it in the Dash process to Y, the ksh process will have Y But the Bash will still have X.
– JohnDoea
56 mins ago
1
Yes, in this case I am. Thanks and upvoted.
– JohnDoea
54 mins ago
|
show 3 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
To understand umask, you first need to understand the structure of processes in Unix/Linux. Which is to say, they form a tree-like structure. Each process needs to have a parent, which is the process that spawned it. (With the exception of the first process, init
). Each process may or may not spawn more processes, called children.
Each process has a mask property. This is what is queried or set using the umask command.
Processes inherit the mask of their parent. They can then change their own mask. For example, there is a umask()
C function that can change the mask of the program you are writing, without needing to call umask
from the shell.
A child process cannot affect the mask of their parent. Therefore, changing the mask of a process will not affect the entire system. It will only affect any future child processes.
Since the purpose of a shell is to be able to create and control other processes, a umask
command is built in to most shells. This isn't required for a shell, it is possible to write a basic shell that has no umask
function. But such a shell would not be considered useful as a general-purpose shell for logging in and administering a system.
You can test what I'm saying yourself, using the fact that a shell like Bash can spawn other Bash shells (or whatever other shell you like):
- Open a terminal
- Run the
umask
command to query the current value - Run
bash
(or whatever) to spawn a child shell - Run
umask
to check the value of the child's mask - Set the child's mask to something else, eg run
umask 0000
- Run
umask
to check the child's mask again - Exit from the child shell (run
exit
or pressCtrl-d
) - You are now back in the parent shell again. Run
umask
to check its mask
Useful references:
man 1 umask
man 2 umask
(This gives the reference for theumask()
C function)man bash
(and search forumask
)- https://en.wikipedia.org/wiki/Umask
Hello, I'm sad to say that I don't get an answer to my particular question. You might want to consider editing a bit to touch my question directly.
– JohnDoea
3 hours ago
This might result in upvotes...
– JohnDoea
3 hours ago
You want me to put a line at the top saying "Changing umask does not affect the whole operating system"?
– cryptarch
3 hours ago
1
Do I understand correct? --- A Bash process with mask X will inherit it to a Dash process but if we change it in the Dash process to Y, the ksh process will have Y But the Bash will still have X.
– JohnDoea
56 mins ago
1
Yes, in this case I am. Thanks and upvoted.
– JohnDoea
54 mins ago
|
show 3 more comments
up vote
3
down vote
accepted
To understand umask, you first need to understand the structure of processes in Unix/Linux. Which is to say, they form a tree-like structure. Each process needs to have a parent, which is the process that spawned it. (With the exception of the first process, init
). Each process may or may not spawn more processes, called children.
Each process has a mask property. This is what is queried or set using the umask command.
Processes inherit the mask of their parent. They can then change their own mask. For example, there is a umask()
C function that can change the mask of the program you are writing, without needing to call umask
from the shell.
A child process cannot affect the mask of their parent. Therefore, changing the mask of a process will not affect the entire system. It will only affect any future child processes.
Since the purpose of a shell is to be able to create and control other processes, a umask
command is built in to most shells. This isn't required for a shell, it is possible to write a basic shell that has no umask
function. But such a shell would not be considered useful as a general-purpose shell for logging in and administering a system.
You can test what I'm saying yourself, using the fact that a shell like Bash can spawn other Bash shells (or whatever other shell you like):
- Open a terminal
- Run the
umask
command to query the current value - Run
bash
(or whatever) to spawn a child shell - Run
umask
to check the value of the child's mask - Set the child's mask to something else, eg run
umask 0000
- Run
umask
to check the child's mask again - Exit from the child shell (run
exit
or pressCtrl-d
) - You are now back in the parent shell again. Run
umask
to check its mask
Useful references:
man 1 umask
man 2 umask
(This gives the reference for theumask()
C function)man bash
(and search forumask
)- https://en.wikipedia.org/wiki/Umask
Hello, I'm sad to say that I don't get an answer to my particular question. You might want to consider editing a bit to touch my question directly.
– JohnDoea
3 hours ago
This might result in upvotes...
– JohnDoea
3 hours ago
You want me to put a line at the top saying "Changing umask does not affect the whole operating system"?
– cryptarch
3 hours ago
1
Do I understand correct? --- A Bash process with mask X will inherit it to a Dash process but if we change it in the Dash process to Y, the ksh process will have Y But the Bash will still have X.
– JohnDoea
56 mins ago
1
Yes, in this case I am. Thanks and upvoted.
– JohnDoea
54 mins ago
|
show 3 more comments
up vote
3
down vote
accepted
up vote
3
down vote
accepted
To understand umask, you first need to understand the structure of processes in Unix/Linux. Which is to say, they form a tree-like structure. Each process needs to have a parent, which is the process that spawned it. (With the exception of the first process, init
). Each process may or may not spawn more processes, called children.
Each process has a mask property. This is what is queried or set using the umask command.
Processes inherit the mask of their parent. They can then change their own mask. For example, there is a umask()
C function that can change the mask of the program you are writing, without needing to call umask
from the shell.
A child process cannot affect the mask of their parent. Therefore, changing the mask of a process will not affect the entire system. It will only affect any future child processes.
Since the purpose of a shell is to be able to create and control other processes, a umask
command is built in to most shells. This isn't required for a shell, it is possible to write a basic shell that has no umask
function. But such a shell would not be considered useful as a general-purpose shell for logging in and administering a system.
You can test what I'm saying yourself, using the fact that a shell like Bash can spawn other Bash shells (or whatever other shell you like):
- Open a terminal
- Run the
umask
command to query the current value - Run
bash
(or whatever) to spawn a child shell - Run
umask
to check the value of the child's mask - Set the child's mask to something else, eg run
umask 0000
- Run
umask
to check the child's mask again - Exit from the child shell (run
exit
or pressCtrl-d
) - You are now back in the parent shell again. Run
umask
to check its mask
Useful references:
man 1 umask
man 2 umask
(This gives the reference for theumask()
C function)man bash
(and search forumask
)- https://en.wikipedia.org/wiki/Umask
To understand umask, you first need to understand the structure of processes in Unix/Linux. Which is to say, they form a tree-like structure. Each process needs to have a parent, which is the process that spawned it. (With the exception of the first process, init
). Each process may or may not spawn more processes, called children.
Each process has a mask property. This is what is queried or set using the umask command.
Processes inherit the mask of their parent. They can then change their own mask. For example, there is a umask()
C function that can change the mask of the program you are writing, without needing to call umask
from the shell.
A child process cannot affect the mask of their parent. Therefore, changing the mask of a process will not affect the entire system. It will only affect any future child processes.
Since the purpose of a shell is to be able to create and control other processes, a umask
command is built in to most shells. This isn't required for a shell, it is possible to write a basic shell that has no umask
function. But such a shell would not be considered useful as a general-purpose shell for logging in and administering a system.
You can test what I'm saying yourself, using the fact that a shell like Bash can spawn other Bash shells (or whatever other shell you like):
- Open a terminal
- Run the
umask
command to query the current value - Run
bash
(or whatever) to spawn a child shell - Run
umask
to check the value of the child's mask - Set the child's mask to something else, eg run
umask 0000
- Run
umask
to check the child's mask again - Exit from the child shell (run
exit
or pressCtrl-d
) - You are now back in the parent shell again. Run
umask
to check its mask
Useful references:
man 1 umask
man 2 umask
(This gives the reference for theumask()
C function)man bash
(and search forumask
)- https://en.wikipedia.org/wiki/Umask
edited 3 hours ago
answered 5 hours ago
cryptarch
2513
2513
Hello, I'm sad to say that I don't get an answer to my particular question. You might want to consider editing a bit to touch my question directly.
– JohnDoea
3 hours ago
This might result in upvotes...
– JohnDoea
3 hours ago
You want me to put a line at the top saying "Changing umask does not affect the whole operating system"?
– cryptarch
3 hours ago
1
Do I understand correct? --- A Bash process with mask X will inherit it to a Dash process but if we change it in the Dash process to Y, the ksh process will have Y But the Bash will still have X.
– JohnDoea
56 mins ago
1
Yes, in this case I am. Thanks and upvoted.
– JohnDoea
54 mins ago
|
show 3 more comments
Hello, I'm sad to say that I don't get an answer to my particular question. You might want to consider editing a bit to touch my question directly.
– JohnDoea
3 hours ago
This might result in upvotes...
– JohnDoea
3 hours ago
You want me to put a line at the top saying "Changing umask does not affect the whole operating system"?
– cryptarch
3 hours ago
1
Do I understand correct? --- A Bash process with mask X will inherit it to a Dash process but if we change it in the Dash process to Y, the ksh process will have Y But the Bash will still have X.
– JohnDoea
56 mins ago
1
Yes, in this case I am. Thanks and upvoted.
– JohnDoea
54 mins ago
Hello, I'm sad to say that I don't get an answer to my particular question. You might want to consider editing a bit to touch my question directly.
– JohnDoea
3 hours ago
Hello, I'm sad to say that I don't get an answer to my particular question. You might want to consider editing a bit to touch my question directly.
– JohnDoea
3 hours ago
This might result in upvotes...
– JohnDoea
3 hours ago
This might result in upvotes...
– JohnDoea
3 hours ago
You want me to put a line at the top saying "Changing umask does not affect the whole operating system"?
– cryptarch
3 hours ago
You want me to put a line at the top saying "Changing umask does not affect the whole operating system"?
– cryptarch
3 hours ago
1
1
Do I understand correct? --- A Bash process with mask X will inherit it to a Dash process but if we change it in the Dash process to Y, the ksh process will have Y But the Bash will still have X.
– JohnDoea
56 mins ago
Do I understand correct? --- A Bash process with mask X will inherit it to a Dash process but if we change it in the Dash process to Y, the ksh process will have Y But the Bash will still have X.
– JohnDoea
56 mins ago
1
1
Yes, in this case I am. Thanks and upvoted.
– JohnDoea
54 mins ago
Yes, in this case I am. Thanks and upvoted.
– JohnDoea
54 mins ago
|
show 3 more comments
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481146%2fis-a-file-creation-mask-setted-by-a-given-shells-umask-is-typically-unique-to-t%23new-answer', 'question_page');
);
Post as a guest
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
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
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