Page 1 of 1

Newbie question 777 on directory or just file?

Posted: Thu Nov 06, 2008 7:49 am
by zenkert
Hi,

This is a real newbie question I guess.
I need to have read and write permission - 777 - on just one single file in a directory.
Is it enough to set 777 on just the file?
Or do I have to set it on the whole directory?

(PS the directory and the file are already in a password protected area of the site)

Zenkert

Re: Newbie question 777 on directory or just file?

Posted: Thu Nov 06, 2008 8:12 am
by VladSun

Code: Select all

vladsun@designer:~$ mkdir dir
vladsun@designer:~$ touch dir/file
vladsun@designer:~$ ls -lR
.:
total 8
-rwx------ 1 root    root     678 2008-09-13 21:40 db_check
drwxr-xr-x 2 vladsun vladsun 4096 2008-11-06 16:10 dir
 
./dir:
total 0
-rw-r--r-- 1 vladsun vladsun 0 2008-11-06 16:10 file
vladsun@designer:~$ chmod 000 dir
vladsun@designer:~$ cd dir/
bash: cd: dir/: Permission denied
vladsun@designer:~$ chmod 100 dir
vladsun@designer:~$ cd dir/
vladsun@designer:~/dir$ cd ..
vladsun@designer:~$ ls dir/
ls: dir/: Permission denied
vladsun@designer:~$ chmod 500 dir
vladsun@designer:~$ ls dir/
file
vladsun@designer:~$ touch dir/file2
touch: cannot touch `dir/file2': Permission denied
vladsun@designer:~$ chmod 700 dir
vladsun@designer:~$ touch dir/file2
vladsun@designer:~$ ls dir/
file  file2
vladsun@designer:~$
 
...

Code: Select all

vladsun@designer:~$ chmod 500 dir
vladsun@designer:~$ echo "Example" > dir/file2
vladsun@designer:~$ cat dir/file2
Example
vladsun@designer:~$ ls -l dir/file2
-rw-r--r-- 1 vladsun vladsun 8 2008-11-06 16:13 dir/file2
vladsun@designer:~$ rm dir/*
rm: cannot remove `dir/file': Permission denied
rm: cannot remove `dir/file2': Permission denied
vladsun@designer:~$ chmod 700 dir
vladsun@designer:~$ rm dir/*
vladsun@designer:~$ ls dir/
vladsun@designer:~$

Re: Newbie question 777 on directory or just file?

Posted: Thu Nov 06, 2008 8:38 am
by zenkert
Vladsun, I do not understand your answer.
My site is on adminstaited by me on cPanel.
So I guess I just have to alter the permisson to the directory or the file or both?

Zenkert

Re: Newbie question 777 on directory or just file?

Posted: Thu Nov 06, 2008 9:29 am
by VladSun
I think my post is more than an answer to your question - you have to understand what I've shown and you will get your particular answer.

Also, why don't you just try what you are asking? Starting with the file, then directory, then both. The first one to work is your solution ;)

Re: Newbie question 777 on directory or just file?

Posted: Thu Nov 06, 2008 2:25 pm
by zenkert
You´re one "h..." of a guy :lol:
Real hard coder I guess :D

Anyway, after your first answer I´ve tried and both solutions work.
I went for setting 777 to the file, since that for me seemed more secure.

But I have to say - to understand what you wrote in the first answer I have to study hard.
REAL HARD :D