Shouldn't a file I create default to being owned by me?
Yuki Cuss
celtic at sairyx.org
Fri Feb 17 12:10:32 UTC 2006
Dave M G wrote:
> Ubuntu Users,
>
> I have Appache, PHP, and MySQL all set up and running smoothly. I
> also have three different web sites that I keep in my localhost
> directory and view from within FireFox, without any problems.
>
> So, I was suprised when I created a little PHP script to test
> something, and when I viewed it through FireFox, it said there was a
> "permissions error".
>
> At first I thought this must be a PHP problem, because I create and
> view files within my localhost directory all the time. But the people
> on the PHP mailing list were sure it was just a file permissions problem.
>
> Sure enough, I looked at the file properties from a command prompt,
> and the default was not to be read or written to:
> -rw------- 1 dave dave 20 2006-02-13 22:45
> /home/dave/web_sites/phpinfo.php
>
> So I changed the properties with chmod 777 and the file opens fine.
>
> Now I'm confused by this. Why would this file, which I created and
> saved using gedit, automatically have its permissions set up so I
> can't view or edit it? Why does no other file that I have made or
> edited behaved like this? Is this a one time problem, or is there a
> fundamental problem I'm missing?
>
> Any advice would be much appreciated.
>
> --
> Dave M G
>
Perhaps you misread it;
-rw------- 1 dave dave 20 2006-02-13 22:45
/home/dave/web_sites/phpinfo.php
That means *only* dave can view it. For a few more examples; from my
filesystem:
drwx------ 4 celtic celtic 4096 2006-02-17 18:47 .gconf
That means *only* celtic (myself!) can read/write/execute (ie. go into)
that directory. (note the `d')
-rw-r----- 1 celtic celtic 0 2006-01-21 15:45 .gksu.lock
This means that only I (celtic) can read/write to this file, and members
of the group `celtic' (eg. myself, by default) may read it.
drwxr-x--- 19 celtic celtic 4096 2006-02-17 22:01 code
Much the same, except both I and group members of `celtic' can
read/execute the directory.
drwxr-xr-x 3 celtic celtic 4096 2006-01-28 20:25 vmware
Now, I can read/write/execute, members of `celtic' can read/execute,
*and* all other users can read/execute.
Files by default are created with the permissions 666 MINUS your umask.
Directories are 777 MINUS your umask. To find your current umask, try
typing it at a console; the default is 0022.
celtic at xyrias:~$ umask
0022
celtic at xyrias:~$
That means, if I create a directory, its permissions will be 777-22 =
755. If you don't know how permissions are read in octal, here's the
break down;
1 represents `x' (executable); 2 represents `w' (writable), and 4
represents `r' (readable). Read the digits in left to right order; user,
group, other. Thus, 755 means that the `user' (owner, eg. dave, celtic)
can read+write+execute (1+2+4=7). The group members (celtic, dave,
wheel, what have you ..) can read+execute (1+4=5), as can the other
users (everyone else).
The most likely thing that happened is that your umask is set to 0077.
(note that you can read a umask just like a normal permission, except
that you're *denying* the privileges). Ignoring the first digit, which
is for special bits, you can see that you deny the user (dave) nothing;
but, deny group and the rest of the world everything.
Check your umask often, and read your permissions right. Don't set files
to chmod 777 because it's unnecessary; 755 is good for scripts, 644 for
files, 600 for private files; 640 for files you want your group to see;
660 for files you want your group to write!
It's pretty trivial when you look at it!
- Yuki.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2917 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20060217/dd7af4fc/attachment.bin>
More information about the ubuntu-users
mailing list