You are not logged in.

#1 2009-09-26 17:44:51

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Setting Permissions on New Files / Folders

I am trying to understand the default permissions for my new Arch Linux system. It appears that the umask for my system is 0022 and when I create a directory or file, I get the following:

[carlos@tiger ~]$ umask
0022
[carlos@tiger ~]$ mkdir xyz
[carlos@tiger ~]$ touch zoo
[carlos@tiger ~]$ ls -l
total 24
drwx------ 2 carlos users 4096 2009-09-21 16:42 files
drwx------ 2 carlos users 4096 2009-09-26 13:34 iso
drwx------ 2 carlos users 4096 2009-09-21 16:42 music
drwx------ 2 carlos users 4096 2009-09-21 16:42 pics
drwx------ 2 carlos users 4096 2009-09-21 16:42 vids
drwxr-xr-x 2 carlos users 4096 2009-09-26 13:42 xyz
-rw-r--r-- 1 carlos users    0 2009-09-26 13:42 zoo

Now I am trying to understand how in Arch or Linux in general when I create any new directory as myself 'carlos', can I set the permissions on the newly created folder to 700? As well a newly create text file from 644 which appears to be the default to 700?

Thanks for any help!


./

Offline

#2 2009-09-26 18:19:29

hack.augusto
Member
From: Brazil
Registered: 2008-08-28
Posts: 124

Re: Setting Permissions on New Files / Folders

`chmod 700 xyz` changes the permissions to rwx------

Offline

#3 2009-09-26 18:27:04

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Re: Setting Permissions on New Files / Folders

Yes - I understand how to manually alter / modify permissions however I find it annoying to do so. I can set up a cron job to run every hour that does:

chmod -R 700 /home/carlos

however I would like to know if in Linux / Arch, I can force all new directories I create as myself in my home directory as 700.

Is this possible?


./

Offline

#4 2009-09-26 18:55:00

hack.augusto
Member
From: Brazil
Registered: 2008-08-28
Posts: 124

Re: Setting Permissions on New Files / Folders

You probably don't need that, because /home/carlos already is 700, so other users don't have access to it.
but yeah, if you want you can have a cron job to do that, i can't think of any built-in feature to do that

Offline

#5 2009-09-26 19:08:55

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: Setting Permissions on New Files / Folders

What is the output of "id carlos"?


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#6 2009-09-26 21:31:58

Teoulas
Member
From: Athens, Greece
Registered: 2009-03-21
Posts: 70

Re: Setting Permissions on New Files / Folders

If you want files and directories to inherit the parent's permissions you have to use ACLs (access control lists). Use the getfacl/setfacl/chacl commands. For more info: man acl

If you want all files and directories to be created as 0700 you could also change your umask to 0077.

Last edited by Teoulas (2009-09-26 21:39:17)

Offline

#7 2009-09-26 22:57:39

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: Setting Permissions on New Files / Folders

Carlwill wrote:

Now I am trying to understand how in Arch or Linux in general when I create any new directory as myself 'carlos', can I set the permissions on the newly created folder to 700? As well a newly create text file from 644 which appears to be the default to 700?

Directories default to 777, files to 666.
The umask gets subtracted so if you want to have 700 as  default for folders set your umask to 077.

Offline

#8 2009-09-27 00:21:06

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: Setting Permissions on New Files / Folders

A reasonably good explanation of umask can be found at http://code.google.com/edu/tools101/lin … sions.html. Scroll down to the section titled, not surprisingly, "About umask."

Offline

#9 2009-09-28 18:41:27

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Re: Setting Permissions on New Files / Folders

raf_kig wrote:
Carlwill wrote:

Now I am trying to understand how in Arch or Linux in general when I create any new directory as myself 'carlos', can I set the permissions on the newly created folder to 700? As well a newly create text file from 644 which appears to be the default to 700?

Directories default to 777, files to 666.
The umask gets subtracted so if you want to have 700 as  default for folders set your umask to 077.

On my Linux system and everyone I have tested on the default permissions I get are 755 for directories and 644 for files. I don't know how you got 777 and 666.


./

Offline

#10 2009-09-28 18:55:46

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: Setting Permissions on New Files / Folders

Is your concern that the group users is getting read access to all newly created files in your homedir?


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#11 2009-09-29 11:13:40

clmates
Member
From: A Coruña - España
Registered: 2009-04-25
Posts: 79

Re: Setting Permissions on New Files / Folders

Hi Carlos,

by your name I asume you uinderstand Spanish ;-) If this is the case, you could take a look at

http://en.opensuse.org/Es.Howto_setup_p … _with_acls

is a opensuse Wiki entry (by me ;-D) that explain how to use ACL for setting up permissions and inherit permissions between folders

HTH


-

Arch64 - Acer AX3950 - i5-650 3.2 GHz - 8 GB RAM - Nvidia GeForce 320 1 GB Ram
Arch32 - Samsung NC10 - 2 GB Ram

Offline

#12 2009-09-29 14:50:44

juken
Member
Registered: 2009-03-21
Posts: 1

Re: Setting Permissions on New Files / Folders

If you're using bash, you can do the following:

echo umask 077 >> ~/.bashrc

You will need to reset your bash settings (opening a terminal should work). Now when you create files and directories you should get the following:

[tmp]$ mkdir xyz
[tmp]$ touch zoo
[tmp]$ ls -l
total 4
drwx------ 2 juken juken 4096 2009-09-29 10:49 xyz
-rw------- 1 juken juken    0 2009-09-29 10:49 zoo

Let us know how you make out.

Last edited by juken (2009-09-29 14:52:44)

Offline

#13 2009-10-02 10:21:13

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: Setting Permissions on New Files / Folders

Carlwill wrote:

On my Linux system and everyone I have tested on the default permissions I get are 755 for directories and 644 for files. I don't know how you got 777 and 666.

On most linux systems the umask defaults to 022 ;-)

So you got defaults of  111 111 111 / 110 110 110 for folders/dirs
subtracting the umask 000 010 010 (bitwise) you get 111 101 101 / 110 100 100 which is just 755 / 644

Regards,

raf

Last edited by raf_kig (2009-10-02 10:28:07)

Offline

#14 2020-03-13 16:10:04

neofc
Member
Registered: 2020-03-13
Posts: 1

Re: Setting Permissions on New Files / Folders

I'm quite new to arch linux, but maybe it helps.

The global unmask default is set in /etc/profile.
On my current system (Arch Linux 2020.03.01) it was:

umask 022

Offline

#15 2020-03-13 16:12:54

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,466

Re: Setting Permissions on New Files / Folders

It's been over 10 years, you really think the OP is still looking for a solution?

https://wiki.archlinux.org/index.php/Co … bumping%22

Last edited by Scimmia (2020-03-13 16:15:06)

Offline

#16 2020-03-13 16:18:22

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,788
Website

Re: Setting Permissions on New Files / Folders

Thanks for contributing, neofc. However, please pay attention to the age of threads and refrain from posting in those which are long since abandoned.

https://wiki.archlinux.org/index.php/Co … bumping%22

Closing.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB