Date: Tue, 2 Dec 2008 11:06:19 +0100 From: Mel <fbsd.questions@rachie.is-a-geek.net> To: freebsd-questions@freebsd.org Cc: Adam Zaleski <talk@holon.urwis.cc> Subject: Re: Problem with permissions and vi Message-ID: <200812021106.20916.fbsd.questions@rachie.is-a-geek.net> In-Reply-To: <493500C0.3030202@holon.urwis.cc> References: <493500C0.3030202@holon.urwis.cc>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 02 December 2008 10:32:48 Adam Zaleski wrote: > Hello, > > I have a problem setting up some permissions to file > and editing this file with vi.. I have two different > examples to show you what I mean... First one: > > [netlest@unixlab ~]$ echo "some text" > some_file.txt > [netlest@unixlab ~]$ chmod 000 some_file.txt > [netlest@unixlab ~]$ ls -l some_file.txt > ---------- 1 netlest staff 10 2 gru 09:55 some_file.txt > [netlest@unixlab ~]$ echo "some other text" >> some_file.txt > -bash: some_file.txt: Permission denied > [netlest@unixlab ~]$ cat some_file.txt > cat: some_file.txt: Permission denied > [netlest@unixlab ~]$ chmod 600 some_file.txt > [netlest@unixlab ~]$ cat some_file.txt > some text > [netlest@unixlab ~]$ > > > Everythink was ok... > > And now.. another one > [netlest@unixlab ~]$ echo "some text" > some_file.txt > [netlest@unixlab ~]$ chmod 000 some_file.txt > [netlest@unixlab ~]$ ls -l some_file.txt > ---------- 1 netlest staff 10 2 gru 09:55 some_file.txt > [netlest@unixlab ~]$ vi some_file.txt > > Now ignore warnings with permission denied showing in vim.. > and put some text into the some_file.txt and then :wq! > > [netlest@unixlab ~]$ ls -l some_file.txt > ---------- 1 netlest staff 33 2 gru 10:23 some_file.txt > [netlest@unixlab ~/t]$ cat some_file.txt > cat: some_file.txt: Permission denied > [netlest@unixlab ~/t]$ chmod 600 some_file.txt > [netlest@unixlab ~/t]$ cat some_file.txt > aasda > sd > a some texs > asdas > d > as > [netlest@unixlab ~/t]$ > > > Why I am able to put some text into some_file.txt with > chmod 000 using vi editor and why i can not do the same > using echo??? Because you have write access on the directory and :wq with an exclamation mark !, forces the write, which in actuality removes the file and writes the editor contents to a new file, then restores permissions. -- Mel Problem with today's modular software: they start with the modules and never get to the software part.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812021106.20916.fbsd.questions>