From owner-freebsd-questions@FreeBSD.ORG Tue Dec 2 10:06:26 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BA44A1065673 for ; Tue, 2 Dec 2008 10:06:26 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from mail.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 8FB898FC0A for ; Tue, 2 Dec 2008 10:06:26 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from localhost (mail.rachie.is-a-geek.net [192.168.2.101]) by mail.rachie.is-a-geek.net (Postfix) with ESMTP id A1506AFC1C6; Tue, 2 Dec 2008 01:06:25 -0900 (AKST) From: Mel To: freebsd-questions@freebsd.org Date: Tue, 2 Dec 2008 11:06:19 +0100 User-Agent: KMail/1.9.7 References: <493500C0.3030202@holon.urwis.cc> In-Reply-To: <493500C0.3030202@holon.urwis.cc> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200812021106.20916.fbsd.questions@rachie.is-a-geek.net> Cc: Adam Zaleski Subject: Re: Problem with permissions and vi X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Dec 2008 10:06:26 -0000 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.