Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
I need to change permissions for some folders and files but I do not get how the octal number representation work. Also how do you use umask with fstab file?
If you can get your mind around the relationship of '4 2 1' with the mode bits 'r w x' as I posted above, then you don't need to do all that adding of 400 200 100 40 20 10 4 2 1.
It's the bit relationships, not the actual value in the hundreds.
Introduction to Linux
A Hands on Guide
Machtelt Garrels
CoreSequence.com
<tille@coresequence.com>
Version 3.0.2 Last updated 20030228 Edition
"...before the mask is applied, a directory has permissions 777 or rwxrwxrwx, a plain file 666 or
rw−rw−rw−.
The umask value is substracted from these default permissions after the function has created the new file or
directory. Thus, a directory will have permissions of 775 by default, a file 664, if the mask value is (0)002."
I'm using linux the first time and trying to understand the permission.
The permission i have for my newly created directory and file is different. My default umask is 0022. I'm wondering why the umask value shown in my pc is having 4 digits instead of the standard 3 digit 022? And using 777 to minus away 022 should be 755. But both my directory and file does not have the permission of 755 as shown below. Appreciate if anyone can kindly explain to me...
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
Quote:
Originally posted by lido ...
The permission i have for my newly created directory and file is different. My default umask is 0022. I'm wondering why the umask value shown in my pc is having 4 digits instead of the standard 3 digit 022? And using 777 to minus away 022 should be 755. But both my directory and file does not have the permission of 755 as shown below. Appreciate if anyone can kindly explain to me...
Go down to "3.4.2.2. The file mask" and check that out. You can ignore the first 0 in 0022 for this.
lido, 755 is rwxr-xr-x .
Touch just changes the file time stamp. What do you get when you create a new file? Should be 0666 - 0022 = 0644 = rw-r--r-- (oh, which is what you do have for file.c).
Directory default before umask = 777
File default, before umask = 666
(according to that Introduction to Linux book.)
Umask is just chmod reversed. Count backwards from 7, so for a umask of 7 you would use 0. For 6, you would use 1, and so on:
0 : 7
1 : 6
2 : 5
3 : 4
4 : 3
5 : 2
6 : 1
7 : 0
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.