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 07-12-2012, 04:24 PM   #1
Bob Fletcher
Member
 
Registered: Nov 2008
Location: Hinckley UK
Distribution: Manjaro Cinnamon
Posts: 140

Rep: Reputation: 1
Umask settings


Sorry I cannot work this out I have read heaps on the umask setting but cannot get the result I want. I want a umask setting that will give me the permissions rw-rw-rw- (666). Can someone please tell me what that would be?

Thank you

Robert...
 
Old 07-12-2012, 04:32 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
umask 000

Umask is a subtraction of the octal permissions, which if you set your umask to 0 will be 666, by design it makes nothing executable(directories are an exception for the owner) by default.

So your default new file perms will always be 666 subtracted by your umask.

Couple quick examples:

umask 400 = 266 r--rw-rw
umask 060 = 606 rw----rw-
umask 022(default value) = rw-r--r--
 
Old 07-12-2012, 04:34 PM   #3
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Heres a good page to bookmark for future reference: http://www.cyberciti.biz/tips/unders...lue-usage.html
 
Old 07-13-2012, 01:35 AM   #4
Bob Fletcher
Member
 
Registered: Nov 2008
Location: Hinckley UK
Distribution: Manjaro Cinnamon
Posts: 140

Original Poster
Rep: Reputation: 1
Hi,

Thanks for that. The link you gave me was one I was using but I ended up with 111 and denied myself access. It a bit early in the morning but I will have to print that out and sit with pen and paper and work it out.

Robert...
 
Old 07-13-2012, 12:07 PM   #5
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Just set your umask to 000 in your .bashrc file, you should be good. Keep in mind that some people consider this to have some security implications due to the write permission for the all users set.
 
Old 07-13-2012, 12:59 PM   #6
Bob Fletcher
Member
 
Registered: Nov 2008
Location: Hinckley UK
Distribution: Manjaro Cinnamon
Posts: 140

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by Kustom42 View Post
Just set your umask to 000 in your .bashrc file, you should be good. Keep in mind that some people consider this to have some security implications due to the write permission for the all users set.
Thank you so much for getting back to me as I remain a little confused but as you mentioned the .bashrc I think I may be gaining some understanding.

Am I right to say that the .bachrc umask setting sets the default for the system? The umask I was applying was to a mounted external drive. Initially the usmask was 022 and that was given to me it set the permissions to 555. I knew the umask was important for the permissions as I had to deal with it in vsftpd.conf (changed to Pure-Ftp).

That tutorial talks about subtracting the umast value, must have some relation to the system, am I correct?

The umask of 000 has given me 777 on directories and files. That's OK it works but I guess security should not be compromise anywhere. The External drive I have connected also has a samba share and that allows reading and writing to anyone on the Windows box. That is OK.

So setting the umask on the drive the value has some relation to the umask for the system. Would you have a minute to explain that to me and why I got the permissions of 777.

Thank you so much

Robert...
 
Old 07-13-2012, 01:20 PM   #7
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
if you are creating files that have 777 perms by default I would like to know how because I didn't think it was possible. The default permissions in the Linux OS are(rwxrwxrwx) 0777 for directories and for files they are 0666 (rw-rw-rw).

The .bashrc file is a user bash configuration file, the umask is a environment variable associated with your user's environment. The .bashrc file is read each time you login and each user will have one in their home directory. You can set any custom aliases, env variables etc.. in this file to be set each time you login.

The umask setting is a system wide variable, so there isnt a way to set it just for one file system or hard drive as you mention. It simply tells the OS to subtract XXXX octal permissions from new files or folders that are created.

If you set your umask to 0000 in your .bashrc any new files you create should have the perms of 0666 and directories 0777, if you see something different please provide some bash output that shows what you did, exactly how you did it, and the results.
 
1 members found this post helpful.
Old 07-13-2012, 03:54 PM   #8
TommyC7
Member
 
Registered: Mar 2012
Distribution: Slackware, CentOS, OpenBSD, FreeBSD
Posts: 520

Rep: Reputation: Disabled
As Kustom42 said earlier, umask subtracts from the permissions. I don't recall if the standard permissions without umask are 777 or 666, but either way, umask subtracts from those. To expand on Kustom42's examples, let's have a look with the generic equation (again I'm not sure if it was 777 or 666 for standard permissions so I'm using 777).

Code:
   777
-  umask
===============
New Permissions
So as another example:

Code:
umask = 123

   777
-  123
=======
   654
With umask = 123, permissions are set to "rw-r-x-r--".

Last edited by TommyC7; 07-13-2012 at 03:56 PM.
 
Old 07-13-2012, 04:06 PM   #9
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
For clarification, the defaults are 0666 for files and 0777 for files. That is what Mr. Google's says and I tested it on a Red Hat system to confirm. There may be some differences with other distros but I havent found anything to suggest there is.
 
Old 07-14-2012, 05:51 PM   #10
Bob Fletcher
Member
 
Registered: Nov 2008
Location: Hinckley UK
Distribution: Manjaro Cinnamon
Posts: 140

Original Poster
Rep: Reputation: 1
Thank you everyone for your help. I went to Birmingham today to Waterstones a purchased some books on Linux and WordPress so things are coming together.

Thanks
Robert...
 
  


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
Proper umask settings for /etc/fstab? stefanlasiewski Linux - General 6 06-05-2009 06:27 PM
X applications ignore UMASK settings thejasondean Ubuntu 0 01-10-2007 05:46 AM
vsftpd umask settings fluffyvoidbunny Linux - Software 2 02-07-2006 03:06 PM
Umask - Settings XaViaR Linux - General 2 09-28-2005 06:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:57 PM.

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
Open Source Consulting | Domain Registration