The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to unset the readonly variable Nidhi2177 UNIX for Advanced & Expert Users 2 09-12-2007 05:35 AM
Readonly access faruque.ahmed UNIX for Dummies Questions & Answers 13 01-31-2007 09:25 AM
DDD making problem azazel11998 High Level Programming 0 03-10-2005 07:10 AM
pls hlp: making .sh files executable ropers Filesystems, Disks and Memory 2 07-29-2002 05:44 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-14-2003
Flyguy Flyguy is offline
Registered User
  
 

Join Date: Nov 2003
Posts: 2
Making files readonly with vi?

Hi,

I'm new at this whole Unix thing, but definately learning (lots of fun)...

and I was wondering - how do you make a file read-only with vi? I don't mean how do you load up vi in read-only mode, but how do you save a file (or flag a file, or whatever) in vi to read-only? How do you make it not read-only after it has been set to read-only? Thanks a lot!
  #2 (permalink)  
Old 11-15-2003
max_min max_min is offline
Registered User
  
 

Join Date: Nov 2003
Posts: 10
See the man page for vi


view Start in read-only mode. You will be protected from writing the files. Can also be done with the "-R" argument.

-R Read-only mode. The 'readonly' option will be set. You can still edit the buffer, but will be prevented from accidently overwriting a file. If you do want to overwrite a file, add an exclamation mark to the Ex command, as in ":w!". The 'readonly' option can be reset with ":set noro". See ":help 'readonly'".
  #3 (permalink)  
Old 11-15-2003
kduffin's Avatar
kduffin kduffin is offline Forum Advisor  
UN1X
  
 

Join Date: Nov 2003
Location: Maryland
Posts: 449
You could set your umask before editing the file.

$ umask 266

That would leave any file you edit as read-only to owner. You'll need to switch back immediately after editing the first file, as strange behavior can result from such.

$ umask 022

Cheers,

Keith

Last edited by kduffin; 11-17-2003 at 10:40 PM..
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 01:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0