LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-10-2007, 03:06 AM   #1
sefaklc
LQ Newbie
 
Registered: Aug 2007
Location: ankara(turkey)
Distribution: ubuntu,red hat
Posts: 28

Rep: Reputation: 15
writing to a read-only directory


hello.i have changed the permissions of a directory to read-only
Code:
dr--r--r--  2 sefa sefa 139264 Aug  8 07:22 repo_2
but when i try to make somedirectory inside the directory or create a file, it permits to write.
thank you
 
Old 08-10-2007, 03:23 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 63
It should not; at least not directly.

However, some programs (vi for example) will allow you to override the non-writable status after confirmation from you (in vi it is the '!' you put after the 'w'). The logic is that you're the owner of the directory, so you could chmod u+w dir, save dir/file, and chmod u-w dir. Hence the programs allows you to write to save you the trouble of the chmods.

I suppose there exists programs that misbehave and don't even check you are aware of this. Maybe the shell; I did not try.

Yves.
 
Old 08-10-2007, 03:25 AM   #3
iceman_san
LQ Newbie
 
Registered: Aug 2007
Posts: 21

Rep: Reputation: 15
i think it will do it for u

chmod -R 644 repo_2 .
 
Old 08-10-2007, 03:29 AM   #4
sefaklc
LQ Newbie
 
Registered: Aug 2007
Location: ankara(turkey)
Distribution: ubuntu,red hat
Posts: 28

Original Poster
Rep: Reputation: 15
it does everything :: copying a file to inside of read-only dir,writing a file with vi (only :w) , create new file with 'touch'
i am using rhel5 on vmware workstation. (may it misbehave because of this?)
thank you!
 
Old 08-10-2007, 03:45 AM   #5
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 63
Strange... Are you doing this as root perhaps?
 
Old 08-10-2007, 03:50 AM   #6
sefaklc
LQ Newbie
 
Registered: Aug 2007
Location: ankara(turkey)
Distribution: ubuntu,red hat
Posts: 28

Original Poster
Rep: Reputation: 15
thanks a lot for your quick replies.
i am doing this :
Code:
[root@localhost Desktop]# 
[root@localhost Desktop]# mkdir test
[root@localhost Desktop]# ls -al
total 364
drwx------  4 sefa sefa   4096 Aug  8 08:01 .
drwx------ 20 sefa sefa   4096 Aug  8 07:05 ..
-rw-rw-r--  1 sefa sefa 191991 Aug  7 04:40 perl-Date-Calc-5.0-15.i386.rpm
drw-r--r--  2 sefa sefa 139264 Aug  8 07:50 repo_2
drwxr-xr-x  2 root root   4096 Aug  8 08:01 test
[root@localhost Desktop]# chmod 444 test/
[root@localhost Desktop]# ls -al
total 364
drwx------  4 sefa sefa   4096 Aug  8 08:01 .
drwx------ 20 sefa sefa   4096 Aug  8 07:05 ..
-rw-rw-r--  1 sefa sefa 191991 Aug  7 04:40 perl-Date-Calc-5.0-15.i386.rpm
drw-r--r--  2 sefa sefa 139264 Aug  8 07:50 repo_2
dr--r--r--  2 root root   4096 Aug  8 08:01 test
[root@localhost Desktop]# mkdir ./test/test_directory 
[root@localhost Desktop]# touch ./test/test_file
[root@localhost Desktop]# cd test
[root@localhost test]# ls -al
total 28
dr--r--r-- 3 root root 4096 Aug  8 08:01 .
drwx------ 4 sefa sefa 4096 Aug  8 08:01 ..
drwxr-xr-x 2 root root 4096 Aug  8 08:01 test_directory
-rw-r--r-- 1 root root    0 Aug  8 08:01 test_file
[root@localhost test]#
 
Old 08-10-2007, 03:51 AM   #7
sefaklc
LQ Newbie
 
Registered: Aug 2007
Location: ankara(turkey)
Distribution: ubuntu,red hat
Posts: 28

Original Poster
Rep: Reputation: 15
thanks a lot for your quick replies.
i am doing this :
Code:
[root@localhost Desktop]# 
[root@localhost Desktop]# mkdir test
[root@localhost Desktop]# ls -al
total 364
drwx------  4 sefa sefa   4096 Aug  8 08:01 .
drwx------ 20 sefa sefa   4096 Aug  8 07:05 ..
-rw-rw-r--  1 sefa sefa 191991 Aug  7 04:40 perl-Date-Calc-5.0-15.i386.rpm
drw-r--r--  2 sefa sefa 139264 Aug  8 07:50 repo_2
drwxr-xr-x  2 root root   4096 Aug  8 08:01 test
[root@localhost Desktop]# chmod 444 test/
[root@localhost Desktop]# ls -al
total 364
drwx------  4 sefa sefa   4096 Aug  8 08:01 .
drwx------ 20 sefa sefa   4096 Aug  8 07:05 ..
-rw-rw-r--  1 sefa sefa 191991 Aug  7 04:40 perl-Date-Calc-5.0-15.i386.rpm
drw-r--r--  2 sefa sefa 139264 Aug  8 07:50 repo_2
dr--r--r--  2 root root   4096 Aug  8 08:01 test
[root@localhost Desktop]# mkdir ./test/test_directory 
[root@localhost Desktop]# touch ./test/test_file
[root@localhost Desktop]# cd test
[root@localhost test]# ls -al
total 28
dr--r--r-- 3 root root 4096 Aug  8 08:01 .
drwx------ 4 sefa sefa 4096 Aug  8 08:01 ..
drwxr-xr-x 2 root root 4096 Aug  8 08:01 test_directory
-rw-r--r-- 1 root root    0 Aug  8 08:01 test_file
[root@localhost test]#
 
Old 08-10-2007, 03:57 AM   #8
fatra2
Member
 
Registered: Feb 2004
Location: Switzerland
Distribution: Fedora - RedHat - Mandrake - OpenSuse
Posts: 216

Rep: Reputation: 35
Hi there,

Like theYinYeti pointed out, and from what I can see from your last reply
Quote:
[root@localhost Desktop]#
you are trying your operations as root. You have to know that on the machine root has every rights. That probably explains the reasons why root can create file into a non-writable folder. root says to the machine that it does not care if the folder allows to write, root wants to create a file in that folder.

You should try the same operation as a normal user.
 
Old 08-10-2007, 04:08 AM   #9
sefaklc
LQ Newbie
 
Registered: Aug 2007
Location: ankara(turkey)
Distribution: ubuntu,red hat
Posts: 28

Original Poster
Rep: Reputation: 15
thank you so much , it works,there are no programs that misbehaved =) . only i misbehaved =)
thanks again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Samba: Problem writing to a group-writable directory pschoenb Linux - Server 5 02-28-2007 07:34 PM
Writing to an read-only embedded linux system!! cheema Linux - General 1 01-26-2005 05:20 PM
writing to home directory from windows jsmarshall85 Linux - Networking 1 07-23-2004 10:39 AM
Writing to a shared directory under Mandrake 9x julius Linux - Networking 1 03-28-2004 03:44 AM
writing in read only files endezeichen Linux - Software 3 12-20-2003 04:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration