LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 08-16-2005, 07:16 AM   #1
Rodolfo Medina
Member
 
Registered: Nov 2004
Posts: 61

Rep: Reputation: 15
Can chmod affect `future' files?


I mean, is there a way to make the command `chmod'
act upon files in a certain directory that have not been created yet?
For example:

# mkdir mydir
# touch mydir/file1
# ls -l mydir
total 0
-rw-r--r-- 1 root root 0 ago 16 12:36 file1
# chmod go-r mydir/*
# ls -l mydir
total 0
-rw------- 1 root root 0 ago 16 12:36 file1
# touch mydir/file2
# ls -l mydir
total 0
-rw------- 1 root root 0 ago 16 12:36 file1
-rw-r--r-- 1 root root 0 ago 16 12:38 file2

. The new file created, file2, is not affected by the command '# chmod go-r mydir/*'
previously given. Was it possible, and how,
that file2 were born with same permissions of file1?

Thanks for any reply,
Rodolfo
 
Old 08-16-2005, 07:27 AM   #2
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 441

Rep: Reputation: 141Reputation: 141
Re: Can chmod affect `future' files?

Quote:
Originally posted by Rodolfo Medina
I mean, is there a way to make the command `chmod'
act upon files in a certain directory that have not been created yet?
For example:

# mkdir mydir
# touch mydir/file1
# ls -l mydir
total 0
-rw-r--r-- 1 root root 0 ago 16 12:36 file1
# chmod go-r mydir/*
# ls -l mydir
total 0
-rw------- 1 root root 0 ago 16 12:36 file1
# touch mydir/file2
# ls -l mydir
total 0
-rw------- 1 root root 0 ago 16 12:36 file1
-rw-r--r-- 1 root root 0 ago 16 12:38 file2

. The new file created, file2, is not affected by the command '# chmod go-r mydir/*'
previously given. Was it possible, and how,
that file2 were born with same permissions of file1?

Thanks for any reply,
Rodolfo
UMASK affects the permissions that a file/directory gets when it is created.
If i understand correctly, this is what you mean.
the parameter it gets is the octal number that gets subtracted from 666 (rw-) or 777 (rwx for directories)
In your example you want rw for owner and nothing for others so you want permissions 600, so the umask is 077
usual examples of umask is 077 (which gives rw-------) and 022 (which givers rw-r--r--)
As you see you have 022 umask that is why the file2 gets those permissions.

I don't know what distribution you use, but usually every major distribution uses a default umask in /etc/profile for /bin/bash

For example my /etc/profile has the following:

# Default umask. A umask of 022 prevents new files from being created group
# and world writable.
umask 022
 
Old 08-16-2005, 07:58 AM   #3
Rodolfo Medina
Member
 
Registered: Nov 2004
Posts: 61

Original Poster
Rep: Reputation: 15
Thanks:
but umask does not allow to select a desired file,
it affects all new files of all directories, doesn't it?
I was meaning a way to change permissions for
future new files of a desired directory.
Insn't this possible?

Cheers,
Rodolfo
 
Old 08-16-2005, 09:28 AM   #4
mherring02
Member
 
Registered: May 2005
Location: Pasadena, CA
Distribution: Ubuntu, Fedora
Posts: 50

Rep: Reputation: 15
I would think that any new file would default to the permissions of the directory---and perhaps to the user who created it.

I don't think you can pre-ordain anything but the default behavior---and I don't know why you would want to. One of the worst things with computers is some non-standard behavior caused by **someone** (including you) setting a preference and then forgetting what was set.
 
Old 08-17-2005, 03:23 AM   #5
Rodolfo Medina
Member
 
Registered: Nov 2004
Posts: 61

Original Poster
Rep: Reputation: 15
All right, thank you.

Rodolfo
 
  


Reply



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
chmod recursion -- files only Risc91 AIX 16 09-28-2016 11:15 AM
Future of Linux, Future of BSD ? tarballed Linux - General 28 01-01-2012 04:04 PM
chmod deleted my files NonSumPisces Linux - Newbie 14 09-22-2007 11:37 PM
chmod recursive on files on dlublink Linux - Newbie 6 03-02-2005 08:45 AM
chmod directories and files seperately robeb Linux - General 2 05-23-2003 08:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:17 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