Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If I am not wrong, this is how umask is calculated.
for dir, 777 - 022(root's umask value) = 755.
for file, 666 - 022(root's umask value) = 644.
Now, where this umask value is defined? Is it the /etc/bashrc file?.
If so, then what is the file /etc/login.defs for? My /etc/login.defs file says 077 as umask - what does this mean?
Also where is cmask defined?
The umask can be changed using umask command, but that is temporary. Right? If I have to make it permanent, I can edit .bashrc file in my home dir and append "umask value" to it.
Also, say I am root and I want to set a specific umask for all other users, how to do that?
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495
Rep:
Quote:
Originally Posted by BeingGokul
If I am not wrong, this is how umask is calculated.
for dir, 777 - 022(root's umask value) = 755.
for file, 666 - 022(root's umask value) = 644.
Now, where this umask value is defined? Is it the /etc/bashrc file?.
Yes, that is correct. By default, files will not have the executable permission. Defining umask is done in /etc/fstab. If you don't have a umask entry there, I'm guessing a default value is used.
Quote:
If so, then what is the file /etc/login.defs for? My /etc/login.defs file says 077 as umask - what does this mean?
Read the comments above the umask entry in that file.
Code:
#
# Login configuration initializations:
#
# ERASECHAR Terminal ERASE character ('\010' = backspace).
# KILLCHAR Terminal KILL character ('\025' = CTRL/U).
# UMASK Default "umask" value.
#
# The ERASECHAR and KILLCHAR are used only on System V machines.
#
# UMASK is the default umask value for pam_umask and is used by
# useradd and newusers to set the mode of the new home directories.
# 022 is the "historical" value in Debian for UMASK
# 027, or even 077, could be considered better for privacy
# There is no One True Answer here : each sysadmin must make up his/her
# mind.
#
# If USERGROUPS_ENAB is set to "yes", that will modify this UMASK default value
# for private user groups, i. e. the uid is the same as gid, and username is
# the same as the primary group name: for these, the user permissions will be
# used as group permissions, e. g. 022 will become 002.
#
# Prefix these values with "0" to get octal, "0x" to get hexadecimal.
#
ERASECHAR 0177
KILLCHAR 025
UMASK 022
Quote:
Also where is cmask defined?
I'm unsure. Have you googled it?
Quote:
The umask can be changed using umask command, but that is temporary. Right? If I have to make it permanent, I can edit .bashrc file in my home dir and append "umask value" to it.
Using the umask command is temporary and only applies to that terminal session. I decided once that I wanted all my files to have o-rwx,g-rwx, and put umask 077 in my .bashrc., not a good idea I later found out if you use sudo as it also affects those files. I found a better solution.
Code:
bullshark@beastlinux ~ $ crontab -l | tail -2
# m h dom mon dow command
0 * * * * chmod -R g-rwx,o-rwx /home/bullshark
bullshark@beastlinux ~ $
Quote:
Also, say I am root and I want to set a specific umask for all other users, how to do that?
Thanks for your time and assistance in advance.
Edit the /etc/fstab to have a umask value for each file system. That doesn't prevent a user from changing permissions or using the umask command.
Last edited by fakie_flip; 07-27-2013 at 08:13 PM.
The bashrc in your home directory overrides the system wide settings in /etc.
So to control users you can set in there home bashrc.
Every user has write permission to their bashrc, so how would that help? I mean, if root sets it in the .bashrc of the user, then the user can override it.
Yes, that is correct. By default, files will not have the executable permission. Defining umask is done in /etc/fstab. If you don't have a umask entry there, I'm guessing a default value is used.
Read the comments above the umask entry in that file.
Code:
#
# Login configuration initializations:
#
# ERASECHAR Terminal ERASE character ('\010' = backspace).
# KILLCHAR Terminal KILL character ('\025' = CTRL/U).
# UMASK Default "umask" value.
#
# The ERASECHAR and KILLCHAR are used only on System V machines.
#
# UMASK is the default umask value for pam_umask and is used by
# useradd and newusers to set the mode of the new home directories.
# 022 is the "historical" value in Debian for UMASK
# 027, or even 077, could be considered better for privacy
# There is no One True Answer here : each sysadmin must make up his/her
# mind.
#
# If USERGROUPS_ENAB is set to "yes", that will modify this UMASK default value
# for private user groups, i. e. the uid is the same as gid, and username is
# the same as the primary group name: for these, the user permissions will be
# used as group permissions, e. g. 022 will become 002.
#
# Prefix these values with "0" to get octal, "0x" to get hexadecimal.
#
ERASECHAR 0177
KILLCHAR 025
UMASK 022
I'm unsure. Have you googled it?
Using the umask command is temporary and only applies to that terminal session. I decided once that I wanted all my files to have o-rwx,g-rwx, and put umask 077 in my .bashrc., not a good idea I later found out if you use sudo as it also affects those files. I found a better solution.
Code:
bullshark@beastlinux ~ $ crontab -l | tail -2
# m h dom mon dow command
0 * * * * chmod -R g-rwx,o-rwx /home/bullshark
bullshark@beastlinux ~ $
Edit the /etc/fstab to have a umask value for each file system. That doesn't prevent a user from changing permissions or using the umask command.
/etc/fstab -- editing it to have umask for each file system --? Is that really possible? When you say filesystem, do you mean the partition? and how would i set it in the fstab file? what's the format?
Also,
Setting it for a partition means, whoever the user maybe, if they create files or dir under that partition, that file/dir will get the pre-defined permissions. Is that's the case?
Coming to login.defs -- my login.defs says umask as 077. But whereas when i create files/directories using any user in my system, it doesn't seem to follow 077, instead it is 022. I checked .bashrc of all users and found no overriding also. What does this 077 implies? why it's not being implemented? what overrides that?
Last edited by BeingGokul; 07-28-2013 at 11:48 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.