LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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

Reply
 
Search this Thread
Old 07-27-2013, 05:36 PM   #1
BeingGokul
LQ Newbie
 
Registered: Jul 2013
Location: Bangalore, India
Distribution: RedHat, CentOS
Posts: 11

Rep: Reputation: Disabled
Question Clarify umask feature


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?

Thanks for your time and assistance in advance.
 
Old 07-27-2013, 05:47 PM   #2
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 718

Rep: Reputation: 102Reputation: 102
Clarify umask feature

The bashrc in your home directory overrides the system wide settings in /etc.

So to control users you can set in there home bashrc.
 
Old 07-27-2013, 08:10 PM   #3
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Rep: Reputation: 80
Quote:
Originally Posted by BeingGokul View Post
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.
 
Old 07-27-2013, 08:42 PM   #4
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,865

Rep: Reputation: 639Reputation: 639Reputation: 639Reputation: 639Reputation: 639Reputation: 639
Quote:
Originally Posted by jv2112 View Post
The bashrc in your home directory overrides the system wide settings in /etc.

So to control users you can set in there home bashrc.
But the user can then just change it back - so if he wants to enforce it for all users that is not a solution.
 
Old 07-28-2013, 11:40 AM   #5
BeingGokul
LQ Newbie
 
Registered: Jul 2013
Location: Bangalore, India
Distribution: RedHat, CentOS
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jv2112 View Post
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.
 
Old 07-28-2013, 11:41 AM   #6
BeingGokul
LQ Newbie
 
Registered: Jul 2013
Location: Bangalore, India
Distribution: RedHat, CentOS
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by astrogeek View Post
But the user can then just change it back - so if he wants to enforce it for all users that is not a solution.
Yes, exactly. So, any solutions that you are aware of?
 
Old 07-28-2013, 11:46 AM   #7
BeingGokul
LQ Newbie
 
Registered: Jul 2013
Location: Bangalore, India
Distribution: RedHat, CentOS
Posts: 11

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by fakie_flip View Post
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.
 
Old 07-30-2013, 03:01 PM   #8
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Rep: Reputation: 80
All the examples I looked at only used umask for fat and ntfs partitions in the fstab, so I could be wrong.
 
  


Reply

Tags
redhat, umask


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Git merging feature 1 and feature 2 mzh Programming 1 06-08-2012 02:57 AM
umask and permissions: has umask 007 bad side effects? browny_amiga Linux - General 2 09-09-2011 08:01 AM
umask and /usr/bin/umask linux_user2011 Linux - Newbie 6 04-27-2011 02:05 AM
Clarify something about Fedora for me? purplecow Fedora 12 11-05-2004 05:36 PM
help me clarify shanenin Linux - Software 1 11-06-2003 09:28 PM


All times are GMT -5. The time now is 09:21 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration